我正在使用Visual Studio 2019开发C++代码。
我正在使用CMake来配置项目。
我需要使用在我的远程机器上编译的boost库。
在控制台应用程序中,当我进入项目的属性下的附加包含目录字段时,我可以放置我需要的包含文件的路径。并且在附加包含目录下,我可以放置boost库的路径。
现在,我右键单击我的项目后找不到属性选项来添加我需要的内容。
boost include directory在/home/ubuntu/boost_1_70_0下。
boost libraries directory在/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错误:
Error CMake Error at CMakeProject1/CMakeLists.txt:13 (find_package): Could not find a package configuration file provided by "Boost" (requested version 1.70.0) with any of the following names:
BoostConfig.cmake boost-config.cmake
Add the installation prefix of "Boost" to CMAKE_PREFIX_PATH or set
"Boost_DIR" to a directory containing one of the above files. If "Boost" provides a separate development package or SDK, be sure it has been installed.
INCLUDE_DIRECTORIES(path_to_include)
? - ChrisMM