Skip to content

Commit 69afa32

Browse files
authored
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 <[email protected]>
1 parent fb1eda9 commit 69afa32

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

ament_cmake_core/cmake/symlink_install/ament_cmake_symlink_install_files.cmake

+18-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
set(__AMENT_CMAKE_SYMLINK_INSTALL_FILES_INDEX "0"
16+
CACHE INTERNAL "Index for unique symlink install files")
17+
1518
#
1619
# Reimplement CMake install(FILES) command to use symlinks instead of copying
1720
# resources.
@@ -42,8 +45,22 @@ function(ament_cmake_symlink_install_files files_keyword)
4245

4346
if(index EQUAL -1)
4447
string(REPLACE ";" "\" \"" argn_quoted "\"${ARGN}\"")
48+
49+
# generate unique files
50+
set(generated_file_base
51+
"${CMAKE_CURRENT_BINARY_DIR}/ament_cmake_symlink_install_files_${__AMENT_CMAKE_SYMLINK_INSTALL_FILES_INDEX}")
52+
set(generated_file_generator_suffix "${generated_file_base}_$<CONFIG>.cmake")
53+
set(generated_file_variable_suffix "${generated_file_base}_\${CMAKE_INSTALL_CONFIG_NAME}.cmake")
54+
math(EXPR __AMENT_CMAKE_SYMLINK_INSTALL_FILES_INDEX
55+
"${__AMENT_CMAKE_SYMLINK_INSTALL_FILES_INDEX} + 1")
56+
set(__AMENT_CMAKE_SYMLINK_INSTALL_FILES_INDEX "${__AMENT_CMAKE_SYMLINK_INSTALL_FILES_INDEX}"
57+
CACHE INTERNAL "Index for unique symlink install files")
58+
59+
file(GENERATE OUTPUT "${generated_file_generator_suffix}"
60+
CONTENT
61+
"ament_cmake_symlink_install_files(\"${CMAKE_CURRENT_SOURCE_DIR}\" FILES ${argn_quoted})\n")
4562
ament_cmake_symlink_install_append_install_code(
46-
"ament_cmake_symlink_install_files(\"${CMAKE_CURRENT_SOURCE_DIR}\" FILES ${argn_quoted})"
63+
"include(\"${generated_file_variable_suffix}\")"
4764
COMMENTS "install(FILES ${argn_quoted})"
4865
)
4966
endif()

0 commit comments

Comments
 (0)