Skip to content

Revert "[Build System: CMake] make add_swift_library a wrapper to add_llvm_library" #20247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 81 additions & 11 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1319,12 +1319,66 @@ endfunction()
#
# Usage:
# add_swift_host_library(name
# [FORCE_BUILD_OPTIMIZED]
# [...]
# [SHARED]
# [STATIC]
# [DEPENDS dep1 ...]
# [LINK_LIBRARIES dep1 ...]
# [INTERFACE_LINK_LIBRARIES dep1 ...]
# [SWIFT_MODULE_DEPENDS dep1 ...]
# [LLVM_COMPONENT_DEPENDS comp1 ...]
# [FILE_DEPENDS target1 ...]
# [C_COMPILE_FLAGS flag1...]
# [LINK_FLAGS flag1...]
# [INSTALL]
# INSTALL_IN_COMPONENT comp
# source1 [source2 source3 ...])
#
# name
# Name of the library (e.g., swiftParse).
#
# SHARED
# Build a shared library.
#
# STATIC
# Build a static library.
#
# DEPENDS
# Targets that this library depends on.
#
# LINK_LIBRARIES
# Libraries this library depends on.
#
# LLVM_COMPONENT_DEPENDS
# LLVM components this library depends on.
#
# FILE_DEPENDS
# Additional files this library depends on.
#
# C_COMPILE_FLAGS
# Extra compiler flags (C, C++, ObjC).
#
# LINK_FLAGS
# Extra linker flags.
#
# INSTALL_IN_COMPONENT comp
# The Swift installation component that this library belongs to.
#
# source1 ...
# Sources to add into this library.
function(add_swift_host_library name)
set(options FORCE_BUILD_OPTIMIZED)
set(options
FORCE_BUILD_OPTIMIZED
SHARED
STATIC)
set(single_parameter_options)
set(multiple_parameter_options GYB_SOURCES)
set(multiple_parameter_options
C_COMPILE_FLAGS
DEPENDS
FILE_DEPENDS
INTERFACE_LINK_LIBRARIES
LINK_FLAGS
LINK_LIBRARIES
LLVM_COMPONENT_DEPENDS)

cmake_parse_arguments(ASHL
"${options}"
Expand All @@ -1333,13 +1387,29 @@ function(add_swift_host_library name)
${ARGN})
set(ASHL_SOURCES ${ASHL_UNPARSED_ARGUMENTS})

handle_gyb_sources(gyb_generated_targets ASHL_GYB_SOURCES
${SWIFT_HOST_VARIANT_ARCH})
llvm_add_library(${name} ${ASHL_GYB_SOURCES} ${ASHL_UNPARSED_ARGUMENTS}
DEPENDS ${gyb_generated_targets})
if(ASHL_FORCE_BUILD_OPTIMIZED)
target_compile_options(${name} PRIVATE "-O2")
endif()
translate_flags(ASHL "${options}")

if(NOT ASHL_SHARED AND NOT ASHL_STATIC)
message(FATAL_ERROR "Either SHARED or STATIC must be specified")
endif()

_add_swift_library_single(
${name}
${name}
${ASHL_SHARED_keyword}
${ASHL_STATIC_keyword}
${ASHL_SOURCES}
SDK ${SWIFT_HOST_VARIANT_SDK}
ARCHITECTURE ${SWIFT_HOST_VARIANT_ARCH}
DEPENDS ${ASHL_DEPENDS}
LINK_LIBRARIES ${ASHL_LINK_LIBRARIES}
LLVM_COMPONENT_DEPENDS ${ASHL_LLVM_COMPONENT_DEPENDS}
FILE_DEPENDS ${ASHL_FILE_DEPENDS}
C_COMPILE_FLAGS ${ASHL_C_COMPILE_FLAGS}
LINK_FLAGS ${ASHL_LINK_FLAGS}
INTERFACE_LINK_LIBRARIES ${ASHL_INTERFACE_LINK_LIBRARIES}
INSTALL_IN_COMPONENT "dev"
)

swift_install_in_component(dev
TARGETS ${name}
Expand Down
30 changes: 24 additions & 6 deletions lib/AST/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,40 @@ add_swift_host_library(swiftAST STATIC
TypeWalker.cpp
USRGeneration.cpp

LINK_LIBS
LINK_LIBRARIES
swiftMarkup
swiftBasic
swiftSyntax

LINK_COMPONENTS
INTERFACE_LINK_LIBRARIES
# Clang dependencies.
# FIXME: Clang should really export these in some reasonable manner.
clangCodeGen
clangIndex
clangFormat
clangToolingCore
clangFrontendTool
clangFrontend
clangDriver
clangSerialization
clangParse
clangSema
clangAnalysis
clangEdit
clangRewriteFrontend
clangRewrite
clangAST
clangLex
clangAPINotes
clangBasic

LLVM_COMPONENT_DEPENDS
bitreader bitwriter coroutines coverage irreader debuginfoDWARF
profiledata instrumentation object objcarcopts mc mcparser
bitreader bitwriter lto ipo option core support ${LLVM_TARGETS_TO_BUILD}

${EXTRA_AST_FLAGS}
)
target_link_libraries(swiftAST
INTERFACE
clangTooling
clangFrontendTool)

# intrinsics_gen is the LLVM tablegen target that generates the include files
# where intrinsics and attributes are declared. swiftAST depends on these
Expand Down
4 changes: 2 additions & 2 deletions lib/ASTSectionImporter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_swift_host_library(swiftASTSectionImporter STATIC
ASTSectionImporter.cpp
LINK_LIBS swiftBasic
LINK_COMPONENTS core)
LINK_LIBRARIES swiftBasic
LLVM_COMPONENT_DEPENDS core)

16 changes: 8 additions & 8 deletions lib/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@

# On non-Darwin require UUID.
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(UUID_INCLUDE "")
set(UUID_LIBRARIES "")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(UUID_INCLUDE "")
set(UUID_LIBRARIES "rpcrt4.lib")
else()
find_package(UUID REQUIRED)
set(UUID_INCLUDE "-I${UUID_INCLUDE_DIRS}")
endif()

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

GYB_SOURCES
UnicodeExtendedGraphemeClusters.cpp.gyb
LINK_LIBS
UnicodeExtendedGraphemeClusters.cpp.gyb

C_COMPILE_FLAGS ${UUID_INCLUDE}
LINK_LIBRARIES
swiftDemangling
${UUID_LIBRARIES}
LINK_COMPONENTS
support)
target_include_directories(swiftBasic
PRIVATE
${UUID_INCLUDE_DIRS})
LLVM_COMPONENT_DEPENDS support)

message(STATUS "Swift version: ${SWIFT_VERSION}")
message(STATUS "Swift vendor: ${SWIFT_VENDOR}")
Expand Down
2 changes: 1 addition & 1 deletion lib/ClangImporter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ add_swift_host_library(swiftClangImporter STATIC
ImportName.cpp
ImportType.cpp
SwiftLookupTable.cpp
LINK_LIBS
LINK_LIBRARIES
swiftAST
swiftParse
)
Expand Down
7 changes: 3 additions & 4 deletions lib/Demangling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ add_swift_host_library(swiftDemangling
OldRemangler.cpp
Punycode.cpp
Remangler.cpp
TypeDecoder.cpp)
target_compile_definitions(swiftDemangling
PRIVATE
LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1)
TypeDecoder.cpp
C_COMPILE_FLAGS
-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1)

3 changes: 1 addition & 2 deletions lib/Driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ set(swiftDriver_targetDefines)
add_swift_host_library(swiftDriver STATIC
${swiftDriver_sources}
DEPENDS SwiftOptions
LINK_LIBS
swiftAST swiftBasic swiftOption)
LINK_LIBRARIES swiftAST swiftBasic swiftOption)

# Generate the static-stdlib-args.lnk file used by -static-stdlib option
# for 'GenericUnix' (eg linux)
Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ add_swift_host_library(swiftFrontend STATIC
SerializedDiagnosticConsumer.cpp
DEPENDS
SwiftOptions
LINK_LIBS
LINK_LIBRARIES
swiftSIL
swiftMigrator
swiftOption
Expand Down
2 changes: 1 addition & 1 deletion lib/FrontendTool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ add_swift_host_library(swiftFrontendTool STATIC
TBD.cpp
DEPENDS
swift-syntax-generated-headers SwiftOptions
LINK_LIBS
LINK_LIBRARIES
swiftIndex
swiftIDE
swiftTBDGen swiftIRGen swiftSIL swiftSILGen swiftSILOptimizer
Expand Down
2 changes: 1 addition & 1 deletion lib/IDE/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ add_swift_host_library(swiftIDE STATIC
IDETypeChecking.cpp
APIDigesterData.cpp
SourceEntityWalker.cpp
LINK_LIBS
LINK_LIBRARIES
swiftFrontend
swiftClangImporter
swiftParse
Expand Down
2 changes: 1 addition & 1 deletion lib/IRGen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ add_swift_host_library(swiftIRGen STATIC
SwiftTargetInfo.cpp
TypeLayoutDumper.cpp
TypeLayoutVerifier.cpp
LINK_LIBS
LINK_LIBRARIES
swiftAST
swiftLLVMPasses
swiftSIL
Expand Down
4 changes: 2 additions & 2 deletions lib/Immediate/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
add_swift_host_library(swiftImmediate STATIC
Immediate.cpp
REPL.cpp
LINK_LIBS
LINK_LIBRARIES
swiftIDE
swiftFrontend
swiftSILGen
swiftSILOptimizer
swiftIRGen
LINK_COMPONENTS
LLVM_COMPONENT_DEPENDS
linker mcjit)

2 changes: 1 addition & 1 deletion lib/Index/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ add_swift_host_library(swiftIndex STATIC
IndexDataConsumer.cpp
IndexRecord.cpp
IndexSymbol.cpp
LINK_LIBS
LINK_LIBRARIES
swiftAST)
4 changes: 2 additions & 2 deletions lib/LLVMPasses/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ add_swift_host_library(swiftLLVMPasses STATIC
LLVMInlineTree.cpp
LLVMMergeFunctions.cpp

LINK_COMPONENTS
analysis
LLVM_COMPONENT_DEPENDS
analysis
)

3 changes: 2 additions & 1 deletion lib/Markup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ add_swift_host_library(swiftMarkup STATIC
AST.cpp
LineList.cpp
Markup.cpp
LINK_LIBS

LINK_LIBRARIES
libcmark_static)
target_compile_definitions(swiftMarkup
PRIVATE
Expand Down
3 changes: 1 addition & 2 deletions lib/Migrator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ add_swift_host_library(swiftMigrator STATIC
Migrator.cpp
MigrationState.cpp
RewriteBufferEditsReceiver.cpp
LINK_LIBS
swiftSyntax swiftIDE)
LINK_LIBRARIES swiftSyntax swiftIDE)

add_dependencies(swiftMigrator
"symlink_migrator_data")
4 changes: 2 additions & 2 deletions lib/Option/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ add_swift_host_library(swiftOption STATIC
Options.cpp
SanitizerOptions.cpp
DEPENDS SwiftOptions
LINK_LIBS
swiftBasic)
LINK_LIBRARIES swiftBasic
FILE_DEPENDS SwiftOptions)

2 changes: 1 addition & 1 deletion lib/Parse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ add_swift_host_library(swiftParse STATIC
Scope.cpp
SyntaxParsingCache.cpp
SyntaxParsingContext.cpp
LINK_LIBS
LINK_LIBRARIES
swiftAST
swiftSyntax
)
Expand Down
2 changes: 1 addition & 1 deletion lib/ParseSIL/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_swift_host_library(swiftParseSIL STATIC
ParseSIL.cpp
LINK_LIBS
LINK_LIBRARIES
swiftParse
swiftSema
swiftSIL
Expand Down
2 changes: 1 addition & 1 deletion lib/PrintAsObjC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_swift_host_library(swiftPrintAsObjC STATIC
PrintAsObjC.cpp
LINK_LIBS
LINK_LIBRARIES
swiftIDE
swiftFrontend
swiftClangImporter
Expand Down
2 changes: 1 addition & 1 deletion lib/RemoteAST/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ add_swift_host_library(swiftRemoteAST STATIC
RemoteAST.cpp
InProcessMemoryReader.cpp
${REMOTE_LIB_HEADERS}
LINK_LIBS
LINK_LIBRARIES
swiftSema swiftIRGen)
2 changes: 1 addition & 1 deletion lib/SIL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ add_swift_host_library(swiftSIL STATIC
SILWitnessTable.cpp
TypeLowering.cpp
ValueOwnership.cpp
LINK_LIBS
LINK_LIBRARIES
swiftSerialization
swiftSema
)
Expand Down
2 changes: 1 addition & 1 deletion lib/SILGen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ add_swift_host_library(swiftSILGen STATIC
SILGenStmt.cpp
SILGenThunk.cpp
SILGenType.cpp
LINK_LIBS
LINK_LIBRARIES
swiftSIL
)
3 changes: 1 addition & 2 deletions lib/SILOptimizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ add_subdirectory(Utils)

add_swift_host_library(swiftSILOptimizer STATIC
${SILOPTIMIZER_SOURCES}
LINK_LIBS
swiftSIL)
LINK_LIBRARIES swiftSIL)
2 changes: 1 addition & 1 deletion lib/Sema/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ add_swift_host_library(swiftSema STATIC
TypeCheckSwitchStmt.cpp
TypeCheckType.cpp
TypeChecker.cpp
LINK_LIBS
LINK_LIBRARIES
swiftParse
swiftAST
swiftSerialization
Expand Down
Loading