Skip to content

Commit 67176e7

Browse files
authored
Merge pull request #37838 from gottesmm/pr-1f1e2f54e1cefb7ac93a086a33295d1ce75a4094
[cmake] Fix a few issues around swift cmake support build/test
2 parents 91a7a47 + 98ab14d commit 67176e7

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,17 @@ function(add_swift_host_library name)
477477
endif()
478478
479479
add_library(${name} ${libkind} ${ASHL_SOURCES})
480-
add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
480+
481+
# Respect LLVM_COMMON_DEPENDS if it is set.
482+
#
483+
# LLVM_COMMON_DEPENDS if a global variable set in ./lib that provides targets
484+
# such as swift-syntax or tblgen that all LLVM/Swift based tools depend on. If
485+
# we don't have it defined, then do not add the dependency since some parts of
486+
# swift host tools do not interact with LLVM/Swift tools and do not define
487+
# LLVM_COMMON_DEPENDS.
488+
if (LLVM_COMMON_DEPENDS)
489+
add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
490+
endif()
481491
if (NOT ASHL_PURE_SWIFT)
482492
llvm_update_compile_flags(${name})
483493
endif()
@@ -624,12 +634,21 @@ function(add_swift_host_tool executable)
624634
_add_host_variant_c_compile_flags(${executable})
625635
_add_host_variant_link_flags(${executable})
626636
_add_host_variant_c_compile_link_flags(${executable})
627-
target_link_directories(${executable} PRIVATE
628-
${SWIFTLIB_DIR}/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR})
637+
629638
# Force executables linker language to be CXX so that we do not link using the
630639
# host toolchain swiftc.
631640
set_target_properties(${executable} PROPERTIES LINKER_LANGUAGE CXX)
632-
add_dependencies(${executable} ${LLVM_COMMON_DEPENDS})
641+
642+
# Respect LLVM_COMMON_DEPENDS if it is set.
643+
#
644+
# LLVM_COMMON_DEPENDS if a global variable set in ./lib that provides targets
645+
# such as swift-syntax or tblgen that all LLVM/Swift based tools depend on. If
646+
# we don't have it defined, then do not add the dependency since some parts of
647+
# swift host tools do not interact with LLVM/Swift tools and do not define
648+
# LLVM_COMMON_DEPENDS.
649+
if (LLVM_COMMON_DEPENDS)
650+
add_dependencies(${executable} ${LLVM_COMMON_DEPENDS})
651+
endif()
633652
634653
set_target_properties(${executable} PROPERTIES
635654
FOLDER "Swift executables")

validation-test/BuildSystem/swift-cmake/CMakeLists.txt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
# In the absence of fine grained tablegen dependencies we need to ensure that
2-
# Swift's libraries all build after the LLVM & Clang tablegen-generated headers
3-
# are generated. When building out-of-tree (as with build-script) LLVM & Clang's
4-
# CMake configuration files create these targets as dummies so we can safely
5-
# depend on them directly here (See: SR-6026)
6-
# LLVM_COMMON_DEPENDS is a construct from the LLVM build system. It is a special
7-
# purpose variable that provides common dependencies for all libraries, and
8-
# executables generated when it is set. CMake's scoping rules enforce that these
9-
# new dependencies will only be added to targets created under Swift's lib
10-
# directory.
11-
list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen clang-tablegen-targets)
12-
13-
# Add generated libSyntax headers to global dependencies.
14-
list(APPEND LLVM_COMMON_DEPENDS swift-syntax-generated-headers)
15-
list(APPEND LLVM_COMMON_DEPENDS swift-parse-syntax-generated-headers)
161

172
add_swift_host_library(TestCPPLib
183
STATIC

0 commit comments

Comments
 (0)