以debug模式为例
方式1:
cmake .. -DCMAKE_BUILD_TYPE=Debug #根据cmake参数来设置编译类型
若命令行直接cmake ..
一般是编译成Release模式
方式2:
在CMakeLists.txt 中 进行设置
SET(CMAKE_BUILD_TYPE “Debug”)
方式3:
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message("Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
# 找到boost特定版本,以及需要的子模块,1.46.1为最低版本,REQUIRED强调必须找到该模块,否则编译失败;
#?COMPONENTS后面罗列一组子模块(这些子模块都属于boost)
find_package(Boost 1.46.1 REQUIRED COMPONENTS filesystem system)
# 验证是否发现boost
if(Boost_FOUND)
message ("boost found")
else()
message (FATAL_ERROR "Cannot find Boost")
endif()
链接对应库文件
target_link_libraries( third_party_include
PRIVATE
Boost::filesystem
)3. 包含子目录 cmake思路
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。