FindBoost

查找Boost的inlude目录和库

用如下形式通过调用find_package使用这个模块

find_package(
Boost  [version][EXACT]   #Minimum or EXACT version e.g. 1.36.0[REQUIRED]       #Fail with error if Boost is not found[COMPONENTS <libs>...]     #Boost libraries by their canonical name)       #e.g. "date_time" for "libboost_date_time"

该模块查找头文件和要求的组件库,或者一个通过“BoostCMake”构建提供的CMake包配置文件。对于后者情形,跳过下面的“BoostCMake”段落,对于前者,用变量报告这个结果:

Boost_FOUND                     - True if headers and requested libraries were found
Boost_INCLUDE_DIRS              - Boost include directories
Boost_LIBRARY_DIRS              - Link directories for Boost libraries
Boost_LIBRARIES                 - Boost component libraries to be linked
Boost_<C>_FOUND                 - True if component <C> was found (<C> is upper-case)
Boost_<C>_LIBRARY               - Libraries to link for component <C> (may include target_link_libraries debug/optimized keywords)
Boost_VERSION                   - BOOST_VERSION value from boost/version.hpp
Boost_LIB_VERSION               - Version string appended to library filenames
Boost_MAJOR_VERSION             - Boost major version number (X in X.y.z)
Boost_MINOR_VERSION             - Boost minor version number (Y in x.Y.z)
Boost_SUBMINOR_VERSION          - Boost subminor version number (Z in x.y.Z)
Boost_LIB_DIAGNOSTIC_DEFINITIONS (Windows)-Pass to add_definitions() to have diagnostic information about Boost's automatic linking displayed during compilation

该模块从这些变量中读取关于搜索位置的提示:

BOOST_ROOT                       - Preferred installation prefix 首选安装前缀(or BOOSTROOT)
BOOST_INCLUDEDIR                - Preferred include directory e.g. <prefix>/include
BOOST_LIBRARYDIR                - Preferred library directory e.g. <prefix>/lib Boost_NO_SYSTEM_PATHS         - Set to ON to disable searching in locations not specified by these hint variables. Default is OFF.
Boost_ADDITIONAL_VERSIONS     -List of Boost versions not known to this module (Boost installlocations may contain the version)

并在CMake的cache记录中持续(persistently)存储结果:

Boost_INCLUDE_DIR             - Directory containing Boost headers
Boost_LIBRARY_DIR_RELEASE     - Directory containing release Boost libraries
Boost_LIBRARY_DIR_DEBUG       - Directory containing debug Boost libraries
Boost_<C>_LIBRARY_DEBUG       - Component <C> library debug variant
Boost_<C>_LIBRARY_RELEASE     - Component <C> library release variant

用户可以设置这些提示或结果作为cache记录。工程项目不应直接读取这些这些记录,但可替代的是,可以使用以上结果变量。注意一些提示(hints)以大写的“BOOST”开始。如果它们没有被指定为CMake变量或者cache记录,可以指定这些变量为环境变量。

该模块首先用上面的提示变量(不包括BOOST_LIBRARYDIR)搜索Boost头文件,且存储结果于Boost_INCLUDE_DIR。然后,用上面的提示(不包括BOOST_INCLUDEDIRand Boost_ADDITIONAL_VERSIONS)搜索组建库,在Boost_INCLUDE_DIR附近的”lib”目录,库名配置设置如下。它保存库路径在Boost_LIBRARY_DIR_DEBUG和Boost_LIBRARY_DIR_RELEASE中,在Boost_<C>_LIBRARY_DEBUG和Boost_<C>_LIBRARY_RELEASE中单独的库位置。当在相同的构建树(不包括环境变量)中,对以前的搜索使用的设置进行改变时,该模块会弃用受以前的改变所影响的搜索结果,且再进行搜索。

Boost库开始使用用它们的文件名编码的变种。用户或者项目工程能区分这些模块,通过设置变量来寻找何种变种。:

Boost_USE_MULTITHREADED             - Set to OFF to use the non-multithreaded libraries ('mt' tag). Default is ON.
Boost_USE_STATIC_LIBS               - Set to ON to force the use of the static libraries. Default is OFF.
Boost_USE_STATIC_RUNTIME            - Set to ON or OFF to specify whether to use libraries linked statically to the C++ runtime ('s'tag). Default is platform dependent.
Boost_USE_DEBUG_RUNTIME             - Set to ON or OFF to specify whether to use libraries linked to the MS debug C++ runtime('g'tag). Default is ON.
Boost_USE_DEBUG_PYTHON              - Set to ON to use libraries compiled with a debug Python build ('y' tag). Default is OFF.
Boost_USE_STLPORT                   - Set to ON to use libraries compiled with STLPort('p' tag). Default is OFF.
Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS   -Set to ON to use libraries compiled with STLPort deprecated "native iostreams"('n'tag). Default is OFF.
Boost_COMPILER                      - Set to the compiler-specific library suffix(e.g."-gcc43"). Default is auto-computed for the C++ compiler in use.
Boost_THREADAPI                     - Suffix for "thread" component library name,such as "pthread" or "win32". Names with and without this suffix will both be tried.
Boost_NAMESPACE                     - Alternate namespace used to build boost with e.g.if set to "myboost", will search for myboost_thread instead of boost_thread.

能设置来控制该模块的的别的一些变量是:

Boost_DEBUG                  - Set to ON to enable debug output from FindBoost. Please enable this before filing any bug report.
Boost_DETAILED_FAILURE_MSG   -Set to ON to add detailed information to the failure message even when the REQUIRED option is not given to the find_package call.
Boost_REALPATH               - Set to ON to resolve symlinks for discovered libraries to assist with packaging. For example,the "system" component library may be resolved to   "/usr/lib/libboost_system.so.1.42.0" instead of "/usr/lib/libboost_system.so". This does not affect linking and should not be enabled unless the user                                 needs this information.
Boost_LIBRARY_DIR             - Default value for Boost_LIBRARY_DIR_RELEASE and Boost_LIBRARY_DIR_DEBUG.

对于VisualStudio和Borland编译器,Boostheaders要求自动链接到相应的库。这要求匹配的库在链接库搜索路径中时能隐式链接或者有效。在这种情形中,设置Boost_USE_STATIC_LIBS为OFF可能不会取得动态链接。典型的Boost自动链接要求静态库,有些例外(诸如Boost.Python).

使用:

add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})

来要求Boost去报告关于自动链接请求的信息。

仅仅查找Boostheaders的例子:

find_package(Boost 1.36.0)
if(Boost_FOUND)     include_directories(${Boost_INCLUDE_DIRS})     add_executable(foo foo.cc)
endif()

寻找Boostheaders和一些静态库的例子:

set(Boost_USE_STATIC_LIBS  ON)         # only find static libs
set(Boost_USE_MULTITHREADED  ON)
set(Boost_USE_STATIC_RUNTIME  OFF)
find_package(Boost 1.36.0 COMPONENTS date_time filesystem system ...)
if(Boost_FOUND)     include_directories(${Boost_INCLUDE_DIRS})     add_executable(foo foo.cc)     target_link_libraries(foo ${Boost_LIBRARIES})
endif()

BoostCMake

如果Boost使用boost-cmake项目工程来构建,它用一个find_package的配置模式为使用提供一个包配置文件。这个模块寻找称之为BoostConfig.cmakeor boost-config.cmake的包配置文件,且在cache记录“Boost_DIR”中存储结果。如果找到,加载包配置文件,这个模块没有返回进一步的动作。要详细了解,请见BoostCMake包配置的文档。

置Boost_NO_BOOST_CMAKE为ON将禁止对boost-cmake的搜索。

FindBoost 查找Boost的inlude目录和库相关推荐

  1. python调用c++动态库 linux_linux中使用boost.python调用c++动态库的方法

    前言 最近开始使用 robot framework 测试c++的动态库,robot framework 是跑在 windows 上面,c++动态库是跑在远程linux主机上面.测试办法是让 robot ...

  2. 包含目录、库目录、附加包含目录、附加库目录、附加依赖项如何使用? 及静态库,动态库的创建与调用和vs里引用的使用

    引言:vs中怎么添加外部头文件? 如过直接在项目头文件处,添加一下,如下图: 否则,依然会报错,如下图: 有两种方法,来解决(你不在vs上的添加它也没事): (1) 直接把外部头文件复制过来,放在此项 ...

  3. PCL 1.8.1 在VS2015中配置 包含目录、库目录和附加依赖项

    PCL 1.8.1 在VS2015中配置 包含目录.库目录和附加依赖项 1. 包含目录 2. 库目录 3. 附加依赖项 如果想要永久配置,需要在属性管理器中进行. 1. 包含目录 C:\Program ...

  4. 记boost在gcc的一个库链接问题generic_category()

    报错大致如下: main.cpp:(.text+0x49): undefined reference to `boost::system::generic_category()' main.cpp:( ...

  5. 包含目录、库目录、附加包含目录、附加库目录、附加依赖项之详解

    VS项目中的包含目录.库目录.附加包含目录.附加库目录.附加依赖项均在"项目->属性->配置属性"下进行配置,具体说明如下: VC++目录: 包含目录:寻找#inclu ...

  6. Visual Studio 2013或2015工程属性中包含目录和库目录的添加方法,附加依赖项,相对路径

    参考文章:包含目录.库目录.附加包含目录.附加库目录.附加依赖项之详解 https://blog.csdn.net/u012043391/article/details/54972127 参考文章:V ...

  7. boost:验证Boost概念检查的class_requires 库应该在预期的时间内捕获错误

    boost:验证Boost概念检查的class_requires 库应该在预期的时间内捕获错误 实现功能 C++实现代码 实现功能 boost:验证Boost概念检查的class_requires 库 ...

  8. C++ 包含目录、库目录、附加依赖项详解

    在使用opencv库,以及其他库的时候,经常会需要添加包含目录.库目录.附加依赖项等.现做一个总结吧. 1.包含目录 是.h的头文件所在的目录,如果没有正确包含目录,代码中会出现红色的警告,各种未定义 ...

  9. C++ 包含目录、库目录、附加依赖项总结

    在使用opencv库,以及其他库的时候,经常会需要添加包含目录.库目录.附加依赖项等.现做一个总结吧. 1.包含目录 是.h的头文件所在的目录,如果没有正确包含目录,代码中会出现红色的警告,各种未定义 ...

  10. VS的包含目录、库目录、引用目录、可执行目录解释

    来源:包含目录.库目录.附加包含目录.附加库目录.附加依赖项之详解 学习备份 VS项目中的包含目录.库目录.附加包含目录.附加库目录.附加依赖项均在"项目->属性->配置属性&q ...

最新文章

  1. logistic回归 如何_第七章:利用Python实现Logistic回归分类模型
  2. ios(iphone/ipad)一个简单的用代码判断当前设备的方法
  3. python面试常见问题-Python面试中常见的40个问题
  4. poweramp最完美设置_2020年感恩节,你最想感谢的人是谁?
  5. SAP Spartacus基于travis的持续集成
  6. (CCPC 2020 网络选拔赛)HDU 6900 Residual Polynomial(分治 + NTT)
  7. BurpSuite插件 -- Struts2-RCE
  8. GPRS底层API(转)
  9. 串口读写flash_老司机带路:LPC82x 存储器及读写保护 手到擒来!
  10. jvisualvm (Java VisualVM)
  11. python+iOS自动化环境搭建
  12. RPGViewer - 游戏常用压缩算法的介绍和识别
  13. 安信可——PB-03F烧录
  14. SSM公司企业绩效考核管理系统
  15. ETL——实现Kettle作业定时任务
  16. hr面试性格测试30题_辉瑞面试过程辉瑞性格测试题
  17. 微信点餐小程序开发_分享微信点餐小程序可以实现哪些功能
  18. 23种设计模式彩图-设计模式之禅
  19. STM32从固件库到HAL库
  20. COMSOL和Matlab联合仿真之复合材料填充建模

热门文章

  1. 计算机专业外语的特点,计算机专业英语在邮政信息技术领域的应用特点|计算机专业哪个好...
  2. 设备密码的设置以及遗忘重设置
  3. 动态路由之RIP协议、Bellman-Ford算法
  4. centos新装系统后安装软件整理
  5. 滴滴披露语音识别新进展:基于Attention显著提升中文识别率
  6. accumulate
  7. 一大波干货学习资源分享
  8. --initialize specified but the data directory has files in it. Aborting.
  9. 读书笔记:陈希孺:概率论与数理统计:2014.01.01
  10. (转)Android 如何建立你的菜单