无法使用柯南在cmake中找到请求的Boost库

时间:2019-11-24 13:44:42

标签: c++ boost cmake conan

我在使用Unix系统(Ubuntu)中的柯南依赖项的c ++中的boost库使用cmake进行编译时遇到问题

sfml库已经实现并且可以在项目中使用,但是boost库不起作用,并且显示以下消息:

['english', 'french']

这是我的conanfile.txt

v-for

这是我的CMakeLists.txt

CMake Error at /usr/share/cmake-3.13/Modules/FindBoost.cmake:2100 (message):
  Unable to find the requested Boost libraries.

  Unable to find the Boost header files.  Please set BOOST_ROOT to the root
  directory containing Boost or BOOST_INCLUDEDIR to the directory containing
  Boost's headers.
Call Stack (most recent call first):
  CMakeLists.txt:13 (find_package)

我尝试了很多解决方案,但是没有人在工作。欢迎所有解决方案或技巧,谢谢!

1 个答案:

答案 0 :(得分:1)

我认为您忘记在您的CMakeLists.txt中添加conan_basic_setup()

查看# Setting the project

# Minimum version of cmake
cmake_minimum_required(VERSION 3.10)

# Setting the project
project(CPP_rtype_2019 CXX)
include(build/conanbuildinfo.cmake)
conan_basic_setup()

# Dependencies Sfml
find_package(SFML 2.5.1 EXACT REQUIRED COMPONENTS system window graphics audio)
find_package(Threads REQUIRED)

# Dependencies Boost
find_package(Boost 1.69.0 EXACT REQUIRED COMPONENTS thread system filesystem)
include_directories(${Boost_INCLUDE_DIRS})

# Set the C++11 standard
set(CMAKE_CXX_STANDARD 11)

# Added all .hpp
include_directories(client/include)
include_directories(server/include)

# Added all .cpp
add_executable(r-type_client client/src/Actor.cpp client/src/Character.cpp client/src/Ennemy.cpp client/src/Interface.cpp client/src/Pown.cpp client/src/Projectile.cpp)
add_executable(r-type_server server/src/GameEngine.cpp)

# Added dependencies to compilation
target_link_libraries(r-type_client PRIVATE sfml-audio sfml-system sfml-graphics)
target_link_libraries(r-type_server PRIVATE Boost::thread Boost::system Boost::filesystem)