我有一个非常简单的 CMake 文件,它在 linux 上运行良好,但在 windows 上,它说它找不到 boost(即使它似乎找到它,因为它说“找到合适的版本”)。这是初始构建文件:
cmake_minimum_required(VERSION 3.16.3)
project(filecompare)
set(CMAKE_CXX_STANDARD 20)
find_package(Boost 1.73.0 COMPONENTS program_options)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(filecompare filecompare.cpp)
target_link_libraries(filecompare ${Boost_LIBRARIES})
endif()
CMake 输出:
-- Could NOT find Boost (missing: Boost_INCLUDE_DIR program_options) (Required is at least version "1.73.0")
-- Configuring done
-- Generating done
-- Build files have been written to: C:/repos/filecompare/cmake-build-debug
所以它似乎无法自己找到库,所以我在 find_package 上面添加了这些行:
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "C:/local/boost_1_73_0")
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "C:/local/boost_1_73_0/lib64-msvc-14.2")
现在它似乎以某种方式找到了库,但没有,这是输出:
-- Could NOT find Boost (missing: program_options) (found suitable version "1.73.0", minimum required is "1.73.0")
-- Configuring done
-- Generating done
-- Build files have been written to: C:/repos/filecompare/cmake-build-debug
我尝试设置如下内容:
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
SET(BOOST_ROOT "C:/local/boost_1_73_0/boost")
但这也无济于事。那么我在这里做错了什么?我在带有 VisualStudio 2019 的 CLion 上使用 clang-cl