Skip to content

Commit

Permalink
Fix generation of CMake config files.
Browse files Browse the repository at this point in the history
Use the provided CMake primitives for this, which should
make it work in all situations.

Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette committed Nov 29, 2023
1 parent 2c58e3f commit b592bbd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 17 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,24 @@ set(PKG_NAME ${PROJECT_NAME})
set(PKG_LIBRARIES urdfdom_sensor urdfdom_model_state urdfdom_model urdfdom_world)
set(PKG_DEPENDS TinyXML2 urdfdom_headers console_bridge)
set(PKG_EXPORTS urdfdom)
set(cmake_conf_file "cmake/urdfdom-config.cmake")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${cmake_conf_file}.in" "${CMAKE_BINARY_DIR}/${cmake_conf_file}" @ONLY)
set(cmake_conf_file "cmake/urdfdom-config")
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${cmake_conf_file}Version.cmake"
VERSION ${URDF_VERSION}
COMPATIBILITY SameMajorVersion
)
configure_package_config_file("${cmake_conf_file}.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${cmake_conf_file}.cmake"
INSTALL_DESTINATION ${CMAKE_CONFIG_INSTALL_DIR}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${cmake_conf_file}.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${cmake_conf_file}Version.cmake"
DESTINATION ${CMAKE_CONFIG_INSTALL_DIR}
)

install(FILES package.xml DESTINATION share/${PROJECT_NAME})
install(FILES ${CMAKE_BINARY_DIR}/${cmake_conf_file}
DESTINATION ${CMAKE_CONFIG_INSTALL_DIR} COMPONENT cmake)

# Make the package config file
set(PKG_DESC "Unified Robot Description Format")
Expand Down
2 changes: 2 additions & 0 deletions cmake/urdfdom-config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@PACKAGE_INIT@

if (@PKG_NAME@_CONFIG_INCLUDED)
return()
endif()
Expand Down

0 comments on commit b592bbd

Please sign in to comment.