[CMake] try creating symlink first on windows

//-E create_symlink//  is available on windows since CMake 3.13 (LLVM now uses 3.13.4)
It may needs administrator privileges or enabled developer mode (Windows 10)
See https://cmake.org/cmake/help/latest/release/3.13.html

Reviewed By: kbobyrev

Differential Revision: https://reviews.llvm.org/D99170
This commit is contained in:
Kirill Bobyrev 2021-04-07 11:23:10 +02:00
parent cd824a48cc
commit f37ea62e57
1 changed files with 7 additions and 8 deletions

View File

@ -4,18 +4,17 @@
function(install_symlink name target outdir)
set(DESTDIR $ENV{DESTDIR})
if(CMAKE_HOST_UNIX)
set(LINK_OR_COPY create_symlink)
else()
set(LINK_OR_COPY copy)
endif()
set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}/")
message(STATUS "Creating ${name}")
execute_process(
COMMAND "${CMAKE_COMMAND}" -E ${LINK_OR_COPY} "${target}" "${name}"
COMMAND "${CMAKE_COMMAND}" -E create_symlink "${target}" "${name}"
WORKING_DIRECTORY "${bindir}" ERROR_VARIABLE has_err)
if(CMAKE_HOST_WIN32 AND has_err)
execute_process(
COMMAND "${CMAKE_COMMAND}" -E copy "${target}" "${name}"
WORKING_DIRECTORY "${bindir}")
endif()
endfunction()