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-G
flag which defaults toMakefile
. A list of all supported generators (e.g. for IDEs) can be found here. - Use the console tool
ccmake
or the guicmake-gui
for 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
cmake
with-DVariable=Value
to set the cmake-internal variableVariable
toValue
.
A complete list of variables recognised by cmake can be found here. - Use
-DCMAKE_BUILD_TYPE
to specify what type of build you would likeDebug, Release, RelWithDebInfo, MinSizeRel
CMake will select appropriate flag for you (e.g.-g
,-O2
). Specifying noBUILD_TYPE
results 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=ON
to build shared libraries,-DBUILD_SHARED_LIBS=OFF
to build static libraries. In preCICE, we default toON
since v2.3. - To use
ccache
ordistcc
with cmake please set the variable CXX_COMPILER_LAUNCHER. - Use
-DCMAKE_INSTALL_PREFIX=/path/to/dir/
to specify the install prefix. Default is/usr/local
on unix. Read more