Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Install includes to include/${PROJECT_NAME} and use modern CMake (ros…
Browse files Browse the repository at this point in the history
…#493)

* Install includes to include/${PROJECT_NAME} and use modern CMake

Signed-off-by: Shane Loretz <[email protected]>

* Remove dependency on eigen3_cmake_module

Signed-off-by: Shane Loretz <[email protected]>

* Undo whitespace change

Signed-off-by: Shane Loretz <[email protected]>

* Remove extra newline

Signed-off-by: Shane Loretz <[email protected]>

* Remove duplicate add_library call

* Keep making old style CMake variables

Signed-off-by: Shane Loretz <[email protected]>

* Update test dependencies

Signed-off-by: Shane Loretz <[email protected]>

* Alphabetize

Signed-off-by: Shane Loretz <[email protected]>

* Include dirs and libs for static_transform_broadcaster_node

Signed-off-by: Shane Loretz <[email protected]>

* Use Eigen3::Eigen when available, else Eigen3_INCLUDE_DIRS

Signed-off-by: Shane Loretz <[email protected]>

* target_include_directories(... PRIVATE

Signed-off-by: Shane Loretz <[email protected]>

* Fix indentation

Signed-off-by: Shane Loretz <[email protected]>
  • Loading branch information
sloretz authored Apr 1, 2022
1 parent 8c77449 commit 0163c86
Show file tree
Hide file tree
Showing 13 changed files with 244 additions and 203 deletions.
109 changes: 52 additions & 57 deletions test_tf2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ endif()

find_package(ament_cmake_gtest REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(eigen3_cmake_module REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(launch_testing_ament_cmake REQUIRED)
Expand All @@ -36,92 +35,88 @@ ament_find_gtest()

ament_add_gtest(buffer_core_test test/buffer_core_test.cpp)
if(TARGET buffer_core_test)
ament_target_dependencies(buffer_core_test
builtin_interfaces
geometry_msgs
rclcpp
tf2
tf2_geometry_msgs
tf2_ros
)
target_link_libraries(buffer_core_test
${builtin_interfaces_TARGETS}
${geometry_msgs_TARGETS}
rclcpp::rclcpp
tf2::tf2
${tf2_geometry_msgs_TARGETS}
tf2_ros::tf2_ros)
endif()

ament_add_gtest(test_message_filter test/test_message_filter.cpp)
if(TARGET test_message_filter)
ament_target_dependencies(test_message_filter
builtin_interfaces
geometry_msgs
rclcpp
tf2
tf2_ros
)
target_link_libraries(test_message_filter
${builtin_interfaces_TARGETS}
${geometry_msgs_TARGETS}
rclcpp::rclcpp
tf2::tf2
tf2_ros::tf2_ros)
endif()

ament_add_gtest(test_convert test/test_convert.cpp)
if(TARGET test_convert)
ament_target_dependencies(test_convert
Eigen3
eigen3_cmake_module
tf2
tf2_bullet
tf2_eigen
tf2_geometry_msgs
tf2_kdl
)
target_link_libraries(test_convert
${geometry_msgs_TARGETS}
tf2::tf2
tf2_bullet::tf2_bullet
tf2_eigen::tf2_eigen
${tf2_geometry_msgs_TARGETS}
tf2_kdl::tf2_kdl)
if(TARGET Eigen3::Eigen)
# TODO(sloretz) require target to exist when https://github.com/ros2/choco-packages/issues/19 is addressed
target_link_libraries(test_convert Eigen3::Eigen)
else()
target_include_directories(test_convert PRIVATE ${Eigen3_INCLUDE_DIRS})
endif()
endif()

ament_add_gtest(test_utils test/test_utils.cpp)
if(TARGET test_utils)
ament_target_dependencies(test_utils
geometry_msgs
tf2
tf2_geometry_msgs
tf2_kdl
)
target_link_libraries(test_utils
${geometry_msgs_TARGETS}
tf2::tf2
${tf2_geometry_msgs_TARGETS}
tf2_kdl::tf2_kdl)
endif()

add_executable(test_buffer_server test/test_buffer_server.cpp)
if(TARGET test_buffer_server)
ament_target_dependencies(test_buffer_server
rclcpp
tf2_bullet
tf2_ros
)
target_link_libraries(test_buffer_server
rclcpp::rclcpp
tf2_ros::tf2_ros)
endif()

add_executable(test_buffer_client test/test_buffer_client.cpp)
if(TARGET test_buffer_client)
ament_target_dependencies(test_buffer_client
rclcpp
tf2_bullet
tf2_geometry_msgs
tf2_kdl
tf2_ros
)
target_link_libraries(test_buffer_client ${GTEST_LIBRARIES})
target_link_libraries(test_buffer_client
${GTEST_LIBRARIES}
rclcpp::rclcpp
tf2_bullet::tf2_bullet
${tf2_geometry_msgs_TARGETS}
tf2_kdl::tf2_kdl
tf2_ros::tf2_ros)
add_launch_test(test/buffer_client_tester.launch.py)
endif()

add_executable(test_static_publisher test/test_static_publisher.cpp)
if(TARGET test_static_publisher)
ament_target_dependencies(test_static_publisher
geometry_msgs
rclcpp
tf2
tf2_ros
)
target_include_directories(test_static_publisher PRIVATE ${GTEST_INCLUDE_DIRS})
target_link_libraries(test_static_publisher ${GTEST_LIBRARIES})
target_link_libraries(test_static_publisher
${GTEST_LIBRARIES}
${geometry_msgs_TARGETS}
rclcpp::rclcpp
tf2::tf2
tf2_ros::tf2_ros)
add_launch_test(test/static_publisher.launch.py)
endif()

ament_add_gtest(test_tf2_bullet test/test_tf2_bullet.cpp)
if(TARGET test_tf2_bullet)
ament_target_dependencies(test_tf2_bullet
rclcpp
tf2_bullet
tf2_ros
)
target_link_libraries(test_tf2_bullet
rclcpp::rclcpp
tf2_bullet::tf2_bullet
tf2_ros::tf2_ros
tf2::tf2)
endif()

# TODO(ahcorde): enable once python part of tf2_geometry_msgs is working
Expand Down
1 change: 0 additions & 1 deletion test_tf2/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<author>Eitan Marder-Eppstein</author>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>eigen3_cmake_module</buildtool_depend>

<build_depend>eigen</build_depend>

Expand Down
38 changes: 23 additions & 15 deletions tf2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ endif()
find_package(ament_cmake)
find_package(console_bridge_vendor REQUIRED) # Provides console_bridge 0.4.0 on platforms without it.
find_package(console_bridge REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(rcutils REQUIRED)
find_package(rosidl_runtime_cpp REQUIRED)
Expand All @@ -23,25 +24,25 @@ find_package(rosidl_runtime_cpp REQUIRED)
add_library(tf2 SHARED src/cache.cpp src/buffer_core.cpp src/static_cache.cpp src/time.cpp)
target_include_directories(tf2 PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
ament_target_dependencies(tf2
"console_bridge"
"geometry_msgs"
"rcutils"
)
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
target_link_libraries(tf2 PUBLIC
${geometry_msgs_TARGETS})
target_link_libraries(tf2 PRIVATE
${builtin_interfaces_TARGETS}
console_bridge::console_bridge
rcutils::rcutils)

# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(tf2 PRIVATE "TF2_BUILDING_DLL")

install(TARGETS tf2 EXPORT tf2
install(TARGETS tf2 EXPORT export_tf2
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

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

# Tests
if(BUILD_TESTING)
Expand Down Expand Up @@ -91,9 +92,11 @@ if(BUILD_TESTING)

ament_add_gtest(test_simple_tf2_core test/simple_tf2_core.cpp)
if(TARGET test_simple_tf2_core)
target_link_libraries(test_simple_tf2_core tf2)
ament_target_dependencies(test_simple_tf2_core
"geometry_msgs"
target_link_libraries(test_simple_tf2_core
${builtin_interfaces_TARGETS}
tf2
# Used, but not linked to test tf2's exports:
# ${geometry_msgs_TARGETS}
)
endif()

Expand All @@ -104,7 +107,12 @@ if(BUILD_TESTING)
endif()

ament_export_dependencies(console_bridge geometry_msgs rcutils rosidl_runtime_cpp)
ament_export_include_directories(include)

# Export old-style CMake variables
ament_export_include_directories("include/${PROJECT_NAME}")
ament_export_libraries(tf2)
ament_export_targets(tf2)

# Export modern CMake targets
ament_export_targets(export_tf2)

ament_package()
1 change: 1 addition & 0 deletions tf2/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<build_depend>rosidl_runtime_cpp</build_depend>
<build_export_depend>rosidl_runtime_cpp</build_export_depend>

<depend>builtin_interfaces</depend>
<depend>console_bridge_vendor</depend>
<depend>geometry_msgs</depend>
<depend>libconsole-bridge-dev</depend>
Expand Down
6 changes: 2 additions & 4 deletions tf2_bullet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ include(bullet-extras.cmake)
add_library(tf2_bullet INTERFACE)
target_include_directories(tf2_bullet INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
target_link_libraries(tf2_bullet INTERFACE
tf2_bullet::Bullet
tf2::tf2
Expand All @@ -30,9 +30,7 @@ target_link_libraries(tf2_bullet INTERFACE

install(TARGETS tf2_bullet EXPORT export_tf2_bullet)

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

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
Expand Down
44 changes: 32 additions & 12 deletions tf2_eigen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,25 @@ find_package(geometry_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)

find_package(eigen3_cmake_module REQUIRED)
find_package(Eigen3 REQUIRED)

install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION include/${PROJECT_NAME})
add_library(tf2_eigen INTERFACE)
target_link_libraries(tf2_eigen INTERFACE
${geometry_msgs_TARGETS}
tf2::tf2
tf2_ros::tf2_ros)
target_include_directories(tf2_eigen INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
if(TARGET Eigen3::Eigen)
# TODO(sloretz) require target to exist when https://github.com/ros2/choco-packages/issues/19 is addressed
target_link_libraries(tf2_eigen INTERFACE Eigen3::Eigen)
else()
target_include_directories(tf2_eigen INTERFACE ${Eigen3_INCLUDE_DIRS})
endif()

install(TARGETS tf2_eigen EXPORT export_tf2_eigen)
install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME})

if(BUILD_TESTING)
find_package(ament_cmake_cppcheck REQUIRED)
Expand All @@ -35,20 +49,26 @@ if(BUILD_TESTING)

ament_add_gtest(tf2_eigen-test test/tf2_eigen-test.cpp)
if(TARGET tf2_eigen-test)
target_include_directories(tf2_eigen-test PUBLIC
include)
ament_target_dependencies(tf2_eigen-test
"tf2"
"tf2_ros")
target_include_directories(tf2_eigen-test PUBLIC
${Eigen3_INCLUDE_DIRS})
target_link_libraries(tf2_eigen-test
tf2_eigen
# Used, but not linked to test tf2_eigen's exports:
# Eigen3::Eigen
# ${geometry_msgs_TARGETS}
# tf2::tf2
# tf2_ros::tf2_ros
)
endif()
endif()

ament_export_include_directories(include)
ament_export_dependencies(
eigen3_cmake_module
Eigen3
tf2
tf2_ros)

# Export old-style CMake variables
ament_export_include_directories("include/${PROJECT_NAME}")

# Export modern CMake targets
ament_export_targets(export_tf2_eigen)

ament_package()
3 changes: 0 additions & 3 deletions tf2_eigen/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
<author>Koji Terada</author>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>eigen3_cmake_module</buildtool_depend>

<buildtool_export_depend>eigen3_cmake_module</buildtool_export_depend>

<build_depend>eigen</build_depend>

Expand Down
Loading

0 comments on commit 0163c86

Please sign in to comment.