From 60c79ae0718963bb0e322f492c100ca820f93e3e Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Thu, 2 May 2024 17:22:48 -0500 Subject: [PATCH] Fix installation of Ign*.cmake modules on newer versions of CMake (#425) Signed-off-by: Addisu Z. Taddese --- CMakeLists.txt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb833285..0608d793 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,19 +182,23 @@ set(tick_tocked_cmake_files foreach(cmake_file ${tick_tocked_cmake_files}) string(REGEX REPLACE "^Gz" "Ign" ign_cmake_file ${cmake_file}) file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/cmake") + set(ign_cmake_file_path "${PROJECT_BINARY_DIR}/cmake/${ign_cmake_file}") if (WIN32) # Windows requires copy instead of symlink - install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E copy \ - ${PROJECT_SOURCE_DIR}\/cmake/${cmake_file} \ - ${PROJECT_BINARY_DIR}\/cmake/${ign_cmake_file})") + add_custom_command(OUTPUT ${ign_cmake_file_path} + COMMAND ${CMAKE_COMMAND} -E copy + ${PROJECT_SOURCE_DIR}/cmake/${cmake_file} ${ign_cmake_file_path} + ) else() - install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \ - ${cmake_file} \ - ${PROJECT_BINARY_DIR}\/cmake/${ign_cmake_file})") + add_custom_command(OUTPUT ${ign_cmake_file_path} + COMMAND ${CMAKE_COMMAND} -E create_symlink + ${cmake_file} ${ign_cmake_file_path} + ) endif() + add_custom_target(target_${ign_cmake_file} ALL DEPENDS ${ign_cmake_file_path}) install( - FILES ${PROJECT_BINARY_DIR}/cmake/${ign_cmake_file} + FILES ${ign_cmake_file_path} DESTINATION ${gz_modules_install_dir} COMPONENT modules) endforeach()