find_package() 在 Windows Cmake 上没有检测到提升 [英] find_package() doesn't detect boost on Windows Cmake

查看:56
本文介绍了find_package() 在 Windows Cmake 上没有检测到提升的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Windows 系统.我想通过 CMake 使用 Boost 库.我已经在 C:oost_1_55_0 上安装了 boost这是我的 CMakeLists.txt 文件

set(Boost_USE_STATIC_LIBS ON)设置(Boost_USE_MULTITHREADED ON)设置(Boost_USE_STATIC_RUNTIME 关闭)find_package(Boost 1.55.0 COMPONENTS 线程)如果(Boost_FOUND)包含目录(${Boost_INCLUDE_DIRS})LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})add_executable (linking_with_boost main.cc sqr.cc)target_link_libraries(linking_with_boost ${Boost_LIBRARIES})别的()消息(状态失败 asdasd!")万一()

我得到 -- 找不到 Boost输出:

$ cmake ../-- 找不到 Boost-- 失败 asdasd!-- 配置完成-- 生成完成-- 构建文件已写入:D:/ubuntu_share/programming/C++/practice/cmake/linking_with_boost/build_win

解决方案

在 Windows 7 x64 上,我将 Boost 1.58 安装到 C:SDKsoost_1_58_0.为了让 cMake 找到所有合适的文件,我不得不添加以下三个系统变量:

<前>BOOST_INCLUDEDIR C:SDKsoost_1_58_0BOOST_LIBRARYDIR C:SDKsoost_1_58_0lib64-msvc-12.0BOOST_ROOT C:SDKsoost_1_58_0oost

I'm using a windows system. I want to use the Boost library using CMake. I've installed boost on C:oost_1_55_0 Here is my CMakeLists.txt file

set(Boost_USE_STATIC_LIBS        ON)
set(Boost_USE_MULTITHREADED      ON)
set(Boost_USE_STATIC_RUNTIME    OFF)
find_package(Boost 1.55.0 COMPONENTS thread)

if(Boost_FOUND)
    include_directories(${Boost_INCLUDE_DIRS}) 
    LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
    add_executable (linking_with_boost main.cc sqr.cc)
    target_link_libraries(linking_with_boost ${Boost_LIBRARIES})
else()
    message(STATUS "Fail  asdasd!")
endif()

I'm getting --Could NOT find Boost Output:

$ cmake ../
-- Could NOT find Boost
-- Fail  asdasd!
-- Configuring done
-- Generating done
-- Build files have been written to: D:/ubuntu_share/programming/C++/practice/cm
ake/linking_with_boost/build_win

解决方案

On Windows 7 x64 I have Boost 1.58 installed to C:SDKsoost_1_58_0. In order to allow cMake to find all of the appropriate files, I had to add the following three system variables:

    BOOST_INCLUDEDIR    C:SDKsoost_1_58_0
    BOOST_LIBRARYDIR    C:SDKsoost_1_58_0lib64-msvc-12.0
    BOOST_ROOT          C:SDKsoost_1_58_0oost

这篇关于find_package() 在 Windows Cmake 上没有检测到提升的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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