Skip to content

Commit a761d7c

Browse files
committed
Revert "Revert "Revert "[Build System: CMake] make add_swift_library a wrapper to add_llvm_library"""
This reverts commit 121f5b6. Sorry to revert this again. This commit makes some pretty big changes. After messing with the merge-conflict created by this internally, I did not feel comfortable landing this now. I talked with Saleem and he agreed with me that this was the right thing to do.
1 parent 6952909 commit a761d7c

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
@@ -63,22 +63,40 @@ add_swift_host_library(swiftAST STATIC
6363
TypeWalker.cpp
6464
USRGeneration.cpp
6565

66-
LINK_LIBS
66+
LINK_LIBRARIES
6767
swiftMarkup
6868
swiftBasic
6969
swiftSyntax
7070

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

7698
${EXTRA_AST_FLAGS}
7799
)
78-
target_link_libraries(swiftAST
79-
INTERFACE
80-
clangTooling
81-
clangFrontendTool)
82100

83101
# intrinsics_gen is the LLVM tablegen target that generates the include files
84102
# 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

0 commit comments

Comments
 (0)