Skip to content

Commit 3f0adbd

Browse files
author
Chris B
authored
Merge pull request #5034 from llvm-beanz/fix-swiftshims-dependency
[CMake] Fix bad dependency in symlink_clang_headers
2 parents e53d0e2 + 58ca217 commit 3f0adbd

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

cmake/modules/SwiftComponents.cmake

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,29 @@ function(swift_install_in_component component)
122122
install(${ARGN})
123123
endif()
124124
endfunction()
125+
126+
function(swift_install_symlink_component component)
127+
cmake_parse_arguments(
128+
ARG # prefix
129+
"" "LINK_NAME;TARGET;DESTINATION" "" ${ARGN})
130+
precondition(ARG_LINK_NAME MESSAGE "LINK_NAME is required")
131+
precondition(ARG_TARGET MESSAGE "TARGET is required")
132+
precondition(ARG_DESTINATION MESSAGE "DESTINATION is required")
133+
134+
swift_is_installing_component("${component}" is_installing)
135+
if (NOT is_installing)
136+
return()
137+
endif()
138+
139+
foreach(path ${CMAKE_MODULE_PATH})
140+
if(EXISTS ${path}/LLVMInstallSymlink.cmake)
141+
set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake)
142+
break()
143+
endif()
144+
endforeach()
145+
precondition(INSTALL_SYMLINK
146+
MESSAGE "LLVMInstallSymlink script must be available.")
147+
148+
install(SCRIPT ${INSTALL_SYMLINK}
149+
CODE "install_symlink(${ARG_LINK_NAME} ${ARG_TARGET} ${ARG_DESTINATION})")
150+
endfunction()

stdlib/public/SwiftShims/CMakeLists.txt

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,8 @@ add_custom_command_target(unused_var
8080
"${clang_headers_location}"
8181
"${SWIFTLIB_DIR}/clang"
8282

83-
# Create a broken symlink that points to '../clang/$VERSION'. It is not
84-
# used when running Swift tools from the build tree directly, but we will
85-
# install it in such a way that it points to Clang installation. If the
86-
# link can be resolved, CMake would try to follow it when installing the
87-
# project under certain conditions.
88-
COMMAND
89-
"${CMAKE_COMMAND}" "-E" "make_directory" "${SWIFTLIB_DIR}/install-tmp/install-tmp"
90-
COMMAND
91-
"${CMAKE_COMMAND}" "-E" "remove"
92-
"${SWIFTLIB_DIR}/install-tmp/install-tmp/clang"
93-
COMMAND
94-
"${CMAKE_COMMAND}" "-E" "create_symlink"
95-
"../clang/${CLANG_VERSION}"
96-
"${SWIFTLIB_DIR}/install-tmp/install-tmp/clang"
9783
CUSTOM_TARGET_NAME "symlink_clang_headers"
98-
OUTPUT "${SWIFTLIB_DIR}/clang" "${SWIFTLIB_DIR}/install-tmp/install-tmp/clang"
84+
OUTPUT "${SWIFTLIB_DIR}/clang"
9985
COMMENT "Symlinking Clang resource headers into ${SWIFTLIB_DIR}/clang")
10086
add_dependencies(copy_shim_headers symlink_clang_headers)
10187

@@ -110,10 +96,10 @@ swift_install_in_component(clang-builtin-headers
11096
DESTINATION "lib/swift/clang"
11197
PATTERN "*.h")
11298

113-
# Alternatively, install a symbolic link to the Clang resource directory.
114-
swift_install_in_component(clang-resource-dir-symlink
115-
DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/swift/install-tmp/install-tmp/clang"
116-
DESTINATION "lib/swift")
99+
swift_install_symlink_component(clang-resource-dir-symlink
100+
LINK_NAME clang
101+
TARGET ../clang/${CLANG_VERSION}
102+
DESTINATION "lib/swift")
117103

118104
# Possibly install Clang headers under Clang's resource directory in case we
119105
# need to use a different version of the headers than the installed Clang. This

0 commit comments

Comments
 (0)