Skip to content

Commit

Permalink
HACK: Allow resolution of current project's path at build time
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaschke committed Jul 4, 2023
1 parent e242db8 commit de60e77
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmake/xacro-extras.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit de60e77

Please sign in to comment.