0

I am using the following cmake file

cmake_minimum_required(VERSION 3.16)
project(Translated01)

find_package(Boost REQUIRED)
find_package(OpenSSL REQUIRED)

set(CMAKE_CXX_STANDARD 14)

add_executable(Translated01 main.cpp)

During CMake configure phase it writes

...
[cmake] -- Check for working CXX compiler: /usr/bin/g++-7 - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Found Boost: /opt/boost (found version "1.73.0")  
[cmake] -- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.1.1")  
[cmake] -- Configuring done
[cmake] -- Generating done

Which proves it is finding boost in /opt/boost.

Unfortunately, during compile it says it can't find include file

[build] ../main.cpp:3:10: fatal error: boost/beast.hpp: No such file or directory
[build]  #include <boost/beast.hpp>
[build]           ^~~~~~~~~~~~~~~~~
[build] compilation terminated.

Although, file is there

$ ls /opt/boost/boost/beast.hpp
/opt/boost/boost/beast.hpp

So, how to configure boost for CMake correctly?

Dims
  • 47,675
  • 117
  • 331
  • 600
  • 4
    find_package(Boost) does nothing except setting variables Boost_*. You should use these libraries to add target include directories. – 273K Nov 27 '20 at 18:00
  • 1
    find_package(Boost) also defines an imported target `Boost::headers` that can be used later in a target_link_libraries command, e.g. `target_link_libraries(Translated01 PUBLIC Boost::headers)`. You may probably need to adapt the scope from `PUBLIC` to `PRIVATE` or `INTERFACE`. – vre Nov 27 '20 at 21:58

0 Answers0