In the 2.x version of CMake, the cmake option CMAKE_BUILD_TYPE
controlled options to be passed to the compiler. For example, if CMAKE_BUILD_TYPE=RelWithDebInfo
then the options passed to the compiler was CMAKE_CXX_FLAGS_RELWITHDEBINFO
for C++ and CMAKE_C_FLAGS_RELWITHDEBINFO
for C (http://binglongx.wordpress.com/tag/cmake_build_type/).
In the new 3.x version of CMake there are commands add_compile_options
and target_compiler_options
for adding options to the compiler (What is the modern method for setting general compile flags in CMake?).
Questions
How do I define which build type CMake should use? Is it still, for example, cmake -DCMAKE_BUILD_TYPE=Debug
?
How do I make use of this build type in my CMakeLists.txt?
Has CMake defined all the build types, or can I define custom, additional, build types?
Has CMake set any default compiler options for each of the build types (for example -g
for the Debug build type)?