【发布时间】:2020-05-25 23:15:07
【问题描述】:
我正在使用 VisualStudio 2019 开发 C++ 代码。
我正在使用 CMake 来配置项目。
我需要使用在我的远程机器上编译的 boost 库。
在console application中,我可以将我在Additional Include Directories下进入项目的Properties时需要的包含文件的路径强>领域。 在Additional Include Directories下我可以放boost库的路径。
现在,当我右键单击我的项目以添加我需要的内容时,我找不到 属性。
我的boost包含目录在/home/ubuntu/boost_1_70_0
我的 boost 库目录在 /home/ubuntu/boost_1_70_0/stage
如何将它们添加到我的 CMake 项目中?
谢谢!
编辑:
这是我的 CMakelists.txt 文件:
# CMakeList.txt : CMake project for CMakeProject1, include source and define
# project specific logic here.
#
cmake_minimum_required (VERSION 3.8)
# Add source to this project's executable.
add_executable (CMakeProject1 "CMakeProject1.cpp" "CMakeProject1.h")
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.70.0 REQUIRED COMPONENTS lambda)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(CMakeProject1 CMakeProject1.cpp)
target_link_libraries(CMakeProject1 ${Boost_LIBRARIES})
endif()
# TODO: Add tests and install targets if needed.
这是我的 .cpp 文件:
#include "CMakeProject1.h"
#include <iostream>
#include <iterator>
#include <algorithm>
#include <boost/lambda/lambda.hpp>
using namespace std;
int main()
{
typedef std::istream_iterator<int> in;
std::cout << "Type in any number: ";
std::for_each(
in(std::cin), in(), std::cout
<< (boost::lambda::_1 * 10)
<< "\nType in another number: ");
}
我的boost目录的路径是:/home/ubuntu/boost_1_70_0
我的 boost 库的路径是:/home/ubuntu/boost_1_70_0/stage
当我运行 .cpp 文件时,会出现此 CMake 错误:
CMakeProject1/CMakeLists.txt:13 (find_package) 处的错误 CMake 错误: 找不到“Boost”提供的包配置文件 (要求的版本 1.70.0)具有以下任何名称:
BoostConfig.cmake boost-config.cmake将“Boost”的安装前缀添加到CMAKE_PREFIX_PATH或设置
“Boost_DIR”到包含上述文件之一的目录。如果 “Boost”提供了单独的开发包或SDK,请务必 已安装。
【问题讨论】:
-
你可能还想看看 microsoft/vcpkg
-
@squareskittles 请你看看我的问题编辑
-
@ChrisMM 是 boostconfig.cmake 和 boost-config.cmake 我在这里缺少什么?我必须下载它们吗?
标签: c++ visual-studio boost cmake path