我使用vcpkg命令安装了boost-variant2
库:
vcpkg install boost-variant2:x64-windows
当vcpkg完成安装后,它会提示如下信息:
The package boost is compatible with built-in CMake targets:
find_package(Boost REQUIRED [COMPONENTS <libs>...])
target_link_libraries(main PRIVATE Boost::boost Boost::<lib1> Boost::<lib2> ...)
因此,在我的CMakeLists.txt中,我添加了以下行:
find_package(Boost COMPONENTS variant2 REQUIRED)
target_link_libraries(MyTarget PRIVATE Boost::variant2)
然而,当我运行 cmake -DCMAKE_TOOLCHAIN_FILE:STRING=/path_to_vcpkg/scripts/buildsystems/vcpkg.cmake
时,出现以下错误:
-- 配置不完整,出现错误!
无法找到 Boost(缺少:variant2)(已找到版本“1.78.0”)