blob: c1c76064b50163db2455167ba745fff028be99e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
From 39e048e60ae2153f7621b7d1a1949dcb69778fa1 Mon Sep 17 00:00:00 2001
From: Michael Platings <michael.platings@arm.com>
Date: Mon, 6 Mar 2023 22:53:54 +0000
Subject: [PATCH] Use LLVM_USE_SYMLINKS option in install_symlink
The change to potentially use symlinks on Windows was added in
https://reviews.llvm.org/D99170.
LLVM_USE_SYMLINKS was added more recently in
https://reviews.llvm.org/D135578 and allows specifying at configure time
whether or not symlinks should be created. The benefit of using this
option is it allows building the package on a symlink-capable Windows
machine with symlinks disabled so that the resulting package can be used
on a Windows machine that doesn't support symlinks.
Differential Revision: https://reviews.llvm.org/D145443
---
llvm/cmake/modules/AddLLVM.cmake | 16 ++++++++++++++--
llvm/cmake/modules/LLVMInstallSymlink.cmake | 14 ++++++--------
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 76695e69e740..fa23bf1d883a 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -2008,13 +2008,19 @@ function(llvm_install_library_symlink name dest type)
set(full_name ${CMAKE_${type}_LIBRARY_PREFIX}${name}${CMAKE_${type}_LIBRARY_SUFFIX})
set(full_dest ${CMAKE_${type}_LIBRARY_PREFIX}${dest}${CMAKE_${type}_LIBRARY_SUFFIX})
+ if(LLVM_USE_SYMLINKS)
+ set(LLVM_LINK_OR_COPY create_symlink)
+ else()
+ set(LLVM_LINK_OR_COPY copy)
+ endif()
+
set(output_dir lib${LLVM_LIBDIR_SUFFIX})
if(WIN32 AND "${type}" STREQUAL "SHARED")
set(output_dir "${CMAKE_INSTALL_BINDIR}")
endif()
install(SCRIPT ${INSTALL_SYMLINK}
- CODE "install_symlink(\"${full_name}\" \"${full_dest}\" \"${output_dir}\")"
+ CODE "install_symlink(\"${full_name}\" \"${full_dest}\" \"${output_dir}\" \"${LLVM_LINK_OR_COPY}\")"
COMPONENT ${component})
endfunction()
@@ -2049,10 +2055,16 @@ function(llvm_install_symlink project name dest)
set(full_dest llvm${CMAKE_EXECUTABLE_SUFFIX})
endif()
+ if(LLVM_USE_SYMLINKS)
+ set(LLVM_LINK_OR_COPY create_symlink)
+ else()
+ set(LLVM_LINK_OR_COPY copy)
+ endif()
+
set(output_dir "${${project}_TOOLS_INSTALL_DIR}")
install(SCRIPT ${INSTALL_SYMLINK}
- CODE "install_symlink(\"${full_name}\" \"${full_dest}\" \"${output_dir}\")"
+ CODE "install_symlink(\"${full_name}\" \"${full_dest}\" \"${output_dir}\" \"${LLVM_LINK_OR_COPY}\")"
COMPONENT ${component})
if (NOT LLVM_ENABLE_IDE AND NOT ARG_ALWAYS_GENERATE)
diff --git a/llvm/cmake/modules/LLVMInstallSymlink.cmake b/llvm/cmake/modules/LLVMInstallSymlink.cmake
index e9be04aceb3d..fb61265543d1 100644
--- a/llvm/cmake/modules/LLVMInstallSymlink.cmake
+++ b/llvm/cmake/modules/LLVMInstallSymlink.cmake
@@ -4,7 +4,10 @@
set(CMAKE_INSTALL_LIBDIR "lib")
include(GNUInstallDirs)
-function(install_symlink name target outdir)
+function(install_symlink name target outdir link_or_copy)
+ # link_or_copy is the "command" to pass to cmake -E.
+ # It should be either "create_symlink" or "copy".
+
set(DESTDIR $ENV{DESTDIR})
if(NOT IS_ABSOLUTE "${outdir}")
set(outdir "${CMAKE_INSTALL_PREFIX}/${outdir}")
@@ -14,12 +17,7 @@ function(install_symlink name target outdir)
message(STATUS "Creating ${name}")
execute_process(
- COMMAND "${CMAKE_COMMAND}" -E create_symlink "${target}" "${name}"
- WORKING_DIRECTORY "${outdir}" ERROR_VARIABLE has_err)
- if(CMAKE_HOST_WIN32 AND has_err)
- execute_process(
- COMMAND "${CMAKE_COMMAND}" -E copy "${target}" "${name}"
- WORKING_DIRECTORY "${outdir}")
- endif()
+ COMMAND "${CMAKE_COMMAND}" -E ${link_or_copy} "${target}" "${name}"
+ WORKING_DIRECTORY "${outdir}")
endfunction()
--
2.39.0.1.g6739ec1790
|