Skip to content

Commit 3feb5ae

Browse files
[CMake] Create tool header collector target only when building tools
`HeaderDependencies.cpp` cannot be compiled with `SWIFT_INCLUDE_TOOLS=OFF` because it depends on `Config.h` which is only generated while building tools. Exclude it from the build to fix `all` target. Follow-up to b39dba3
1 parent c8fe36d commit 3feb5ae

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,34 @@ 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+
98+
# When building unified, we need to make sure all the Clang headers are
99+
# generated before we try to use them.
100+
# When building Swift against an already compiled LLVM/Clang, like
101+
# build-script does, this target does not exist, but the headers
102+
# are already completely generated at that point.
103+
if(TARGET clang-tablegen-targets)
104+
add_dependencies(importedHeaderDependencies clang-tablegen-targets)
105+
endif()
106+
79107
add_subdirectory(APIDigester)
80108
add_subdirectory(AST)
81109
add_subdirectory(ASTGen)

0 commit comments

Comments
 (0)