From 8dc341726dd6510433c0e0bc5cc6a02aa5852ff4 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Wed, 25 Jan 2023 14:39:06 -0700 Subject: [PATCH] Fix overriding of install Signed-off-by: Tyler Weaver --- kinematics_interface/CHANGELOG.rst | 1 - kinematics_interface/CMakeLists.txt | 57 ++++++++-------- kinematics_interface_kdl/CMakeLists.txt | 86 ++++++++++++------------- 3 files changed, 72 insertions(+), 72 deletions(-) diff --git a/kinematics_interface/CHANGELOG.rst b/kinematics_interface/CHANGELOG.rst index 76acc49..c28200c 100644 --- a/kinematics_interface/CHANGELOG.rst +++ b/kinematics_interface/CHANGELOG.rst @@ -23,4 +23,3 @@ Changelog for package kinematics_interface * updated README and cleaned up code * added KDL plugin for kinematics interface * Contributors: Paul Gesel, Andy Zelenak, Bence Magyar, Denis Štogl - diff --git a/kinematics_interface/CMakeLists.txt b/kinematics_interface/CMakeLists.txt index 5ecab38..2f41c4a 100644 --- a/kinematics_interface/CMakeLists.txt +++ b/kinematics_interface/CMakeLists.txt @@ -1,45 +1,48 @@ -cmake_minimum_required(VERSION 3.5) -project(kinematics_interface) +cmake_minimum_required(VERSION 3.16) +project(kinematics_interface LANGUAGES CXX) -if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 14) -endif() - -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") +if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)") add_compile_options(-Wall -Wextra -Wpedantic) endif() -set(THIS_PACKAGE_INCLUDE_DEPENDS - Eigen3 - rclcpp - rclcpp_lifecycle -) - -# find dependencies find_package(ament_cmake REQUIRED) -foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS}) - find_package(${Dependency} REQUIRED) -endforeach() +find_package(Eigen3 REQUIRED) +find_package(rclcpp REQUIRED) +find_package(rclcpp_lifecycle REQUIRED) # Create interface library for kinematics base class add_library(kinematics_interface INTERFACE) -target_include_directories(kinematics_interface INTERFACE include) -ament_target_dependencies(kinematics_interface INTERFACE ${THIS_PACKAGE_INCLUDE_DEPENDS}) +target_compile_features(kinematics_interface INTERFACE cxx_std_17) +target_include_directories(kinematics_interface INTERFACE + $ + $ +) +target_link_libraries(kinematics_interface INTERFACE + Eigen3::Eigen + rclcpp::rclcpp + rclcpp_lifecycle::rclcpp_lifecycle +) # Causes the visibility macros to use dllexport rather than dllimport, # which is appropriate when building the dll but not consuming it. target_compile_definitions(kinematics_interface INTERFACE "KINEMATICS_INTERFACE_BUILDING_DLL") -install(DIRECTORY include/ - DESTINATION include +install( + DIRECTORY include/ + DESTINATION include/kinematics_interface ) - -ament_export_dependencies( - ${THIS_PACKAGE_INCLUDE_DEPENDS} +install( + TARGETS kinematics_interface + EXPORT export_kinematics_interface + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin ) -ament_export_include_directories( - include +ament_export_targets(export_kinematics_interface HAS_LIBRARY_TARGET) +ament_export_dependencies( + Eigen3 + rclcpp + rclcpp_lifecycle ) - ament_package() diff --git a/kinematics_interface_kdl/CMakeLists.txt b/kinematics_interface_kdl/CMakeLists.txt index 2681114..630efc5 100644 --- a/kinematics_interface_kdl/CMakeLists.txt +++ b/kinematics_interface_kdl/CMakeLists.txt @@ -1,72 +1,70 @@ -cmake_minimum_required(VERSION 3.8) -project(kinematics_interface_kdl) +cmake_minimum_required(VERSION 3.16) +project(kinematics_interface_kdl LANGUAGES CXX) -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") +if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)") add_compile_options(-Wall -Wextra -Wpedantic) endif() -set(THIS_PACKAGE_INCLUDE_DEPENDS - Eigen3 - kdl_parser - kinematics_interface - pluginlib - tf2_eigen_kdl -) - -# find dependencies find_package(ament_cmake REQUIRED) -foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS}) - find_package(${Dependency} REQUIRED) -endforeach() - +find_package(Eigen3 REQUIRED) +find_package(kdl_parser REQUIRED) +find_package(kinematics_interface REQUIRED) +find_package(pluginlib REQUIRED) +find_package(tf2_eigen_kdl REQUIRED) add_library( - ${PROJECT_NAME} + kinematics_interface_kdl SHARED src/kinematics_interface_kdl.cpp ) -target_include_directories(${PROJECT_NAME} PRIVATE include) -ament_target_dependencies(${PROJECT_NAME} ${THIS_PACKAGE_INCLUDE_DEPENDS}) - -pluginlib_export_plugin_description_file(kinematics_interface kinematics_interface_kdl.xml) - -install( - TARGETS ${PROJECT_NAME} - RUNTIME DESTINATION bin - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib +target_include_directories(kinematics_interface_kdl PUBLIC + $ + $ ) - -install( - DIRECTORY include/ - DESTINATION include +target_compile_features(kinematics_interface_kdl PUBLIC cxx_std_17) +target_link_libraries(kinematics_interface_kdl PUBLIC + Eigen3::Eigen + kdl_parser::kdl_parser + kinematics_interface::kinematics_interface + pluginlib::pluginlib + tf2_eigen_kdl::tf2_eigen_kdl ) +pluginlib_export_plugin_description_file(kinematics_interface kinematics_interface_kdl.xml) if(BUILD_TESTING) find_package(ament_cmake_gmock REQUIRED) find_package(ros2_control_test_assets REQUIRED) ament_add_gmock( - test_${PROJECT_NAME} + test_kinematics_interface_kdl test/test_kinematics_interface_kdl.cpp ) - target_include_directories(test_${PROJECT_NAME} PRIVATE include) - target_link_libraries(test_${PROJECT_NAME} ${PROJECT_NAME}) - ament_target_dependencies(test_${PROJECT_NAME} - ${THIS_PACKAGE_INCLUDE_DEPENDS} - ros2_control_test_assets - ) + target_link_libraries(test_kinematics_interface_kdl kinematics_interface_kdl) + + # TODO: Use target_link_libraries once ros2_control_test_assets' + # CMake include export is fixed + ament_target_dependencies(test_kinematics_interface_kdl ros2_control_test_assets) endif() -ament_export_libraries( - ${PROJECT_NAME} +install( + DIRECTORY include/ + DESTINATION include/kinematics_interface_kdl ) -ament_export_include_directories( - include +install( + TARGETS kinematics_interface_kdl + EXPORT export_kinematics_interface_kdl + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin ) + +ament_export_targets(export_kinematics_interface_kdl HAS_LIBRARY_TARGET) ament_export_dependencies( - ${THIS_PACKAGE_INCLUDE_DEPENDS} + Eigen3 + kdl_parser + kinematics_interface + pluginlib + tf2_eigen_kdl ) - ament_package()