背景
Cmake内包含find_package(Boost COMPONENTS system filesystem program_options REQUIRED)
下载boost_1_84_0,解压到自定义路径,使用默认bootstrap.bat
+b2.exe
调用Cmake ..
报错 Could NOT find Boost (missing: system filesystem program_options)
往环境变量内加入BOOST_ROOT
后报错Could NOT find Boost (missing: system filesystem program_options) (found version "1.84.0")
解决方案
往CMakeLists.txt内加入(加在find_package
段前)
set(BOOST_ROOT "xxx/boost_1_84_0")
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "xxx/boost_1_84_0")
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "xxx/boost_1_84_0/stage/lib")
还是报错Could NOT find Boost (missing: system filesystem program_options) (found version "1.84.0")
再加入
set(Boost_LIB_PREFIX "lib")
生成成功
CMake Warning at D:/Cmake/share/cmake-3.27/Modules/FindBoost.cmake:1384 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: xxx/build