您的位置:首页 > 其它

CMake使用心得

2018-02-23 17:35 162 查看

CMake为Debug和Release分别设置不同的选项

编译选项

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")


链接选项

add_executable( MyEXE ${SOURCES})
target_link_libraries( MyEXE debug 3PDebugLib)
target_link_libraries( MyEXE optimized 3PReleaseLib)


ref: https://stackoverflow.com/questions/2209929/linking-different-libraries-for-debug-and-release-builds-in-cmake-on-windows

A "debug", "optimized", or "general" keyword indicates that the library immediately following it is to be used only for the corresponding build configuration.


CMake为VS工程添加source或include过滤器

FILE(GLOB srcs src/*.cpp)
FILE(GLOB inc include/*.h)

source_group("include" FILES ${inc})
source_group("Source Files" FILES ${srcs})
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  cmake