Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install includes to ${PROJECT_NAME} folder and use modern CMake #58

Merged
merged 3 commits into from
Jan 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,38 @@ endif()
find_package(ament_cmake_ros REQUIRED)

find_package(image_geometry REQUIRED)
find_package(OpenCV REQUIRED)
find_package(OpenCV REQUIRED COMPONENTS core)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(sensor_msgs REQUIRED)

add_library(DepthImageToLaserScan
src/DepthImageToLaserScan.cpp
)
ament_target_dependencies(DepthImageToLaserScan
"image_geometry"
"OpenCV"
"sensor_msgs"
)
target_link_libraries(DepthImageToLaserScan PUBLIC
image_geometry::image_geometry
opencv_core
${sensor_msgs_TARGETS})

generate_export_header(DepthImageToLaserScan EXPORT_FILE_NAME ${PROJECT_NAME}/DepthImageToLaserScan_export.h)
target_include_directories(DepthImageToLaserScan PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)

add_library(DepthImageToLaserScanROS
src/DepthImageToLaserScanROS.cpp
)
ament_target_dependencies(DepthImageToLaserScanROS
"rclcpp"
"rclcpp_components"
)
target_link_libraries(DepthImageToLaserScanROS DepthImageToLaserScan)
target_link_libraries(DepthImageToLaserScanROS PUBLIC
rclcpp::rclcpp)
target_link_libraries(DepthImageToLaserScanROS PRIVATE
rcutils::rcutils
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this isn't of your doing, but DepthImageToLaserScanROS.cpp doesn't actually need to include rcutils, and hence doesn't need to directly link against it. So I'd be in favor of removing that unnecessary include, and removing this.

(rcutils also isn't properly exposed as a dependency in package.xml or CMakeLists.txt)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed traces of rcutils in 9926f09

rclcpp_components::component)

target_link_libraries(DepthImageToLaserScanROS PUBLIC
DepthImageToLaserScan)
generate_export_header(DepthImageToLaserScanROS EXPORT_FILE_NAME ${PROJECT_NAME}/DepthImageToLaserScanROS_export.h)
target_include_directories(DepthImageToLaserScanROS PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)

rclcpp_components_register_nodes(DepthImageToLaserScanROS
"depthimage_to_laserscan::DepthImageToLaserScanROS")
Expand All @@ -60,9 +58,7 @@ target_link_libraries(depthimage_to_laserscan_node
DepthImageToLaserScanROS
)

install(DIRECTORY include/
DESTINATION include
)
install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME})

install(DIRECTORY
launch
Expand All @@ -71,6 +67,7 @@ install(DIRECTORY
)

install(TARGETS DepthImageToLaserScan DepthImageToLaserScanROS
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
Expand All @@ -83,7 +80,7 @@ install(TARGETS depthimage_to_laserscan_node
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/DepthImageToLaserScan_export.h
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/DepthImageToLaserScanROS_export.h
DESTINATION include/${PROJECT_NAME})
DESTINATION include/${PROJECT_NAME}/${PROJECT_NAME})

if(BUILD_TESTING)
find_package(ament_cmake_gtest REQUIRED)
Expand All @@ -92,6 +89,9 @@ if(BUILD_TESTING)
target_link_libraries(${PROJECT_NAME}-test DepthImageToLaserScan)
endif()

ament_export_include_directories(include)
ament_export_libraries(DepthImageToLaserScan DepthImageToLaserScanROS)
ament_export_targets(export_${PROJECT_NAME})
ament_export_dependencies(rclcpp)
ament_export_dependencies(image_geometry)
ament_export_dependencies(OpenCV)
ament_export_dependencies(sensor_msgs)
ament_package()