From 2ccf2c80a1d3df61ab668b16db843d4f6196a2a7 Mon Sep 17 00:00:00 2001 From: Guillaume Sarthou Date: Fri, 9 Aug 2024 11:46:11 +0200 Subject: [PATCH] [CMakeLists] install ontologenius_compat --- .gitignore | 1 + CMakeLists.txt | 40 ++++++++++++++++++- cmake/ontologenius_compatConfigExtras.cmake | 1 + ...ntologenius_compatConfigIntermediate.cmake | 0 ...logenius_compatConfigIntermediate.cmake.in | 33 +++++++++++++++ 5 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 cmake/ontologenius_compatConfigExtras.cmake create mode 100644 cmake/ontologenius_compatConfigIntermediate.cmake create mode 100644 cmake/ontologenius_compatConfigIntermediate.cmake.in diff --git a/.gitignore b/.gitignore index 4a8a35bc..ba98e87f 100644 --- a/.gitignore +++ b/.gitignore @@ -53,5 +53,6 @@ launch.json # CMake *.cmake +!cmake/*.cmake *.bin build/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b787c52..32a3d155 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,6 @@ endif() include(cmake/Sanitizers.cmake) -# add_compile_options(-DONTO_ROS_VERSION=$ENV{ROS_VERSION}) function(add_onto_library TARGET) if(NOT TARGET) message(FATAL_ERROR "Expected the target name as first argument") @@ -121,6 +120,7 @@ if($ENV{ROS_VERSION} STREQUAL "1") LIBRARIES ontologenius_lib ontologenius_interface CATKIN_DEPENDS roscpp rospy std_msgs DEPENDS TinyXML OpenCV + CFG_EXTRAS ontologenius_compatConfigExtras.cmake ) elseif($ENV{ROS_VERSION} STREQUAL "2") ament_export_dependencies(rosidl_default_runtime pluginlib) @@ -231,7 +231,10 @@ function(add_ros_library TARGET) if($ENV{ROS_VERSION} STREQUAL "1") add_dependencies(${TARGET} ontologenius_gencpp ${catkin_EXPORTED_TARGETS}) - target_include_directories(${TARGET} PUBLIC include ${catkin_INCLUDE_DIRS}) + target_include_directories(${TARGET} PUBLIC + $ + $ + ${catkin_INCLUDE_DIRS}) target_link_libraries(${TARGET} PUBLIC ${catkin_LIBRARIES}) # PRIVATE has been removed fot ontoloGUI elseif($ENV{ROS_VERSION} STREQUAL "2") ament_target_dependencies(${TARGET} PUBLIC rclcpp pluginlib builtin_interfaces std_msgs) @@ -464,6 +467,33 @@ target_include_directories(ontoloGUI PUBLIC include) # # Install ## # ################################## if($ENV{ROS_VERSION} STREQUAL "1") + # Generate CMake package config file + include(CMakePackageConfigHelpers) + configure_package_config_file( + cmake/ontologenius_compatConfigIntermediate.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/ontologenius_compatConfigIntermediate.cmake + INSTALL_DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/cmake + ) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/ontologenius_compatConfigIntermediate.cmake + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/cmake + ) + + install( + TARGETS ontologenius_compat + EXPORT ontologenius_compatTargets + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + ) + + # Install the target file + install( + EXPORT ontologenius_compatTargets + FILE ontologenius_compatTargets.cmake + NAMESPACE ontologenius:: + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/cmake + ) + install(TARGETS ontoloGUI RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) install(TARGETS @@ -481,6 +511,12 @@ if($ENV{ROS_VERSION} STREQUAL "1") PATTERN ".svn" EXCLUDE ) + install(DIRECTORY include/${PROJECT_NAME}/API/${PROJECT_NAME}/ + DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} + FILES_MATCHING PATTERN "*.h" + PATTERN ".svn" EXCLUDE + ) + install(DIRECTORY launch/ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch ) diff --git a/cmake/ontologenius_compatConfigExtras.cmake b/cmake/ontologenius_compatConfigExtras.cmake new file mode 100644 index 00000000..c5210373 --- /dev/null +++ b/cmake/ontologenius_compatConfigExtras.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/ontologenius_compatConfigIntermediate.cmake) diff --git a/cmake/ontologenius_compatConfigIntermediate.cmake b/cmake/ontologenius_compatConfigIntermediate.cmake new file mode 100644 index 00000000..e69de29b diff --git a/cmake/ontologenius_compatConfigIntermediate.cmake.in b/cmake/ontologenius_compatConfigIntermediate.cmake.in new file mode 100644 index 00000000..c05ffe16 --- /dev/null +++ b/cmake/ontologenius_compatConfigIntermediate.cmake.in @@ -0,0 +1,33 @@ +@PACKAGE_INIT@ + +# Handle transitive dependencies +# No dependencies for now +# include(CMakeFindDependencyMacro) +# find_dependency(Boost REQUIRED) + +FUNCTION(PREPEND var prefix) + SET(listVar "") + FOREACH(f ${ARGN}) + LIST(APPEND listVar "${prefix}/${f}") + ENDFOREACH(f) + SET(${var} "${listVar}" PARENT_SCOPE) +ENDFUNCTION(PREPEND) + +# Components that are always including +if (NOT "ontologenius_compat" IN_LIST ontologenius_compat_FIND_COMPONENTS) + set(ontologenius_compat_FIND_COMPONENTS "ontologenius_compat" ${ontologenius_compat_FIND_COMPONENTS}) + #list(PREPEND ontologenius_compat_FIND_COMPONENTS "ontologenius_compat") +endif() + +foreach(component ${ontologenius_compat_FIND_COMPONENTS}) + # For requested component, execute its "config" script + include( + ${CMAKE_CURRENT_LIST_DIR}/${component}Targets.cmake + RESULT_VARIABLE ontologenius_compat_${component}_FOUND + ) +endforeach() + +# No macro file for now +# include("${CMAKE_CURRENT_LIST_DIR}/ontologenius_compatMacros.cmake") + +check_required_components(ontologenius_compat)