Reputation: 1223
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.
Upvotes: 3
Views: 2369
Reputation: 1568
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
Upvotes: 0
Reputation: 914
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
Upvotes: 1