Skip to content

[CMake] adjust clang resource dir symlinks to new path #66983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions stdlib/public/SwiftShims/swift/shims/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,20 @@ add_custom_target("copy_shim_headers" ALL
DEPENDS "${outputs}"
COMMENT "Copying SwiftShims module to ${output_dir}")

if ("${LLVM_PACKAGE_VERSION}" STREQUAL "")
message(FATAL_ERROR
"LLVM_PACKAGE_VERSION must be set before including subdirectories")
if (NOT CLANG_VERSION_MAJOR)
if (NOT LLVM_VERSION_MAJOR)
message(FATAL_ERROR
"CLANG_VERSION_MAJOR or LLVM_VERSION_MAJOR must be set \
in order to infer the path to clang headers")
else()
message(WARNING
"CLANG_VERSION_MAJOR is not defined, falling back to \
LLVM_VERSION_MAJOR to infer the path to clang headers")
set(CLANG_VERSION_MAJOR "${LLVM_VERSION_MAJOR}")
endif()
endif()

# Symlink in the Clang headers.
# First extract the "version" used for Clang's resource directory.
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
"${LLVM_PACKAGE_VERSION}")
# Symlink in the Clang headers from either the provided clang...
if(NOT SWIFT_INCLUDE_TOOLS AND
(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER OR SWIFT_PREBUILT_CLANG))
if(SWIFT_COMPILER_IS_MSVC_LIKE)
Expand All @@ -94,7 +99,8 @@ if(NOT SWIFT_INCLUDE_TOOLS AND
endif()
message(STATUS "Using clang Resource Directory: ${clang_headers_location}")
else()
set(clang_headers_location "${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}")
# ... or the one we just built
set(clang_headers_location "${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION_MAJOR}")
endif()

if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
Expand Down Expand Up @@ -205,7 +211,7 @@ if(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER OR SWIFT_PREBUILT_CLANG)
# toolchain was built with SWIFT_INCLUDE_TOOLS.
set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET_default ${clang_headers_location})
else()
set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET_default "../clang/${CLANG_VERSION}")
set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET_default "../clang/${CLANG_VERSION_MAJOR}")
endif()

set(SWIFT_CLANG_RESOURCE_DIR_SYMLINK_INSTALL_TARGET
Expand Down