linux - 尽管使用了 BOOST_ROOT,但无法找到我的本地 Boost 发行版而不是已安装的发行版

标签 linux boost cmake

我有一个关于 FindBoost 的问题。我正在尝试从我自己的 boost 1.49 发行版中选择 boost 组件,该发行版位于已预装默认 boost 1.47 的 HPC (redhat) 上。 我想专门使用我的,并且我一直在尝试使用 BOOST_ROOT 作为缓存变量、内部缓存变量和使用 set(ENV{BOOST_ROOT} ) 的环境变量,但没有任何效果:我可以看到 BOOST_ROOT设置正确(指向1.49.0版本),但似乎对FindBoost生成的库路径没有影响:它们都指向1.47.0版本中的库。 我正在尝试这个:

# I give a chance to the user to set BOOST_PATH to the local boost distribution before calling FindBoost
if( NOT DEFINED BOOST_PATH)
    message(STATUS " Set BOOST_PATH to a specific Boost distribution if needed.")
    set(BOOST_PATH "Default" CACHE PATH "Set the path to a specific Boost distribution if not default.")

# On the second pass, I use BOOST_PATH to initialize BOOST_ROOT, hoping that FindBoost will use it to find my local version.
else(   NOT DEFINED BOOST_PATH)
    if( NOT (BOOST_PATH MATCHES "Default"))
        set(BOOST_ROOT ${BOOST_PATH} CACHE PATH "path to the preferred boost distribution.")
    endif(NOT (BOOST_PATH MATCHES "Default"))

    # I test to make sure the path in   BOOST_ROOT is what I expect: it is on the console, as well as in the cache
    message("BOOST_ROOT = ${BOOST_ROOT}")

    set(Boost_USE_MULTITHREADED      ON)
    set(Boost_USE_STATIC_LIBS        ON)
    set(Boost_ADDITIONAL_VERSIONS    "1.42" "1.42.0" 
                             "1.43" "1.43.0" 
                             "1.44" "1.44.0" 
                             "1.45" "1.45.0" 
                             "1.46" "1.46.0" "1.46.1"
                             "1.47" "1.47.0"
                             "1.48" "1.48.0"
                             "1.49" "1.49.0"
                             ${BOOST_ADDITIONAL_VERSION}
    )
    set(Boost_DEBUG                  TRUE) # Debugging info output for FindBoost
    set(Boost_DETAILED_FAILURE_MSG   TRUE) # Set to FALSE by default


    # I invoke FindBoost here, but although BOOST_ROOT points to my local boost, all the paths of the 3 components points to the installed debug/release variants, not to my local distribution.  
    find_package( Boost COMPONENTS date_time filesystem system program_options )

# unimportant code
[...]

endif(  NOT DEFINED BOOST_PATH)

如果您能帮助我,我将不胜感激。预先非常感谢您。

尼古拉斯

最佳答案

在较新版本的 FindBoost.cmake (CMake 2.8.x) 中,有一个变量可以设置为影响脚本查找 Boost 的搜索路径。

它被称为Boost_NO_SYSTEM_PATHS,如果它设置为TRUE,则不会查看安装在系统位置的库。

我必须在我的一些项目中执行此操作,因为两个 Boost 安装的库被 find_package() 脚本混淆了。

关于linux - 尽管使用了 BOOST_ROOT,但无法找到我的本地 Boost 发行版而不是已安装的发行版,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9713629/

相关文章:

linux - Golang交叉编译: gccgo - unrecognized command line option `-marm`

linux - 如何从 shell 设置管道尺寸?

Linux上的java进程

c++ - 连续调用 boost::asio::read_async: 没有数据的回调

c++ - 构建支持 GPU/CUDA 的 PCL 库

c++ - 使用 cmake 错误链接 boost 日志

当我通过 USB 集线器连接串行设备时,Linux 进程进入 D 状态

c++ - boost program_options 生成一个 Klocwork MLK.MUST

c++ - 应用程序的一个实例,平台无关,C++11

android-studio - Android Studio (build.gradle) - 错误 : starting process 'command ' . .\bin\cmake.exe''