I got a bunch of C++
sources files and headers. They may use external libraries such as Boost e.g. I am interested in the process of building binaries for Windows and *nix.
-
Makefiles (*nix) and .vcproj (Windows) call compilers with some specifications such as the order of compilation, compilation options and stuff.
-
CMakeLists.txt can be used by CMake to build either makefiles or .vcproj and use very helpful commands such as recursive search of files, automatic linkage with known libraries, installers, variables that can be used in source files…
Is there any existing tool that would generate a CMakeLists.txt from specified options ? Options could be like : scan this folder and make a library out of it, then scan this other folder and make an executable and automatically link both with Boost as well along with a user friendly installer with generated INSTALL.txt and README.txt. Something very powerful like that.
4
I recently started learning CMake myself, and like Delnan mentions in his comment there is really no point in wrapping the creation of those scripts further in some kind of tool. The problems that you are trying to solve are pretty much the purpose of CMake and its reason for existence.
In fact, what you say you want to do sounds a lot like what the CMakeLists.txt for a project actually would do (without the installation part, which is slightly more involved depending on your needs).
e.g. scanning a folder for source and turning it into a lib is at its heart just a few commands:
cmake_minimum_required(VERSION 2.8)
project(YourProject)
# This is a built-in utility to grab all the source files from a specific
# location into a list
AUX_SOURCE_DIRECTORY(. LOG_SOURCES)
# This is all you need to do to tell CMake that a specific list of files
# should be built as a library (shared in this case)
add_library(Logging SHARED ${LOG_SOURCES})
The above doesn’t yet link any other libraries automatically, or deal with compiler settings, but all of that stuff is possible and relatively straightforward once you start wrapping your head around the CMake-way.
3