Cmake链接boost库


没有安装在默认路径下使用:

 

set(BOOST_ROOT /usr/include/boost)////设置自己的路径
set(Boost_NO_SYSTEM_PATHS NO)////////这里是说明用系统路径  一般默认使用 默认安装在/usr/include/boost
find_package(Boost COMPONENTS regex system REQUIRED)

if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
MESSAGE( STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}.")
MESSAGE( STATUS "Boost_LIBRARIES = ${Boost_LIBRARIES}.")
MESSAGE( STATUS "Boost_LIB_VERSION = ${Boost_LIB_VERSION}.")
add_executable(main main.cpp)
target_link_libraries (main ${Boost_LIBRARIES})
endif()

 

 

安装在默认路径 直接使用好了

 

find_package(Boost COMPONENTS regex system REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
MESSAGE( STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}.")
MESSAGE( STATUS "Boost_LIBRARIES = ${Boost_LIBRARIES}.")
MESSAGE( STATUS "Boost_LIB_VERSION = ${Boost_LIB_VERSION}.")
add_executable(main main.cpp)
target_link_libraries (main ${Boost_LIBRARIES})
endif()


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM