如何确定CMake的Boost库名称 [英] How to determine the Boost library names for CMake
问题描述
我正在尝试找出boost
库的CMakeList.txt中Find
的哪些组件.
I am trying to figure out what components to Find
in CMakeList.txt for boost
libraries.
我查看了该目录/usr/local/include/boost
.我随机选择了一些文件夹,并尝试使用FIND_PACKAGE
.这些都很好用.
I looked at this directory /usr/local/include/boost
. And I randomly pick some of the folders and try to use FIND_PACKAGE
. These following all works well.
FIND_PACKAGE(Boost COMPONENTS thread system log log_setup
signals graph memory_order program_options REQUIRED)
我正在使用的特定计算机是property_tree
.它不起作用,并产生以下错误消息:
The particular one that I am using is property_tree
. It is not working and produces the following error message:
/Applications/CMake.app/Contents/share/cmake-3.1/Modules/FindBoost.cmake:1182(消息)处的CMake错误:
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.1/Modules/FindBoost.cmake:1182 (message):
无法找到请求的Boost库.
Unable to find the requested Boost libraries.
增强版本:1.55.0
Boost version: 1.55.0
增强包含路径:/usr/local/include
Boost include path: /usr/local/include
找不到以下静态Boost库:
Could not find the following static Boost libraries:
boost_property_tree
任何人都可以解释一下如何或在何处找到用于增强的适当库名吗?
Could anyone explain how or where I can find the proper library names for boost?
推荐答案
FIND_PACKAGE
的COMPONENTS
部分仅搜索编译的库.它无法检查构成Boost的主要部分的仅标头库.只有少数需要链接的库(大多数是执行平台特定内容的库).
The COMPONENTS
part of FIND_PACKAGE
only searches for compiled libraries. It is not able to check for the header-only libraries that comprise a major part of Boost. There are only a few libraries that require linking (mostly those that perform platform-specific things).
在您的示例中,仅需预先构建thread
,signals
(与signals2
(仅标头)不同),system
和program_options
,然后将其与程序链接.对于其余的内容,包括相关的头文件就足够了.
From your examples, only thread
, signals
(in contrast to signals2
which is header-only), system
and program_options
need to be build beforehand and then linked with your program. For the rest, it is sufficient to include the relevant header files .
因此,只需将${Boost_INCLUDE_DIRS}
添加到目标的包含目录中即可.
Thus, it is sufficient to add ${Boost_INCLUDE_DIRS}
to the include directories of your target.
请参阅此处以获取这些库的列表哪些boost库仅是头文件?
See here for a list of libraries of these libraries Which boost libraries are header-only?
这篇关于如何确定CMake的Boost库名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!