在CMakeLists.txt中使用find_package(Boost ...)时CMake错误:未找到合适的构建变体 [英] CMake Error while using find_package(Boost ... ) in CMakeLists.txt: No suitable build variant has been found

查看:213
本文介绍了在CMakeLists.txt中使用find_package(Boost ...)时CMake错误:未找到合适的构建变体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用CMake时,调用 find_package(必须安装Boost 1.6 COMPONENTS program_options线程系统)时出现以下错误:

When using CMake, I get the following error when calling find_package(Boost 1.6 COMPONENTS program_options thread system REQUIRED):

-- Boost include dirs: C:/dev/boost/include/boost-1_72
-- Boost libraries:
Boost library
-- Found Boost 1.72.0 at C:/dev/boost/lib/cmake/Boost-1.72.0
--   Requested configuration: QUIET REQUIRED COMPONENTS program_options;thread;system
-- BoostConfig: find_package(boost_headers 1.72.0 EXACT CONFIG REQUIRED QUIET HINTS C:/dev/boost/lib/cmake)
-- BoostConfig: find_package(boost_program_options 1.72.0 EXACT CONFIG REQUIRED QUIET HINTS C:/dev/boost/lib/cmake)
-- Found boost_program_options 1.72.0 at C:/dev/boost/lib/cmake/boost_program_options-1.72.0
-- Boost toolset is vc142 (MSVC 19.25.28612.0)
-- Scanning C:/dev/boost/lib/cmake/boost_program_options-1.72.0/libboost_program_options-variant*.cmake
--   Including C:/dev/boost/lib/cmake/boost_program_options-1.72.0/libboost_program_options-variant-vc142-mt-gd-x32-1_72-static.cmake
--   [ ] libboost_program_options-vc142-mt-gd-x32-1_72.lib
--   Including C:/dev/boost/lib/cmake/boost_program_options-1.72.0/libboost_program_options-variant-vc142-mt-gd-x64-1_72-static.cmake
--   [ ] libboost_program_options-vc142-mt-gd-x64-1_72.lib
--   Including C:/dev/boost/lib/cmake/boost_program_options-1.72.0/libboost_program_options-variant-vc142-mt-x32-1_72-static.cmake
--   [ ] libboost_program_options-vc142-mt-x32-1_72.lib
--   Including C:/dev/boost/lib/cmake/boost_program_options-1.72.0/libboost_program_options-variant-vc142-mt-x64-1_72-static.cmake
--   [ ] libboost_program_options-vc142-mt-x64-1_72.lib
CMake Error at C:/dev/boost/lib/cmake/Boost-1.72.0/BoostConfig.cmake:120 (find_package):
  Found package configuration file:

    C:/dev/boost/lib/cmake/boost_program_options-1.72.0/boost_program_options-config.cmake

  but it set boost_program_options_FOUND to FALSE so package
  "boost_program_options" is considered to be NOT FOUND.  Reason given by
  package:

  No suitable build variant has been found.

  The following variants have been tried and rejected:

  * libboost_program_options-vc142-mt-gd-x32-1_72.lib (32 bit, need 64)

  * libboost_program_options-vc142-mt-gd-x64-1_72.lib (static,
  Boost_USE_STATIC_LIBS=OFF)

  * libboost_program_options-vc142-mt-x32-1_72.lib (32 bit, need 64)

  * libboost_program_options-vc142-mt-x64-1_72.lib (static,
  Boost_USE_STATIC_LIBS=OFF)

Call Stack (most recent call first):
  C:/dev/boost/lib/cmake/Boost-1.72.0/BoostConfig.cmake:185 (boost_find_component)
  C:/dev/cmake-3.17.0-win64-x64/share/cmake-3.17/Modules/FindBoost.cmake:444 (find_package)
  CMakeLists.txt:79 (find_package)


-- Configuring incomplete, errors occurred!
See also "C:/Users/sbreuer/Documents/Uni/Praktikum/SunFlower/Simulation/code/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/sbreuer/Documents/Uni/Praktikum/SunFlower/Simulation/code/build/CMakeFiles/CMakeError.log".

我不明白这里的问题.我为 include lib 目录添加了环境变量.我正在使用CMake 3.17.0和Boost 1.72.0

I do not understand the problem here. I added the environment variables for the include and the lib directory. I am using CMake 3.17.0 and Boost 1.72.0

推荐答案

错误的重要部分在这里:

The important section of the error is here:

  No suitable build variant has been found.

  The following variants have been tried and rejected:

  * libboost_program_options-vc142-mt-gd-x32-1_72.lib (32 bit, need 64)

  * libboost_program_options-vc142-mt-gd-x64-1_72.lib (static,
  Boost_USE_STATIC_LIBS=OFF)

  * libboost_program_options-vc142-mt-x32-1_72.lib (32 bit, need 64)

  * libboost_program_options-vc142-mt-x64-1_72.lib (static,
  Boost_USE_STATIC_LIBS=OFF)

它显示找到的库,并给出拒绝它们的原因.此处的所有库均为 static ,如其名称上的 lib 前缀所示.但是,您的CMake配置指示您要使用静态库( Boost_USE_STATIC_LIBS = OFF ).要解决该错误,您有两种选择:

It shows the libraries that were found, and gives the reason why they were rejected. All of the libraries here are static, as indicated by the lib prefix on their names. However, your CMake configuration indicates you do not want to use static libraries (Boost_USE_STATIC_LIBS=OFF). To fix the error, you have two options:

  1. Boost_USE_STATIC_LIBS 设置为 ON :

set(Boost_USE_STATIC_LIBS ON)
find_package(Boost 1.6 COMPONENTS program_options thread system REQUIRED)

  • 构建共享 Boost库,因此不仅只有静态库可用.

  • Build the shared Boost libraries, so not only the static libraries are available.

    这篇关于在CMakeLists.txt中使用find_package(Boost ...)时CMake错误:未找到合适的构建变体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆