Skip to content

Commit

Permalink
Support generator expressions when symlinking install(FILES) (#560)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
cottsay authored Nov 19, 2024
1 parent fb1eda9 commit 69afa32
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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}_$<CONFIG>.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()
Expand Down

0 comments on commit 69afa32

Please sign in to comment.