Skip to content

Commit 0bbcae4

Browse files
authored
Merge pull request #70877 from kateinoigakukun/pr-881a2ba91d1f6a7bc84606dea6aa0d069c0793ac
[CMake] Create tool header collector target only when building tools
2 parents 7a0c4b5 + 960086c commit 0bbcae4

File tree

2 files changed

+22
-29
lines changed

2 files changed

+22
-29
lines changed

include/CMakeLists.txt

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1 @@
11
add_subdirectory(swift)
2-
3-
4-
# Create a library that depends on all headers defined in include/swift/module.modulemap
5-
#
6-
# TODO: generate this dynamically through the modulemap; this cannot use `sed`
7-
# as that is not available on all platforms (e.g. Windows).
8-
file(GENERATE
9-
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp"
10-
CONTENT "
11-
#define COMPILED_WITH_SWIFT
12-
#define SWIFT_TARGET
13-
14-
#include \"swift/Basic/BasicBridging.h\"
15-
#include \"swift/AST/ASTBridging.h\"
16-
#include \"swift/IDE/IDEBridging.h\"
17-
#include \"swift/Parse/ParseBridging.h\"
18-
#include \"swift/SIL/SILBridging.h\"
19-
#include \"swift/SILOptimizer/OptimizerBridging.h\"
20-
")
21-
add_library(importedHeaderDependencies "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp")
22-
23-
# When building unified, we need to make sure all the Clang headers are
24-
# generated before we try to use them.
25-
# When building Swift against an already compiled LLVM/Clang, like
26-
# build-script does, this target does not exist, but the headers
27-
# are already completely generated at that point.
28-
if(TARGET clang-tablegen-targets)
29-
add_dependencies(importedHeaderDependencies clang-tablegen-targets)
30-
endif()

lib/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,28 @@ if (SWIFT_BUILD_SWIFT_SYNTAX)
7676
EXPORT_LINK_INTERFACE_LIBRARIES)
7777
endif()
7878

79+
# Create a library that depends on all tool headers defined in include/module.modulemap
80+
#
81+
# TODO: generate this dynamically through the modulemap; this cannot use `sed`
82+
# as that is not available on all platforms (e.g. Windows).
83+
file(GENERATE
84+
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp"
85+
CONTENT "
86+
#define COMPILED_WITH_SWIFT
87+
#define SWIFT_TARGET
88+
89+
#include \"swift/Basic/BasicBridging.h\"
90+
#include \"swift/AST/ASTBridging.h\"
91+
#include \"swift/IDE/IDEBridging.h\"
92+
#include \"swift/Parse/ParseBridging.h\"
93+
#include \"swift/SIL/SILBridging.h\"
94+
#include \"swift/SILOptimizer/OptimizerBridging.h\"
95+
")
96+
add_library(importedHeaderDependencies "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp")
97+
# Respect LLVM_COMMON_DEPENDS as well as `add_swift_X` does to ensure
98+
# all prerequisites like TableGen'ed headers are generated before.
99+
add_dependencies(importedHeaderDependencies ${LLVM_COMMON_DEPENDS})
100+
79101
add_subdirectory(APIDigester)
80102
add_subdirectory(AST)
81103
add_subdirectory(ASTGen)

0 commit comments

Comments
 (0)