Creating custom build types for quality tools
So far, we have only talked about 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 interfere with the global CMAKE_<LANG>_FLAGS
.
Do Not Override CMAKE_<LANG>_FLAGS
Setting the global compiler option is preferred over the generic CMAKE_<LANG>_FLAGS
in your CMakeLists.txt
. These flags are intended to be set outside the project, either by passing them over the command line or by supplying them with a toolchain file. Modifying them inside a project has a high chance of interfering with the cases where they are set from the outside.
For...