Skip to content

Commit

Permalink
Fix installation of Ign*.cmake modules on newer versions of CMake (#425)
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <[email protected]>
  • Loading branch information
azeey authored May 2, 2024
1 parent 116763e commit 60c79ae
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 60c79ae

Please sign in to comment.