find_package()不能在Windows CMake的检测提振 [英] find_package() doesn't detect boost on Windows Cmake

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

问题描述

我使用的是Windows系统。我想用CMake的使用Boost库。
我已经在安装到C升压:\\ boost_1_55_0 \\
这是我的CMakeLists.txt文件

 集(Boost_USE_STATIC_LIBS ON)
集(Boost_USE_MULTITHREADED ON)
集(Boost_USE_STATIC_RUNTIME OFF)
find_package(升压1.55.0组件螺纹)如果(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)
其他()
    消息(STATUS故障asdasd!)
万一()

我越来越不--Could升压找到
输出:

  $ cmake的../
- 找不到升压
- 故障asdasd!
- 配置完成
- 生成完成
- 建立文件已被写入:D:/ ubuntu_share /编程/ C ++ /实习/厘米
AKE / linking_with_boost / build_win


解决方案

您需要将环境变量 BOOST_ROOT 设置为 C:\\ boost_1_55_0 运行前 cmake的。另外,也要看看 cmake的--help模块FindBoost 以获得更多帮助。

I'm using a windows system. I want to use the Boost library using CMake. I've installed boost on C:\boost_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

解决方案

You need to set the environment variable BOOST_ROOT to c:\boost_1_55_0 before running cmake. Also look at cmake --help-module FindBoost for more help.

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

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