Skip to content

Commit 3dfedf0

Browse files
authored
Merge pull request #20247 from apple/revert-19514-breakup
Revert "[Build System: CMake] make add_swift_library a wrapper to add_llvm_library"
2 parents bf16b27 + 103f9a8 commit 3dfedf0

File tree

29 files changed

+156
-73
lines changed

29 files changed

+156
-73
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 81 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,12 +1319,66 @@ endfunction()
13191319
#
13201320
# Usage:
13211321
# add_swift_host_library(name
1322-
# [FORCE_BUILD_OPTIMIZED]
1323-
# [...]
1322+
# [SHARED]
1323+
# [STATIC]
1324+
# [DEPENDS dep1 ...]
1325+
# [LINK_LIBRARIES dep1 ...]
1326+
# [INTERFACE_LINK_LIBRARIES dep1 ...]
1327+
# [SWIFT_MODULE_DEPENDS dep1 ...]
1328+
# [LLVM_COMPONENT_DEPENDS comp1 ...]
1329+
# [FILE_DEPENDS target1 ...]
1330+
# [C_COMPILE_FLAGS flag1...]
1331+
# [LINK_FLAGS flag1...]
1332+
# [INSTALL]
1333+
# INSTALL_IN_COMPONENT comp
1334+
# source1 [source2 source3 ...])
1335+
#
1336+
# name
1337+
# Name of the library (e.g., swiftParse).
1338+
#
1339+
# SHARED
1340+
# Build a shared library.
1341+
#
1342+
# STATIC
1343+
# Build a static library.
1344+
#
1345+
# DEPENDS
1346+
# Targets that this library depends on.
1347+
#
1348+
# LINK_LIBRARIES
1349+
# Libraries this library depends on.
1350+
#
1351+
# LLVM_COMPONENT_DEPENDS
1352+
# LLVM components this library depends on.
1353+
#
1354+
# FILE_DEPENDS
1355+
# Additional files this library depends on.
1356+
#
1357+
# C_COMPILE_FLAGS
1358+
# Extra compiler flags (C, C++, ObjC).
1359+
#
1360+
# LINK_FLAGS
1361+
# Extra linker flags.
1362+
#
1363+
# INSTALL_IN_COMPONENT comp
1364+
# The Swift installation component that this library belongs to.
1365+
#
1366+
# source1 ...
1367+
# Sources to add into this library.
13241368
function(add_swift_host_library name)
1325-
set(options FORCE_BUILD_OPTIMIZED)
1369+
set(options
1370+
FORCE_BUILD_OPTIMIZED
1371+
SHARED
1372+
STATIC)
13261373
set(single_parameter_options)
1327-
set(multiple_parameter_options GYB_SOURCES)
1374+
set(multiple_parameter_options
1375+
C_COMPILE_FLAGS
1376+
DEPENDS
1377+
FILE_DEPENDS
1378+
INTERFACE_LINK_LIBRARIES
1379+
LINK_FLAGS
1380+
LINK_LIBRARIES
1381+
LLVM_COMPONENT_DEPENDS)
13281382

13291383
cmake_parse_arguments(ASHL
13301384
"${options}"
@@ -1333,13 +1387,29 @@ function(add_swift_host_library name)
13331387
${ARGN})
13341388
set(ASHL_SOURCES ${ASHL_UNPARSED_ARGUMENTS})
13351389

1336-
handle_gyb_sources(gyb_generated_targets ASHL_GYB_SOURCES
1337-
${SWIFT_HOST_VARIANT_ARCH})
1338-
llvm_add_library(${name} ${ASHL_GYB_SOURCES} ${ASHL_UNPARSED_ARGUMENTS}
1339-
DEPENDS ${gyb_generated_targets})
1340-
if(ASHL_FORCE_BUILD_OPTIMIZED)
1341-
target_compile_options(${name} PRIVATE "-O2")
1342-
endif()
1390+
translate_flags(ASHL "${options}")
1391+
1392+
if(NOT ASHL_SHARED AND NOT ASHL_STATIC)
1393+
message(FATAL_ERROR "Either SHARED or STATIC must be specified")
1394+
endif()
1395+
1396+
_add_swift_library_single(
1397+
${name}
1398+
${name}
1399+
${ASHL_SHARED_keyword}
1400+
${ASHL_STATIC_keyword}
1401+
${ASHL_SOURCES}
1402+
SDK ${SWIFT_HOST_VARIANT_SDK}
1403+
ARCHITECTURE ${SWIFT_HOST_VARIANT_ARCH}
1404+
DEPENDS ${ASHL_DEPENDS}
1405+
LINK_LIBRARIES ${ASHL_LINK_LIBRARIES}
1406+
LLVM_COMPONENT_DEPENDS ${ASHL_LLVM_COMPONENT_DEPENDS}
1407+
FILE_DEPENDS ${ASHL_FILE_DEPENDS}
1408+
C_COMPILE_FLAGS ${ASHL_C_COMPILE_FLAGS}
1409+
LINK_FLAGS ${ASHL_LINK_FLAGS}
1410+
INTERFACE_LINK_LIBRARIES ${ASHL_INTERFACE_LINK_LIBRARIES}
1411+
INSTALL_IN_COMPONENT "dev"
1412+
)
13431413

13441414
swift_install_in_component(dev
13451415
TARGETS ${name}

lib/AST/CMakeLists.txt

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,40 @@ add_swift_host_library(swiftAST STATIC
6262
TypeWalker.cpp
6363
USRGeneration.cpp
6464

65-
LINK_LIBS
65+
LINK_LIBRARIES
6666
swiftMarkup
6767
swiftBasic
6868
swiftSyntax
6969

70-
LINK_COMPONENTS
70+
INTERFACE_LINK_LIBRARIES
71+
# Clang dependencies.
72+
# FIXME: Clang should really export these in some reasonable manner.
73+
clangCodeGen
74+
clangIndex
75+
clangFormat
76+
clangToolingCore
77+
clangFrontendTool
78+
clangFrontend
79+
clangDriver
80+
clangSerialization
81+
clangParse
82+
clangSema
83+
clangAnalysis
84+
clangEdit
85+
clangRewriteFrontend
86+
clangRewrite
87+
clangAST
88+
clangLex
89+
clangAPINotes
90+
clangBasic
91+
92+
LLVM_COMPONENT_DEPENDS
7193
bitreader bitwriter coroutines coverage irreader debuginfoDWARF
7294
profiledata instrumentation object objcarcopts mc mcparser
7395
bitreader bitwriter lto ipo option core support ${LLVM_TARGETS_TO_BUILD}
7496

7597
${EXTRA_AST_FLAGS}
7698
)
77-
target_link_libraries(swiftAST
78-
INTERFACE
79-
clangTooling
80-
clangFrontendTool)
8199

82100
# intrinsics_gen is the LLVM tablegen target that generates the include files
83101
# where intrinsics and attributes are declared. swiftAST depends on these

lib/ASTSectionImporter/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_swift_host_library(swiftASTSectionImporter STATIC
22
ASTSectionImporter.cpp
3-
LINK_LIBS swiftBasic
4-
LINK_COMPONENTS core)
3+
LINK_LIBRARIES swiftBasic
4+
LLVM_COMPONENT_DEPENDS core)
55

lib/Basic/CMakeLists.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11

22
# On non-Darwin require UUID.
33
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
4+
set(UUID_INCLUDE "")
45
set(UUID_LIBRARIES "")
56
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
7+
set(UUID_INCLUDE "")
68
set(UUID_LIBRARIES "rpcrt4.lib")
79
else()
810
find_package(UUID REQUIRED)
11+
set(UUID_INCLUDE "-I${UUID_INCLUDE_DIRS}")
912
endif()
1013

1114
# Figure out if we can track VC revisions.
@@ -99,16 +102,13 @@ add_swift_host_library(swiftBasic STATIC
99102
# Platform-agnostic fallback TaskQueue implementation
100103
Default/TaskQueue.inc
101104

102-
GYB_SOURCES
103-
UnicodeExtendedGraphemeClusters.cpp.gyb
104-
LINK_LIBS
105+
UnicodeExtendedGraphemeClusters.cpp.gyb
106+
107+
C_COMPILE_FLAGS ${UUID_INCLUDE}
108+
LINK_LIBRARIES
105109
swiftDemangling
106110
${UUID_LIBRARIES}
107-
LINK_COMPONENTS
108-
support)
109-
target_include_directories(swiftBasic
110-
PRIVATE
111-
${UUID_INCLUDE_DIRS})
111+
LLVM_COMPONENT_DEPENDS support)
112112

113113
message(STATUS "Swift version: ${SWIFT_VERSION}")
114114
message(STATUS "Swift vendor: ${SWIFT_VENDOR}")

lib/ClangImporter/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ add_swift_host_library(swiftClangImporter STATIC
1616
ImportName.cpp
1717
ImportType.cpp
1818
SwiftLookupTable.cpp
19-
LINK_LIBS
19+
LINK_LIBRARIES
2020
swiftAST
2121
swiftParse
2222
)

lib/Demangling/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ add_swift_host_library(swiftDemangling
99
OldRemangler.cpp
1010
Punycode.cpp
1111
Remangler.cpp
12-
TypeDecoder.cpp)
13-
target_compile_definitions(swiftDemangling
14-
PRIVATE
15-
LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1)
12+
TypeDecoder.cpp
13+
C_COMPILE_FLAGS
14+
-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1)
1615

lib/Driver/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ set(swiftDriver_targetDefines)
1919
add_swift_host_library(swiftDriver STATIC
2020
${swiftDriver_sources}
2121
DEPENDS SwiftOptions
22-
LINK_LIBS
23-
swiftAST swiftBasic swiftOption)
22+
LINK_LIBRARIES swiftAST swiftBasic swiftOption)
2423

2524
# Generate the static-stdlib-args.lnk file used by -static-stdlib option
2625
# for 'GenericUnix' (eg linux)

lib/Frontend/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ add_swift_host_library(swiftFrontend STATIC
1212
SerializedDiagnosticConsumer.cpp
1313
DEPENDS
1414
SwiftOptions
15-
LINK_LIBS
15+
LINK_LIBRARIES
1616
swiftSIL
1717
swiftMigrator
1818
swiftOption

lib/FrontendTool/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ add_swift_host_library(swiftFrontendTool STATIC
55
TBD.cpp
66
DEPENDS
77
swift-syntax-generated-headers SwiftOptions
8-
LINK_LIBS
8+
LINK_LIBRARIES
99
swiftIndex
1010
swiftIDE
1111
swiftTBDGen swiftIRGen swiftSIL swiftSILGen swiftSILOptimizer

lib/IDE/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ add_swift_host_library(swiftIDE STATIC
1313
IDETypeChecking.cpp
1414
APIDigesterData.cpp
1515
SourceEntityWalker.cpp
16-
LINK_LIBS
16+
LINK_LIBRARIES
1717
swiftFrontend
1818
swiftClangImporter
1919
swiftParse

lib/IRGen/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ add_swift_host_library(swiftIRGen STATIC
5050
SwiftTargetInfo.cpp
5151
TypeLayoutDumper.cpp
5252
TypeLayoutVerifier.cpp
53-
LINK_LIBS
53+
LINK_LIBRARIES
5454
swiftAST
5555
swiftLLVMPasses
5656
swiftSIL

lib/Immediate/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
add_swift_host_library(swiftImmediate STATIC
22
Immediate.cpp
33
REPL.cpp
4-
LINK_LIBS
4+
LINK_LIBRARIES
55
swiftIDE
66
swiftFrontend
77
swiftSILGen
88
swiftSILOptimizer
99
swiftIRGen
10-
LINK_COMPONENTS
10+
LLVM_COMPONENT_DEPENDS
1111
linker mcjit)
1212

lib/Index/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ add_swift_host_library(swiftIndex STATIC
33
IndexDataConsumer.cpp
44
IndexRecord.cpp
55
IndexSymbol.cpp
6-
LINK_LIBS
6+
LINK_LIBRARIES
77
swiftAST)

lib/LLVMPasses/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ add_swift_host_library(swiftLLVMPasses STATIC
66
LLVMInlineTree.cpp
77
LLVMMergeFunctions.cpp
88

9-
LINK_COMPONENTS
10-
analysis
9+
LLVM_COMPONENT_DEPENDS
10+
analysis
1111
)
1212

lib/Markup/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ add_swift_host_library(swiftMarkup STATIC
22
AST.cpp
33
LineList.cpp
44
Markup.cpp
5-
LINK_LIBS
5+
6+
LINK_LIBRARIES
67
libcmark_static)
78
target_compile_definitions(swiftMarkup
89
PRIVATE

lib/Migrator/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ add_swift_host_library(swiftMigrator STATIC
4949
Migrator.cpp
5050
MigrationState.cpp
5151
RewriteBufferEditsReceiver.cpp
52-
LINK_LIBS
53-
swiftSyntax swiftIDE)
52+
LINK_LIBRARIES swiftSyntax swiftIDE)
5453

5554
add_dependencies(swiftMigrator
5655
"symlink_migrator_data")

lib/Option/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ add_swift_host_library(swiftOption STATIC
22
Options.cpp
33
SanitizerOptions.cpp
44
DEPENDS SwiftOptions
5-
LINK_LIBS
6-
swiftBasic)
5+
LINK_LIBRARIES swiftBasic
6+
FILE_DEPENDS SwiftOptions)
77

lib/Parse/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ add_swift_host_library(swiftParse STATIC
1313
Scope.cpp
1414
SyntaxParsingCache.cpp
1515
SyntaxParsingContext.cpp
16-
LINK_LIBS
16+
LINK_LIBRARIES
1717
swiftAST
1818
swiftSyntax
1919
)

lib/ParseSIL/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
add_swift_host_library(swiftParseSIL STATIC
22
ParseSIL.cpp
3-
LINK_LIBS
3+
LINK_LIBRARIES
44
swiftParse
55
swiftSema
66
swiftSIL

lib/PrintAsObjC/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
add_swift_host_library(swiftPrintAsObjC STATIC
22
PrintAsObjC.cpp
3-
LINK_LIBS
3+
LINK_LIBRARIES
44
swiftIDE
55
swiftFrontend
66
swiftClangImporter

lib/RemoteAST/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ add_swift_host_library(swiftRemoteAST STATIC
1515
RemoteAST.cpp
1616
InProcessMemoryReader.cpp
1717
${REMOTE_LIB_HEADERS}
18-
LINK_LIBS
18+
LINK_LIBRARIES
1919
swiftSema swiftIRGen)

lib/SIL/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ add_swift_host_library(swiftSIL STATIC
4444
SILWitnessTable.cpp
4545
TypeLowering.cpp
4646
ValueOwnership.cpp
47-
LINK_LIBS
47+
LINK_LIBRARIES
4848
swiftSerialization
4949
swiftSema
5050
)

lib/SILGen/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ add_swift_host_library(swiftSILGen STATIC
3030
SILGenStmt.cpp
3131
SILGenThunk.cpp
3232
SILGenType.cpp
33-
LINK_LIBS
33+
LINK_LIBRARIES
3434
swiftSIL
3535
)

lib/SILOptimizer/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,4 @@ add_subdirectory(Utils)
3535

3636
add_swift_host_library(swiftSILOptimizer STATIC
3737
${SILOPTIMIZER_SOURCES}
38-
LINK_LIBS
39-
swiftSIL)
38+
LINK_LIBRARIES swiftSIL)

lib/Sema/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ add_swift_host_library(swiftSema STATIC
5858
TypeCheckSwitchStmt.cpp
5959
TypeCheckType.cpp
6060
TypeChecker.cpp
61-
LINK_LIBS
61+
LINK_LIBRARIES
6262
swiftParse
6363
swiftAST
6464
swiftSerialization

0 commit comments

Comments
 (0)