Skip to content

Commit 4277292

Browse files
authored
Merge pull request #19514 from compnerd/breakup
[Build System: CMake] make add_swift_library a wrapper to add_llvm_library
2 parents 433444f + c3555cf commit 4277292

File tree

29 files changed

+73
-156
lines changed

29 files changed

+73
-156
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 11 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,66 +1319,12 @@ endfunction()
13191319
#
13201320
# Usage:
13211321
# add_swift_host_library(name
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.
1322+
# [FORCE_BUILD_OPTIMIZED]
1323+
# [...]
13681324
function(add_swift_host_library name)
1369-
set(options
1370-
FORCE_BUILD_OPTIMIZED
1371-
SHARED
1372-
STATIC)
1325+
set(options FORCE_BUILD_OPTIMIZED)
13731326
set(single_parameter_options)
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)
1327+
set(multiple_parameter_options GYB_SOURCES)
13821328

13831329
cmake_parse_arguments(ASHL
13841330
"${options}"
@@ -1387,29 +1333,13 @@ function(add_swift_host_library name)
13871333
${ARGN})
13881334
set(ASHL_SOURCES ${ASHL_UNPARSED_ARGUMENTS})
13891335

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-
)
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()
14131343

14141344
swift_install_in_component(dev
14151345
TARGETS ${name}

lib/AST/CMakeLists.txt

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

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

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
70+
LINK_COMPONENTS
9371
bitreader bitwriter coroutines coverage irreader debuginfoDWARF
9472
profiledata instrumentation object objcarcopts mc mcparser
9573
bitreader bitwriter lto ipo option core support ${LLVM_TARGETS_TO_BUILD}
9674

9775
${EXTRA_AST_FLAGS}
9876
)
77+
target_link_libraries(swiftAST
78+
INTERFACE
79+
clangTooling
80+
clangFrontendTool)
9981

10082
# intrinsics_gen is the LLVM tablegen target that generates the include files
10183
# 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_LIBRARIES swiftBasic
4-
LLVM_COMPONENT_DEPENDS core)
3+
LINK_LIBS swiftBasic
4+
LINK_COMPONENTS core)
55

lib/Basic/CMakeLists.txt

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

22
# On non-Darwin require UUID.
33
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
4-
set(UUID_INCLUDE "")
54
set(UUID_LIBRARIES "")
65
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
7-
set(UUID_INCLUDE "")
86
set(UUID_LIBRARIES "rpcrt4.lib")
97
else()
108
find_package(UUID REQUIRED)
11-
set(UUID_INCLUDE "-I${UUID_INCLUDE_DIRS}")
129
endif()
1310

1411
# Figure out if we can track VC revisions.
@@ -102,13 +99,16 @@ add_swift_host_library(swiftBasic STATIC
10299
# Platform-agnostic fallback TaskQueue implementation
103100
Default/TaskQueue.inc
104101

105-
UnicodeExtendedGraphemeClusters.cpp.gyb
106-
107-
C_COMPILE_FLAGS ${UUID_INCLUDE}
108-
LINK_LIBRARIES
102+
GYB_SOURCES
103+
UnicodeExtendedGraphemeClusters.cpp.gyb
104+
LINK_LIBS
109105
swiftDemangling
110106
${UUID_LIBRARIES}
111-
LLVM_COMPONENT_DEPENDS support)
107+
LINK_COMPONENTS
108+
support)
109+
target_include_directories(swiftBasic
110+
PRIVATE
111+
${UUID_INCLUDE_DIRS})
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_LIBRARIES
19+
LINK_LIBS
2020
swiftAST
2121
swiftParse
2222
)

lib/Demangling/CMakeLists.txt

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

lib/Driver/CMakeLists.txt

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

2425
# Generate the static-stdlib-args.lnk file used by -static-stdlib option
2526
# 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_LIBRARIES
15+
LINK_LIBS
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_LIBRARIES
8+
LINK_LIBS
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_LIBRARIES
16+
LINK_LIBS
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_LIBRARIES
53+
LINK_LIBS
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_LIBRARIES
4+
LINK_LIBS
55
swiftIDE
66
swiftFrontend
77
swiftSILGen
88
swiftSILOptimizer
99
swiftIRGen
10-
LLVM_COMPONENT_DEPENDS
10+
LINK_COMPONENTS
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_LIBRARIES
6+
LINK_LIBS
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-
LLVM_COMPONENT_DEPENDS
10-
analysis
9+
LINK_COMPONENTS
10+
analysis
1111
)
1212

lib/Markup/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ add_swift_host_library(swiftMarkup STATIC
22
AST.cpp
33
LineList.cpp
44
Markup.cpp
5-
6-
LINK_LIBRARIES
5+
LINK_LIBS
76
libcmark_static)
87
target_compile_definitions(swiftMarkup
98
PRIVATE

lib/Migrator/CMakeLists.txt

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

5455
add_dependencies(swiftMigrator
5556
"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_LIBRARIES swiftBasic
6-
FILE_DEPENDS SwiftOptions)
5+
LINK_LIBS
6+
swiftBasic)
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_LIBRARIES
16+
LINK_LIBS
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_LIBRARIES
3+
LINK_LIBS
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_LIBRARIES
3+
LINK_LIBS
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_LIBRARIES
18+
LINK_LIBS
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_LIBRARIES
47+
LINK_LIBS
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_LIBRARIES
33+
LINK_LIBS
3434
swiftSIL
3535
)

lib/SILOptimizer/CMakeLists.txt

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

3636
add_swift_host_library(swiftSILOptimizer STATIC
3737
${SILOPTIMIZER_SOURCES}
38-
LINK_LIBRARIES swiftSIL)
38+
LINK_LIBS
39+
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_LIBRARIES
61+
LINK_LIBS
6262
swiftParse
6363
swiftAST
6464
swiftSerialization

0 commit comments

Comments
 (0)