From ccb37f2664b775d1b0eccb15bf26a9521a64498a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Rodri=CC=81guez=20Troitin=CC=83o?= Date: Wed, 9 Feb 2022 12:20:52 -0800 Subject: [PATCH] [cmake] Allow overriding Clang resource symlink target When building with a prebuilt Clang, the changes introduced in #40707 supposed that the toolchain was in its final path. When building in stages (first the toolchain, then the standard library), the toolchain might not be in the final path, and the created symlink will point to a machine-local path that does not make sense. The changes introduced should not modify the existing behaviour introduced by #40707, but should allow customizing the final installation target using the CMake cached variable for those setups that need the flexibility. --- stdlib/public/SwiftShims/CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/stdlib/public/SwiftShims/CMakeLists.txt b/stdlib/public/SwiftShims/CMakeLists.txt index 09c581bb34ca9..66021bbe37fe7 100644 --- a/stdlib/public/SwiftShims/CMakeLists.txt +++ b/stdlib/public/SwiftShims/CMakeLists.txt @@ -205,20 +205,23 @@ endif() if(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER OR SWIFT_PREBUILT_CLANG) # This will still link against the Swift-forked clang headers if the Swift # toolchain was built with SWIFT_INCLUDE_TOOLS. - set(symlink_dir ${clang_headers_location}) + set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET_default ${clang_headers_location}) else() - set(symlink_dir "../clang/${CLANG_VERSION}") + set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET_default "../clang/${CLANG_VERSION}") endif() +set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET + ${SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET_default} CACHE STRING "The target of the installed symlink at lib/swift/clang") + swift_install_symlink_component(clang-resource-dir-symlink LINK_NAME clang - TARGET ${symlink_dir} + TARGET ${SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET} DESTINATION "lib/swift") if(SWIFT_BUILD_STATIC_STDLIB) swift_install_symlink_component(clang-resource-dir-symlink LINK_NAME clang - TARGET ${symlink_dir} + TARGET ${SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET} DESTINATION "lib/swift_static") endif()