Add CREATE_LINK polyfill for older CMakes

This commit is contained in:
Ariel Abreu 2021-01-13 23:26:13 -05:00
parent 2beda36721
commit 23aacf047a
No known key found for this signature in database
GPG Key ID: BB20848279B910AC
2 changed files with 13 additions and 0 deletions

View File

@ -46,6 +46,7 @@ include(MacroEnsureOutOfSourceBuild)
include(dsym) include(dsym)
include(xcproj) include(xcproj)
include(architecture) include(architecture)
include(create_symlink)
MACRO_ENSURE_OUT_OF_SOURCE_BUILD() MACRO_ENSURE_OUT_OF_SOURCE_BUILD()

View File

@ -0,0 +1,12 @@
#
# used to create a symbolic link at configuration time
#
function(create_symlink target output_path)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14.0")
# use CREATE_LINK if we can
file(CREATE_LINK "${target}" "${output_path}" SYMBOLIC)
else()
# fallback to `ln` otherwise
execute_process(COMMAND ln -sfn "${target}" "${output_path}")
endif()
endfunction()