From de60e77bf77fc7875a8f4bc64ceadeafd8de11a2 Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Tue, 4 Jul 2023 14:18:55 +0200 Subject: [PATCH 1/3] HACK: Allow resolution of current project's path at build time --- cmake/xacro-extras.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmake/xacro-extras.cmake b/cmake/xacro-extras.cmake index cd17f770..e6a66fbd 100644 --- a/cmake/xacro-extras.cmake +++ b/cmake/xacro-extras.cmake @@ -77,9 +77,16 @@ ${_xacro_err}") separate_arguments(_xacro_deps_result) + ## HACK: ament package resolution doesn't work at build time yet + # - Augment AMENT_PREFIX_PATH to include ${PROJECT_BINARY_DIR}/ament_cmake_index + # - Create a symlink from there to the actual source directory to find source files + set(PROJECT_BUILD_INDEX "${PROJECT_BINARY_DIR}/ament_cmake_index") + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BUILD_INDEX}/share") + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${PROJECT_SOURCE_DIR}" "${PROJECT_BUILD_INDEX}/share/${PROJECT_NAME}") + ## command to actually call xacro add_custom_command(OUTPUT ${output} - COMMAND xacro -o ${abs_output} ${input} ${_XACRO_REMAP} + COMMAND ${CMAKE_COMMAND} -E env AMENT_PREFIX_PATH="${PROJECT_BUILD_INDEX}:${AMENT_PREFIX_PATH}" xacro -o ${abs_output} ${input} ${_XACRO_REMAP} DEPENDS ${input} ${_xacro_deps_result} ${_XACRO_DEPENDS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "xacro: generating ${output} from ${input}" From c1c965215eae3fa4c73ee1137364c8a2eef47dee Mon Sep 17 00:00:00 2001 From: Yuki Furuta Date: Tue, 31 Oct 2023 02:31:33 -0700 Subject: [PATCH 2/3] Pass colon-separated AMENT_PREFIX_PATH --- cmake/xacro-extras.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/xacro-extras.cmake b/cmake/xacro-extras.cmake index e6a66fbd..6ee139c7 100644 --- a/cmake/xacro-extras.cmake +++ b/cmake/xacro-extras.cmake @@ -85,8 +85,9 @@ ${_xacro_err}") execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${PROJECT_SOURCE_DIR}" "${PROJECT_BUILD_INDEX}/share/${PROJECT_NAME}") ## command to actually call xacro - add_custom_command(OUTPUT ${output} - COMMAND ${CMAKE_COMMAND} -E env AMENT_PREFIX_PATH="${PROJECT_BUILD_INDEX}:${AMENT_PREFIX_PATH}" xacro -o ${abs_output} ${input} ${_XACRO_REMAP} + list(JOIN AMENT_PREFIX_PATH ":" AMENT_PREFIX_PATH_ENV) # format as colon-separated list + add_custom_command(OUTPUT ${abs_output} + COMMAND ${CMAKE_COMMAND} -E env AMENT_PREFIX_PATH="${PROJECT_BUILD_INDEX}:${AMENT_PREFIX_PATH_ENV}" xacro -o ${abs_output} ${input} ${_XACRO_REMAP} DEPENDS ${input} ${_xacro_deps_result} ${_XACRO_DEPENDS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "xacro: generating ${output} from ${input}" From 16e4631e18dada83566ddbc9c4b070b3ba3d43cd Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Tue, 31 Oct 2023 10:23:00 +0100 Subject: [PATCH 3/3] Remove commented-out cmake messages --- cmake/xacro-extras.cmake | 3 --- 1 file changed, 3 deletions(-) diff --git a/cmake/xacro-extras.cmake b/cmake/xacro-extras.cmake index 6ee139c7..393e2bc7 100644 --- a/cmake/xacro-extras.cmake +++ b/cmake/xacro-extras.cmake @@ -46,7 +46,6 @@ function(xacro_add_xacro_file input) message(FATAL_ERROR "no specified for: " ${input}) endif() endif() - # message(STATUS "output: ${output}") ## determine absolute output target location if(IS_ABSOLUTE ${output}) @@ -54,7 +53,6 @@ function(xacro_add_xacro_file input) else() set(abs_output ${CMAKE_CURRENT_BINARY_DIR}/${output}) endif() - # message(STATUS "abs_output: ${abs_output}") ## export abs_output to parent scope in variable ${_XACRO_OUTPUT} if(NOT _XACRO_OUTPUT) @@ -132,7 +130,6 @@ function(xacro_add_files) # have INSTALL option, but no TARGET: fallback to default target if(_XACRO_INSTALL AND NOT _XACRO_TARGET) - # message(STATUS "xacro: no TARGET specified, using default") set(_XACRO_TARGET _xacro_auto_generate) endif()