Skip to content

Commit

Permalink
Merge pull request #404 from Ryanf55/bugfix-403-cmake
Browse files Browse the repository at this point in the history
grid_map_core: Use ament_export_targets and improve eigen linkage
  • Loading branch information
Ryanf55 authored Feb 5, 2024
2 parents 46e4511 + 89ead03 commit 274d7c4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
36 changes: 15 additions & 21 deletions grid_map_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##
###########
Expand All @@ -49,21 +35,31 @@ add_library(${PROJECT_NAME}
src/iterators/SlidingWindowIterator.cpp
)

## Specify additional locations of header files
target_include_directories(${PROJECT_NAME}
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)

target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen)

#############
## Install ##
#############

# 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"
)
Expand Down Expand Up @@ -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
)
11 changes: 8 additions & 3 deletions grid_map_cv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ find_package(sensor_msgs REQUIRED)

find_package(OpenCV REQUIRED
COMPONENTS
opencv_photo
photo
)

grid_map_package()
Expand Down Expand Up @@ -43,8 +43,13 @@ add_library(${PROJECT_NAME} SHARED
src/InpaintFilter.cpp
)

ament_target_dependencies(${PROJECT_NAME} SYSTEM
${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}
)

#############
Expand Down

0 comments on commit 274d7c4

Please sign in to comment.