Skip to content

Commit 9412f19

Browse files
committed
[cmake] Change set_swift_llvm_is_available to set definitions on a specific target.
Otherwise we set it on all targets/languages in a subdirectory (I forgot if it propagates up). Regardless, this type of viral stuff is something we want to move away from since it creates a code that is a "forall" piece of code rather than a piece of code that only effects a single target. I also conditionalized the actual definitions being added on the compiled file's language being C,CXX,OBJC,OBJCXX since as we add Swift sources to the host side of the compiler, we will not want these flags to propagate to Swift sources.
1 parent 0d4d98e commit 9412f19

File tree

22 files changed

+54
-27
lines changed

22 files changed

+54
-27
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ endmacro()
638638

639639
# Declare that files in this library are built with LLVM's support
640640
# libraries available.
641-
macro(set_swift_llvm_is_available)
642-
add_compile_options(-DSWIFT_LLVM_SUPPORT_IS_AVAILABLE)
643-
endmacro()
641+
function(set_swift_llvm_is_available name)
642+
target_compile_definitions(${name} PRIVATE
643+
$<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:SWIFT_LLVM_SUPPORT_IS_AVAILABLE>)
644+
endfunction()

lib/APIDigester/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set_swift_llvm_is_available()
1+
22

33
add_swift_host_library(swiftAPIDigester STATIC
44
ModuleAnalyzerNodes.cpp
@@ -8,3 +8,5 @@ target_link_libraries(swiftAPIDigester PRIVATE
88
swiftFrontend
99
swiftSIL
1010
swiftIDE)
11+
12+
set_swift_llvm_is_available(swiftAPIDigester)

lib/AST/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ else()
99
)
1010
endif()
1111

12-
set_swift_llvm_is_available()
13-
1412
add_swift_host_library(swiftAST STATIC
1513
AbstractSourceFileDepGraphFactory.cpp
1614
AccessNotes.cpp
@@ -146,3 +144,5 @@ endif()
146144
# headers.
147145
# For more information see the comment at the top of lib/CMakeLists.txt.
148146
add_dependencies(swiftAST intrinsics_gen clang-tablegen-targets)
147+
148+
set_swift_llvm_is_available(swiftAST)

lib/ASTSectionImporter/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
set_swift_llvm_is_available()
1+
22

33
add_swift_host_library(swiftASTSectionImporter STATIC
44
ASTSectionImporter.cpp
55
LLVM_LINK_COMPONENTS core)
66
target_link_libraries(swiftASTSectionImporter PRIVATE
77
swiftBasic)
88

9+
set_swift_llvm_is_available(swiftASTSectionImporter)

lib/ClangImporter/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ set(SWIFT_GYB_FLAGS
44
add_gyb_target(generated_sorted_cf_database
55
SortedCFDatabase.def.gyb)
66

7-
set_swift_llvm_is_available()
8-
97
add_swift_host_library(swiftClangImporter STATIC
108
CFTypeInfo.cpp
119
ClangAdapter.cpp
@@ -37,3 +35,5 @@ get_property(CLANG_TABLEGEN_TARGETS GLOBAL PROPERTY CLANG_TABLEGEN_TARGETS)
3735
add_dependencies(swiftClangImporter
3836
generated_sorted_cf_database
3937
${CLANG_TABLEGEN_TARGETS})
38+
39+
set_swift_llvm_is_available(swiftClangImporter)

lib/DependencyScan/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#set_swift_llvm_is_available()
1+
22

33
add_swift_host_library(swiftDependencyScan STATIC
44
DependencyScanningTool.cpp

lib/Driver/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set_swift_llvm_is_available()
1+
22

33
set(swiftDriver_sources
44
Action.cpp
@@ -25,3 +25,5 @@ target_link_libraries(swiftDriver PRIVATE
2525
swiftAST
2626
swiftBasic
2727
swiftOption)
28+
29+
set_swift_llvm_is_available(swiftDriver)

lib/Frontend/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set_swift_llvm_is_available()
1+
22
add_swift_host_library(swiftFrontend STATIC
33
ArgsToFrontendInputsConverter.cpp
44
ArgsToFrontendOptionsConverter.cpp
@@ -29,3 +29,4 @@ target_link_libraries(swiftFrontend PRIVATE
2929
swiftSerialization
3030
swiftTBDGen)
3131

32+
set_swift_llvm_is_available(swiftFrontend)

lib/FrontendTool/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set_swift_llvm_is_available()
1+
22
add_swift_host_library(swiftFrontendTool STATIC
33
FrontendTool.cpp
44
ImportedModules.cpp
@@ -27,3 +27,5 @@ target_link_libraries(swiftFrontendTool PRIVATE
2727
swiftSILGen
2828
swiftSILOptimizer
2929
swiftTBDGen)
30+
31+
set_swift_llvm_is_available(swiftFrontendTool)

lib/IDE/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set_swift_llvm_is_available()
1+
22
add_swift_host_library(swiftIDE STATIC
33
CodeCompletion.cpp
44
CodeCompletionCache.cpp
@@ -29,3 +29,4 @@ target_link_libraries(swiftIDE PRIVATE
2929
swiftParse
3030
swiftSema)
3131

32+
set_swift_llvm_is_available(swiftIDE)

0 commit comments

Comments
 (0)