mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-10 18:22:42 +02:00
handle case where a symlink replaces copy
This commit is contained in:
parent
00b8c937c7
commit
b28e7cc765
1 changed files with 29 additions and 9 deletions
|
@ -10,21 +10,41 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
macro(SYMLINK_OR_COPY_DIRECTORY_BESIDE_TARGET _SHOULD_SYMLINK _DIRECTORY _DESTINATION)
|
macro(SYMLINK_OR_COPY_DIRECTORY_BESIDE_TARGET _SHOULD_SYMLINK _DIRECTORY _DESTINATION)
|
||||||
|
|
||||||
|
# remove the current directory
|
||||||
|
add_custom_command(
|
||||||
|
TARGET ${TARGET_NAME} POST_BUILD
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -E remove_directory $<TARGET_FILE_DIR:${TARGET_NAME}>/${_DESTINATION}
|
||||||
|
)
|
||||||
|
|
||||||
if (${_SHOULD_SYMLINK})
|
if (${_SHOULD_SYMLINK})
|
||||||
# the caller wants a symlink, so just add a command to symlink the DIR beside target
|
|
||||||
|
# first create the destination
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET ${TARGET_NAME} POST_BUILD
|
TARGET ${TARGET_NAME} POST_BUILD
|
||||||
COMMAND "${CMAKE_COMMAND}" -E create_symlink
|
COMMAND "${CMAKE_COMMAND}" -E make_directory
|
||||||
"${_DIRECTORY}"
|
|
||||||
$<TARGET_FILE_DIR:${TARGET_NAME}>/${_DESTINATION}
|
$<TARGET_FILE_DIR:${TARGET_NAME}>/${_DESTINATION}
|
||||||
)
|
|
||||||
else ()
|
|
||||||
# remove the current directory
|
|
||||||
add_custom_command(
|
|
||||||
TARGET ${TARGET_NAME} POST_BUILD
|
|
||||||
COMMAND "${CMAKE_COMMAND}" -E remove_directory $<TARGET_FILE_DIR:${TARGET_NAME}>/${_DESTINATION}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# the caller wants a symlink, so just add a command to symlink all contents of _DIRECTORY
|
||||||
|
# in the destination - we can't simply create a symlink for _DESTINATION
|
||||||
|
# because the remove_directory call above would delete the original files
|
||||||
|
|
||||||
|
file(GLOB _DIR_ITEMS ${_DIRECTORY}/*)
|
||||||
|
|
||||||
|
foreach(_ITEM ${_DIR_ITEMS})
|
||||||
|
# get the filename for this item
|
||||||
|
get_filename_component(_ITEM_FILENAME ${_ITEM} NAME)
|
||||||
|
|
||||||
|
# add the command to symlink this item
|
||||||
|
add_custom_command(
|
||||||
|
TARGET ${TARGET_NAME} POST_BUILD
|
||||||
|
COMMAND "${CMAKE_COMMAND}" -E create_symlink
|
||||||
|
${_ITEM}
|
||||||
|
$<TARGET_FILE_DIR:${TARGET_NAME}>/${_DESTINATION}/${_ITEM_FILENAME}
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
else ()
|
||||||
# copy the directory
|
# copy the directory
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET ${TARGET_NAME} POST_BUILD
|
TARGET ${TARGET_NAME} POST_BUILD
|
||||||
|
|
Loading…
Reference in a new issue