From 69afa32843a95dbed072c3eee282424a214f878a Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Tue, 19 Nov 2024 12:22:38 -0600 Subject: [PATCH] Support generator expressions when symlinking install(FILES) (#560) Generator expressions are supported when invoking install(FILES) normally, and this change adds support for such invocations when symlinking as well. The change is copied from ament_cmake_symlink_install_targets, which already performs this resolution successfully. Signed-off-by: Scott K Logan --- .../ament_cmake_symlink_install_files.cmake | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ament_cmake_core/cmake/symlink_install/ament_cmake_symlink_install_files.cmake b/ament_cmake_core/cmake/symlink_install/ament_cmake_symlink_install_files.cmake index e267c6d5..e54774ae 100644 --- a/ament_cmake_core/cmake/symlink_install/ament_cmake_symlink_install_files.cmake +++ b/ament_cmake_core/cmake/symlink_install/ament_cmake_symlink_install_files.cmake @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(__AMENT_CMAKE_SYMLINK_INSTALL_FILES_INDEX "0" + CACHE INTERNAL "Index for unique symlink install files") + # # Reimplement CMake install(FILES) command to use symlinks instead of copying # resources. @@ -42,8 +45,22 @@ function(ament_cmake_symlink_install_files files_keyword) if(index EQUAL -1) string(REPLACE ";" "\" \"" argn_quoted "\"${ARGN}\"") + + # generate unique files + set(generated_file_base + "${CMAKE_CURRENT_BINARY_DIR}/ament_cmake_symlink_install_files_${__AMENT_CMAKE_SYMLINK_INSTALL_FILES_INDEX}") + set(generated_file_generator_suffix "${generated_file_base}_$.cmake") + set(generated_file_variable_suffix "${generated_file_base}_\${CMAKE_INSTALL_CONFIG_NAME}.cmake") + math(EXPR __AMENT_CMAKE_SYMLINK_INSTALL_FILES_INDEX + "${__AMENT_CMAKE_SYMLINK_INSTALL_FILES_INDEX} + 1") + set(__AMENT_CMAKE_SYMLINK_INSTALL_FILES_INDEX "${__AMENT_CMAKE_SYMLINK_INSTALL_FILES_INDEX}" + CACHE INTERNAL "Index for unique symlink install files") + + file(GENERATE OUTPUT "${generated_file_generator_suffix}" + CONTENT + "ament_cmake_symlink_install_files(\"${CMAKE_CURRENT_SOURCE_DIR}\" FILES ${argn_quoted})\n") ament_cmake_symlink_install_append_install_code( - "ament_cmake_symlink_install_files(\"${CMAKE_CURRENT_SOURCE_DIR}\" FILES ${argn_quoted})" + "include(\"${generated_file_variable_suffix}\")" COMMENTS "install(FILES ${argn_quoted})" ) endif()