Cannot find Boost dependency for ament_cmake
I have been trying to build a ROS2 package that depends on Boost. Unfortunately, it looks like CMake is unable to find the Boost libraries. The error log is -
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find Boost (missing: Boost_INCLUDE_DIR system)
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.16/Modules/FindBoost.cmake:2179 (find_package_handle_standard_args)
CMakeLists.txt:17 (find_package)
make: *** [Makefile:266: cmake_check_build_system] Error 1
The relevant CMakeLists.txt content is -
find_package(Boost REQUIRED COMPONENTS system)
target_include_directories(local_diagnostic include ${Boost_INCLUDE_DIRS})
target_link_libraries(local_diagnostic ${Boost_LIBRARIES})
add_executable( local_diagnostic src/local_diagnostic.cpp)
ament_export_dependencies(Boost)
Did you install Boost with with
-dev
suffix? Since it is missingBoost_INCLUDE_DIR
runningsudo apt install libboost-all-dev
may fix the problem.