3

Boost header files are on /usr/include/boost.

In CMakeLists.txt I include the folder with include_directories

include_directories(/usr/include /usr/include/boost/  
/usr/include/boost/smart_ptr)

However, cmake insists in not finding header files. The problem arises in intrusive_ptr.hpp, which includes #include <boost/smart_ptr/intrusive_ptr.hpp:

boost/smart_ptr/intrusive_ptr.hpp: No such file or directory
/usr/include/boost/intrusive_ptr.hpp

My guess is it does not like boost/smart_ptr/ prefix.

So, include_directories did not work.

CMake Error:

CMake Error at /usr/local/share/cmake-3.3/Modules/FindBoost.cmake:1245   
(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.

What should I do?

Thanks.

Mert Mertce
  • 1,049
  • 7
  • 34
  • It's not CMake that's not finding the headers, that's a compiler error... – rubenvb Aug 17 '15 at 15:18
  • Have you tried giving the BOOST_ROOT hint? Like `cmake -DBOOST_ROOT=/usr/include/`? If this does not work, which compiler are you using and how did you install Boost? – rettichschnidi Aug 18 '15 at 07:29

2 Answers2

1

While I do not know what failed in your case, I'd recommend to simply use find_package with the included FindBoost.cmake file:

find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})

Done

rettichschnidi
  • 904
  • 7
  • 23
0

I think you are using 3.3 cmake version, which support target_include_directories.

Even target_link_library should help here which gives the include path free if we link the library.

How do you add boost libraries in CMakeLists.txt

Community
  • 1
  • 1
Swapnil
  • 1,424
  • 2
  • 19
  • 30