【发布时间】:2014-09-22 18:04:58
【问题描述】:
在 2.x 版本的 CMake 中,cmake 选项 CMAKE_BUILD_TYPE 控制要传递给编译器的选项。例如,如果CMAKE_BUILD_TYPE=RelWithDebInfo,那么传递给编译器的选项对于 C++ 是 CMAKE_CXX_FLAGS_RELWITHDEBINFO,对于 C (http://binglongx.wordpress.com/tag/cmake_build_type/) 是 CMAKE_C_FLAGS_RELWITHDEBINFO。
在新的 3.x 版本的 CMake 中,有命令 add_compile_options 和 target_compiler_options 用于向编译器添加选项 (What is the modern method for setting general compile flags in CMake?)。
问题
如何定义 CMake 应该使用的构建类型?还是比如cmake -DCMAKE_BUILD_TYPE=Debug?
如何在我的 CMakeLists.txt 中使用这种构建类型?
CMake 是否定义了所有构建类型,或者我可以定义自定义、附加的构建类型?
CMake 是否为每种构建类型设置了任何默认编译器选项(例如,-g 用于调试构建类型)?
【问题讨论】:
-
the cmake option CMAKE_BUILD_TYPE controlled options to be passed to the compiler不,看到这个answer
标签: cmake