From 4f32682271add9477a4566596c1997053d59f345 Mon Sep 17 00:00:00 2001 From: Ryan Friedman Date: Sat, 21 Oct 2023 19:36:31 -0500 Subject: [PATCH 1/2] Update ament to latest recommendations * Fixes include errors in grid_map_geo ros2 port Signed-off-by: Ryan Friedman --- grid_map_core/CMakeLists.txt | 36 +++++++++++++++--------------------- grid_map_cv/CMakeLists.txt | 6 +++++- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/grid_map_core/CMakeLists.txt b/grid_map_core/CMakeLists.txt index 3fac843ad..cbf8ff5da 100644 --- a/grid_map_core/CMakeLists.txt +++ b/grid_map_core/CMakeLists.txt @@ -9,24 +9,10 @@ find_package(grid_map_cmake_helpers REQUIRED) include(cmake/${PROJECT_NAME}-extras.cmake) ## System dependencies are found with CMake's conventions -#find_package(Eigen3 REQUIRED) -# Solution to find Eigen3 with Saucy. -find_package(Eigen3 QUIET) -if(NOT EIGEN3_FOUND) -find_package(PkgConfig REQUIRED) -pkg_check_modules(EIGEN3 REQUIRED eigen3) -set(EIGEN3_INCLUDE_DIR ${EIGEN3_INCLUDE_DIRS}) -endif() +find_package(Eigen3 REQUIRED) grid_map_package() -## Specify additional locations of header files -include_directories( - include - SYSTEM - ${EIGEN3_INCLUDE_DIR} -) - ########### ## Build ## ########### @@ -49,6 +35,15 @@ add_library(${PROJECT_NAME} src/iterators/SlidingWindowIterator.cpp ) +## Specify additional locations of header files +target_include_directories(${PROJECT_NAME} + PUBLIC + "$" + "$" +) + +target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen) + ############# ## Install ## ############# @@ -56,14 +51,15 @@ add_library(${PROJECT_NAME} # Mark executables and/or libraries for installation install( TARGETS ${PROJECT_NAME} - ARCHIVE DESTINATION lib + EXPORT export_${PROJECT_NAME} LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib RUNTIME DESTINATION lib/${PROJECT_NAME} ) # Mark cpp header files for installation install( - DIRECTORY include/${PROJECT_NAME}/ + DIRECTORY include/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING PATTERN "*.hpp" ) @@ -129,10 +125,8 @@ if(TARGET ${PROJECT_NAME}-test) target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) endif() -ament_export_include_directories(include ${EIGEN3_INCLUDE_DIR}) -ament_export_libraries( - ${PROJECT_NAME} -) +ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET) +ament_export_dependencies(Eigen3) ament_package(CONFIG_EXTRAS cmake/${PROJECT_NAME}-extras.cmake ) diff --git a/grid_map_cv/CMakeLists.txt b/grid_map_cv/CMakeLists.txt index 3dc6f78aa..2bb61c092 100644 --- a/grid_map_cv/CMakeLists.txt +++ b/grid_map_cv/CMakeLists.txt @@ -43,10 +43,14 @@ add_library(${PROJECT_NAME} SHARED src/InpaintFilter.cpp ) -ament_target_dependencies(${PROJECT_NAME} SYSTEM +ament_target_dependencies(${PROJECT_NAME} PUBLIC ${dependencies} ) +target_link_libraries(${PROJECT_NAME} PUBLIC + grid_map_core::grid_map_core +) + ############# ## Install ## ############# From 89ead0384524c728d86e17e227cb0d1ad470ea6e Mon Sep 17 00:00:00 2001 From: wep21 Date: Sun, 4 Feb 2024 22:33:17 +0900 Subject: [PATCH 2/2] fix: use target link libraries instead of ament target deps Signed-off-by: wep21 --- grid_map_cv/CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/grid_map_cv/CMakeLists.txt b/grid_map_cv/CMakeLists.txt index 2bb61c092..644b73896 100644 --- a/grid_map_cv/CMakeLists.txt +++ b/grid_map_cv/CMakeLists.txt @@ -13,7 +13,7 @@ find_package(sensor_msgs REQUIRED) find_package(OpenCV REQUIRED COMPONENTS - opencv_photo + photo ) grid_map_package() @@ -43,12 +43,13 @@ add_library(${PROJECT_NAME} SHARED src/InpaintFilter.cpp ) -ament_target_dependencies(${PROJECT_NAME} PUBLIC - ${dependencies} -) - target_link_libraries(${PROJECT_NAME} PUBLIC + cv_bridge::cv_bridge grid_map_core::grid_map_core + opencv_photo + pluginlib::pluginlib + rclcpp::rclcpp + ${sensor_msgs_TARGETS} ) #############