Skip to content

Commit

Permalink
[CMakeLists] install ontologenius_compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Sarthou committed Aug 9, 2024
1 parent 973861c commit 2ccf2c8
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ launch.json

# CMake
*.cmake
!cmake/*.cmake
*.bin
build/
40 changes: 38 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
${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)
Expand Down Expand Up @@ -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
Expand All @@ -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
)
Expand Down
1 change: 1 addition & 0 deletions cmake/ontologenius_compatConfigExtras.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/ontologenius_compatConfigIntermediate.cmake)
Empty file.
33 changes: 33 additions & 0 deletions cmake/ontologenius_compatConfigIntermediate.cmake.in
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 2ccf2c8

Please sign in to comment.