-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
CMake Best Practices - Second Edition
By :
So far, we have discussed build types such as Debug, Release, RelWithDebInfo, and MinSizeRel, which are provided by CMake by default. These build types can be extended with custom build types that pass global flags to all targets. For the code quality tools that rely on certain compiler flags, providing a custom build type can simplify CMakeLists.txt considerably, especially for large projects. Creating a custom build type is also much preferred to directly interfering with the global CMAKE_<LANG>_FLAGS.
Do not override CMAKE_<LANG>_FLAGS
Setting the global compiler option is over the generic CMAKE_<LANG>_FLAGS in your CMakeLists.txt. These flags are intended to be set outside a project, either by passing them over the command line or by supplying them with a toolchain file. Modifying them inside a project creates a high chance of interfering with the cases where they are set from the outside.
For multi-configuration...