Skip to content

Commit 4ff5e8f

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 4ff5e8f

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

include/CMakeLists.txt

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
add_subdirectory(swift)
22

3+
if(SWIFT_INCLUDE_TOOLS)
34

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
5+
# Create a library that depends on all tool headers defined in include/module.modulemap
6+
#
7+
# TODO: generate this dynamically through the modulemap; this cannot use `sed`
8+
# as that is not available on all platforms (e.g. Windows).
9+
file(GENERATE
10+
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp"
11+
CONTENT "
12+
#define COMPILED_WITH_SWIFT
13+
#define SWIFT_TARGET
1314
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")
15+
#include \"swift/Basic/BasicBridging.h\"
16+
#include \"swift/AST/ASTBridging.h\"
17+
#include \"swift/IDE/IDEBridging.h\"
18+
#include \"swift/Parse/ParseBridging.h\"
19+
#include \"swift/SIL/SILBridging.h\"
20+
#include \"swift/SILOptimizer/OptimizerBridging.h\"
21+
")
22+
add_library(importedHeaderDependencies "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp")
2223

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)
24+
# When building unified, we need to make sure all the Clang headers are
25+
# generated before we try to use them.
26+
# When building Swift against an already compiled LLVM/Clang, like
27+
# build-script does, this target does not exist, but the headers
28+
# are already completely generated at that point.
29+
if(TARGET clang-tablegen-targets)
30+
add_dependencies(importedHeaderDependencies clang-tablegen-targets)
31+
endif()
3032
endif()

0 commit comments

Comments
 (0)