[PATCH] D99170: [CMake] try creating symlink first on windows

LJC via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 23 03:46:43 PDT 2021


paperchalice created this revision.
paperchalice added a reviewer: chandlerc.
Herald added a subscriber: mgorny.
paperchalice requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99170

Files:
  llvm/cmake/modules/LLVMInstallSymlink.cmake


Index: llvm/cmake/modules/LLVMInstallSymlink.cmake
===================================================================
--- llvm/cmake/modules/LLVMInstallSymlink.cmake
+++ llvm/cmake/modules/LLVMInstallSymlink.cmake
@@ -3,19 +3,17 @@
 # See PR8397.
 
 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}"
-    WORKING_DIRECTORY "${bindir}")
+    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()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99170.332597.patch
Type: text/x-patch
Size: 1016 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210323/7c4356b5/attachment.bin>


More information about the llvm-commits mailing list