From 18245f1f5a1553d5e4d9d4842550c084845dea0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernd=20M=C3=BCller?= Date: Mon, 29 Jan 2024 23:04:25 +0100 Subject: [PATCH] take changes from https://github.com/ros/urdfdom/pull/142 to new version --- CMakeLists.txt | 15 ++++-- cmake-absolute-paths.patch | 86 +++++++++++++++++++++++++++++++++++ cmake/pkgconfig/urdfdom.pc.in | 4 +- cmake/urdfdom-config.cmake.in | 6 +-- 4 files changed, 103 insertions(+), 8 deletions(-) create mode 100644 cmake-absolute-paths.patch diff --git a/CMakeLists.txt b/CMakeLists.txt index b5330130..a53cb714 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ option(APPEND_PROJECT_NAME_TO_INCLUDEDIR if(APPEND_PROJECT_NAME_TO_INCLUDEDIR) set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}") + set(CMAKE_INSTALL_FULL_INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}/${PROJECT_NAME}") endif() # set the default build type @@ -59,9 +60,9 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}" enable_testing() -set(CMAKE_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake) -string(REGEX REPLACE "[^/]+" ".." RELATIVE_PATH_CMAKE_DIR_TO_PREFIX "${CMAKE_CONFIG_INSTALL_DIR}") -string(REGEX REPLACE "[^/]+" ".." RELATIVE_PATH_LIBDIR_TO_PREFIX "${CMAKE_INSTALL_LIBDIR}") +set(CMAKE_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/${PROJECT_NAME}/cmake) +file(RELATIVE_PATH RELATIVE_PATH_CMAKE_DIR_TO_PREFIX "${CMAKE_CONFIG_INSTALL_DIR}" "${CMAKE_INSTALL_PREFIX}") +file(RELATIVE_PATH RELATIVE_PATH_LIBDIR_TO_PREFIX "${CMAKE_INSTALL_FULL_LIBDIR}" "${CMAKE_INSTALL_PREFIX}") add_subdirectory(urdf_parser) @@ -69,6 +70,12 @@ set(PKG_NAME ${PROJECT_NAME}) set(PKG_LIBRARIES urdfdom_sensor urdfdom_model_state urdfdom_model urdfdom_world) set(PKG_DEPENDS urdfdom_headers) set(PKG_EXPORTS urdfdom) +string(REPLACE + "${CMAKE_INSTALL_PREFIX}" "\${${PROJECT_NAME}_DIR}/${RELATIVE_PATH_CMAKE_DIR_TO_PREFIX}" + CMAKE_CONF_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}") +string(REPLACE + "${CMAKE_INSTALL_PREFIX}" "\${${PROJECT_NAME}_DIR}/${RELATIVE_PATH_CMAKE_DIR_TO_PREFIX}" + CMAKE_CONF_INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}") set(cmake_conf_file "cmake/urdfdom-config") include(CMakePackageConfigHelpers) write_basic_package_version_file( @@ -92,6 +99,8 @@ install(FILES package.xml DESTINATION share/${PROJECT_NAME}) set(PKG_DESC "Unified Robot Description Format") set(PKG_DEPENDS "urdfdom_headers") # make the list separated by spaces instead of ; set(PKG_URDF_LIBS "-lurdfdom_sensor -lurdfdom_model_state -lurdfdom_model -lurdfdom_world") +string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${prefix}" PKG_CONF_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}") +string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${prefix}" PKG_CONF_INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}") set(pkg_conf_file "cmake/pkgconfig/urdfdom.pc") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${pkg_conf_file}.in" "${CMAKE_BINARY_DIR}/${pkg_conf_file}" @ONLY) install(FILES ${CMAKE_BINARY_DIR}/${pkg_conf_file} diff --git a/cmake-absolute-paths.patch b/cmake-absolute-paths.patch new file mode 100644 index 00000000..e1e663f0 --- /dev/null +++ b/cmake-absolute-paths.patch @@ -0,0 +1,86 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b533013..a53cb71 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -19,6 +19,7 @@ option(APPEND_PROJECT_NAME_TO_INCLUDEDIR + + if(APPEND_PROJECT_NAME_TO_INCLUDEDIR) + set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}") ++ set(CMAKE_INSTALL_FULL_INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}/${PROJECT_NAME}") + endif() + + # set the default build type +@@ -59,9 +60,9 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}" + + enable_testing() + +-set(CMAKE_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake) +-string(REGEX REPLACE "[^/]+" ".." RELATIVE_PATH_CMAKE_DIR_TO_PREFIX "${CMAKE_CONFIG_INSTALL_DIR}") +-string(REGEX REPLACE "[^/]+" ".." RELATIVE_PATH_LIBDIR_TO_PREFIX "${CMAKE_INSTALL_LIBDIR}") ++set(CMAKE_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/${PROJECT_NAME}/cmake) ++file(RELATIVE_PATH RELATIVE_PATH_CMAKE_DIR_TO_PREFIX "${CMAKE_CONFIG_INSTALL_DIR}" "${CMAKE_INSTALL_PREFIX}") ++file(RELATIVE_PATH RELATIVE_PATH_LIBDIR_TO_PREFIX "${CMAKE_INSTALL_FULL_LIBDIR}" "${CMAKE_INSTALL_PREFIX}") + + add_subdirectory(urdf_parser) + +@@ -69,6 +70,12 @@ set(PKG_NAME ${PROJECT_NAME}) + set(PKG_LIBRARIES urdfdom_sensor urdfdom_model_state urdfdom_model urdfdom_world) + set(PKG_DEPENDS urdfdom_headers) + set(PKG_EXPORTS urdfdom) ++string(REPLACE ++ "${CMAKE_INSTALL_PREFIX}" "\${${PROJECT_NAME}_DIR}/${RELATIVE_PATH_CMAKE_DIR_TO_PREFIX}" ++ CMAKE_CONF_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}") ++string(REPLACE ++ "${CMAKE_INSTALL_PREFIX}" "\${${PROJECT_NAME}_DIR}/${RELATIVE_PATH_CMAKE_DIR_TO_PREFIX}" ++ CMAKE_CONF_INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}") + set(cmake_conf_file "cmake/urdfdom-config") + include(CMakePackageConfigHelpers) + write_basic_package_version_file( +@@ -92,6 +99,8 @@ install(FILES package.xml DESTINATION share/${PROJECT_NAME}) + set(PKG_DESC "Unified Robot Description Format") + set(PKG_DEPENDS "urdfdom_headers") # make the list separated by spaces instead of ; + set(PKG_URDF_LIBS "-lurdfdom_sensor -lurdfdom_model_state -lurdfdom_model -lurdfdom_world") ++string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${prefix}" PKG_CONF_LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}") ++string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${prefix}" PKG_CONF_INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}") + set(pkg_conf_file "cmake/pkgconfig/urdfdom.pc") + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${pkg_conf_file}.in" "${CMAKE_BINARY_DIR}/${pkg_conf_file}" @ONLY) + install(FILES ${CMAKE_BINARY_DIR}/${pkg_conf_file} +diff --git a/cmake/pkgconfig/urdfdom.pc.in b/cmake/pkgconfig/urdfdom.pc.in +index 77d1d9f..01ccb89 100644 +--- a/cmake/pkgconfig/urdfdom.pc.in ++++ b/cmake/pkgconfig/urdfdom.pc.in +@@ -1,8 +1,8 @@ + # This file was generated by CMake for @PROJECT_NAME@ + prefix=${pcfiledir}/../@RELATIVE_PATH_LIBDIR_TO_PREFIX@ + exec_prefix=${prefix} +-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ +-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ ++libdir=@PKG_CONF_LIBDIR@ ++includedir=@PKG_CONF_INCLUDEDIR@ + + Name: @PKG_NAME@ + Description: @PKG_DESC@ +diff --git a/cmake/urdfdom-config.cmake.in b/cmake/urdfdom-config.cmake.in +index ee84f41..9a77019 100644 +--- a/cmake/urdfdom-config.cmake.in ++++ b/cmake/urdfdom-config.cmake.in +@@ -8,16 +8,16 @@ set(@PKG_NAME@_CONFIG_INCLUDED TRUE) + set(CMAKE_MODULE_PATH_BACKUP_URDFDOM ${CMAKE_MODULE_PATH}) + list(APPEND CMAKE_MODULE_PATH "${@PROJECT_NAME@_DIR}") + +-set(@PKG_NAME@_INCLUDE_DIRS "${@PROJECT_NAME@_DIR}/@RELATIVE_PATH_CMAKE_DIR_TO_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@") ++set(@PKG_NAME@_INCLUDE_DIRS "@CMAKE_CONF_INCLUDEDIR@") + + foreach(lib @PKG_LIBRARIES@) + set(onelib "${lib}-NOTFOUND") + set(onelibd "${lib}-NOTFOUND") + find_library(onelib ${lib} +- PATHS "${@PROJECT_NAME@_DIR}/@RELATIVE_PATH_CMAKE_DIR_TO_PREFIX@/@CMAKE_INSTALL_LIBDIR@" ++ PATHS "@CMAKE_CONF_LIBDIR@" + NO_DEFAULT_PATH) + find_library(onelibd ${lib}d +- PATHS "${@PROJECT_NAME@_DIR}/@RELATIVE_PATH_CMAKE_DIR_TO_PREFIX@/@CMAKE_INSTALL_LIBDIR@" ++ PATHS "@CMAKE_CONF_LIBDIR@" + NO_DEFAULT_PATH) + if(onelib-NOTFOUND AND onelibd-NOTFOUND) + message(FATAL_ERROR "Library '${lib}' in package @PKG_NAME@ is not installed properly") diff --git a/cmake/pkgconfig/urdfdom.pc.in b/cmake/pkgconfig/urdfdom.pc.in index 77d1d9f9..01ccb892 100644 --- a/cmake/pkgconfig/urdfdom.pc.in +++ b/cmake/pkgconfig/urdfdom.pc.in @@ -1,8 +1,8 @@ # This file was generated by CMake for @PROJECT_NAME@ prefix=${pcfiledir}/../@RELATIVE_PATH_LIBDIR_TO_PREFIX@ exec_prefix=${prefix} -libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ -includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ +libdir=@PKG_CONF_LIBDIR@ +includedir=@PKG_CONF_INCLUDEDIR@ Name: @PKG_NAME@ Description: @PKG_DESC@ diff --git a/cmake/urdfdom-config.cmake.in b/cmake/urdfdom-config.cmake.in index ee84f41d..9a770192 100644 --- a/cmake/urdfdom-config.cmake.in +++ b/cmake/urdfdom-config.cmake.in @@ -8,16 +8,16 @@ set(@PKG_NAME@_CONFIG_INCLUDED TRUE) set(CMAKE_MODULE_PATH_BACKUP_URDFDOM ${CMAKE_MODULE_PATH}) list(APPEND CMAKE_MODULE_PATH "${@PROJECT_NAME@_DIR}") -set(@PKG_NAME@_INCLUDE_DIRS "${@PROJECT_NAME@_DIR}/@RELATIVE_PATH_CMAKE_DIR_TO_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@") +set(@PKG_NAME@_INCLUDE_DIRS "@CMAKE_CONF_INCLUDEDIR@") foreach(lib @PKG_LIBRARIES@) set(onelib "${lib}-NOTFOUND") set(onelibd "${lib}-NOTFOUND") find_library(onelib ${lib} - PATHS "${@PROJECT_NAME@_DIR}/@RELATIVE_PATH_CMAKE_DIR_TO_PREFIX@/@CMAKE_INSTALL_LIBDIR@" + PATHS "@CMAKE_CONF_LIBDIR@" NO_DEFAULT_PATH) find_library(onelibd ${lib}d - PATHS "${@PROJECT_NAME@_DIR}/@RELATIVE_PATH_CMAKE_DIR_TO_PREFIX@/@CMAKE_INSTALL_LIBDIR@" + PATHS "@CMAKE_CONF_LIBDIR@" NO_DEFAULT_PATH) if(onelib-NOTFOUND AND onelibd-NOTFOUND) message(FATAL_ERROR "Library '${lib}' in package @PKG_NAME@ is not installed properly")