更新时间:2023-11-09 11:43:04
CMake可以像Visual Studio一样为您的VS解决方案生成 RelWithDebInfo
配置.
CMake does - as Visual Studio would do - generate a RelWithDebInfo
configuration for your VS solution.
但是您也可以将调试信息添加到其他配置-如 Release
-也可以使用例如 target_compile_options()
和发电机专家,以提供必要的/Zi
或/Z7
命令:
But you can add debug info to other configurations - like Release
- also with the use of e.g. target_compile_options()
and generator experssions to give the necessary /Zi
or /Z7
command:
target_compile_options(
${PROJECT_NAME}
PRIVATE
"$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<CONFIG:RELEASE>>:/Zi>"
)
or you could just say you want it for all configurations and all targets with add_compile_options()
(and without generator expressions for better readability):
project(...)
if (MSVC)
add_compile_options("/Zi")
endif()
参考