c++ - Boost+CMake:没有合适的构建变体
问题描述
我正在尝试为我参与的项目在嵌入式类似 SPARC 的机器上部署一些库。我在这台机器上成功地构建了前沿的 Boost 库并将其安装到 /util 目录中。然后我尝试为 CMake 编写简单的测试脚本。这是此脚本的开头:
cmake_minimum_required(VERSION 2.8.3)
project(cpp_boost_test)
find_package(Boost REQUIRED COMPONENTS system thread)
find_package(console_bridge REQUIRED)
message(STATUS "Boost Includes: ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost Libraries: ${Boost_LIBRARIES}")
运行时我收到以下错误消息:
-- Found Boost 1.70.0 at /util/lib/cmake/Boost-1.70.0
-- Requested configuration: QUIET REQUIRED COMPONENTS
system;thread
-- Found boost_headers 1.70.0 at /util/lib/cmake/boost_headers-1.70.0
-- Found boost_system 1.70.0 at /util/lib/cmake/boost_system-1.70.0
-- No suitable boost_system variant has been identified!
-- libboost_system.so.1.70.0 (shared, BUILD_SHARED_LIBS not ON, set Boost_USE_STATIC_LIBS=OFF to override)
CMake Error at /util/lib/cmake/Boost-1.70.0/BoostConfig.cmake:60 (find_package):
Found package configuration file:
/util/lib/cmake/boost_system-1.70.0/boost_system-config.cmake
but it set boost_system_FOUND to FALSE so package "boost_system" is considered to be NOT FOUND.
Reason given by package:
No suitable build variant has been found.
Call Stack (most recent call first):
/util/lib/cmake/Boost-1.70.0/BoostConfig.cmake:89 (boost_find_dependency)
/util/share/cmake-3.7/Modules/FindBoost.cmake:229 (find_package)
CMakeLists.txt:4 (find_package)
我尝试设置 Boost_USE_STATIC_LIBS 选项,但错误仍然存在。
这可能是 Boost.System 中的版本冲突吗?我应该怎么做才能避免这个错误?无法从项目中删除 Boost,因此我无法接受有关此类删除的答案...
解决方案
我调查了 Boost 的变化历史,所以答案是在链接 Boost 的项目中构建依赖项应该手动包含到 CMake 中(请参阅此处的答案:CMake finds Boost but the import targets not available for Boost version for details)。因此,必须使用比您使用的 CMake 版本稍旧的 Boost 版本。我通过回滚到 Boost 1.61 解决了我的问题(根据我的嵌入式平台的特性,我无法编译高于 3.7.0 的 CMake 版本)。
推荐阅读
- python-3.x - 在框架中看不到 tkinter 按钮/标签
- javascript - Firebase Cloud Functions:无法通过 Axios 使用 http.get 请求的 JSON 输出
- r - 有条件地删除文件
- r - R Shiny:如何在过滤器中按升序显示值
- ios - iOS Swift Canvas 绘图和框架功能
- laravel - Laravel Passport 如何无密码登录,只使用手机?
- powerbi - 在 Power BI 中创建折线图
- php - 重定向后 Laravel Auth 会话丢失(使用 Web 中间件)
- javascript - 搜索在反应中不像期望的那样工作
- python-3.x - 无法理解 opencv2 python 中的 dtype 错误