General information on CMake
- CMake is a tool for build system configuration.
It generates a chosen build system in the directory it was executed in. The build system to generate can be specified using the-Gflag which defaults toMakefile. A list of all supported generators (e.g. for IDEs) can be found here. - Use the console tool
ccmakeor the guicmake-guifor a more comfortable configuration. - The generated build system automatically reconfigures cmake when necessary.
- It respects your environment variables
CXX,CXX_FLAGS, … during configuration.
Please use them to set your compiler and warning level of choice. - Invoke
cmakewith-DVariable=Valueto set the cmake-internal variableVariabletoValue.
A complete list of variables recognised by cmake can be found here. - Use
-DCMAKE_BUILD_TYPEto specify what type of build you would likeDebug, Release, RelWithDebInfo, MinSizeRel
CMake will select appropriate flag for you (e.g.-g,-O2). Specifying noBUILD_TYPEresults in an un-optimised non-debug build. - The generated build system knows where the source directory is.
It is thus possible to have multiple configurations using the same (e.g.
build/debug/,build/release/) - Use
-DBUILD_SHARED_LIBS=ONto build shared libraries,-DBUILD_SHARED_LIBS=OFFto build static libraries. In preCICE, we default toONsince v2.3. - To use
ccacheordistccwith cmake please set the variable CXX_COMPILER_LAUNCHER. - Use
-DCMAKE_INSTALL_PREFIX=/path/to/dir/to specify the install prefix. Default is/usr/localon unix. Read more