构建项目时,Boost_LIBRARIES不包含program_options,即使它是必需的和找到的。如果我手动添加它,它工作正常。我的CMake包含以下内容:
find_package(Boost 1.60.0 REQUIRED COMPONENTS program_options thread system regex)
message("${Boost_LIBRARIES}")
include_directories(include ${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
target_link_libraries (proj ${Boost_LIBRARIES} boost_program_options)
CMake声称已找到该库,但未在message("${Boost_LIBRARIES}")
答案 0 :(得分:1)
重写现代CMake的代码:
find_package(Boost 1.60.0 REQUIRED COMPONENTS program_options thread system regex)
add_executable(proj ...)
target_link_libraries(proj Boost::program_options ...)
忘记生成的Boost_BLAH_LBAH
个变量和include_directories
+ link_directories
。
如果使用Boost finder导致smth出错,请将-DBoost_DEBUG=ON
添加到cmake
命令行。
如果smth出错w /(any / generic)find_package
添加-DCMAKE_FIND_DEBUG_MODE=ON
。
另见灵感:https://steveire.wordpress.com/2017/11/05/embracing-modern-cmake/