主要CMAKE FindBoost模块的官方文档。
这里假设boost安装位置为D:\Boost_1_61_0
。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| cmake_minimum_required(VERSION 2.8) project (test_boost) IF(WIN32) set(BOOST_ROOT D:/boost_1_61_0) set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) find_package(Boost 1.61.0 REQUIRED COMPONENTS program_options regex) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) endif() aux_source_directory(test_boost TEST_BOOST) add_executable(test_boost ${TEST_BOOST}) target_link_libraries(test_boost ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_REGEX_LIBRARY})
|