Skip to content

Commit

Permalink
Revert "Revert "[Build System: CMake] make add_swift_library a wrappe…
Browse files Browse the repository at this point in the history
…r to add_llvm_library""

This reverts commit 103f9a8.
  • Loading branch information
compnerd committed Nov 5, 2018
1 parent c044001 commit 121f5b6
Show file tree
Hide file tree
Showing 29 changed files with 73 additions and 156 deletions.
92 changes: 11 additions & 81 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1319,66 +1319,12 @@ endfunction()
#
# Usage:
# add_swift_host_library(name
# [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.
# [FORCE_BUILD_OPTIMIZED]
# [...]
function(add_swift_host_library name)
set(options
FORCE_BUILD_OPTIMIZED
SHARED
STATIC)
set(options FORCE_BUILD_OPTIMIZED)
set(single_parameter_options)
set(multiple_parameter_options
C_COMPILE_FLAGS
DEPENDS
FILE_DEPENDS
INTERFACE_LINK_LIBRARIES
LINK_FLAGS
LINK_LIBRARIES
LLVM_COMPONENT_DEPENDS)
set(multiple_parameter_options GYB_SOURCES)

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

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

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

LINK_LIBRARIES
LINK_LIBS
swiftMarkup
swiftBasic
swiftSyntax

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
LINK_COMPONENTS
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_LIBRARIES swiftBasic
LLVM_COMPONENT_DEPENDS core)
LINK_LIBS swiftBasic
LINK_COMPONENTS core)

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

# 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 @@ -102,13 +99,16 @@ add_swift_host_library(swiftBasic STATIC
# Platform-agnostic fallback TaskQueue implementation
Default/TaskQueue.inc

UnicodeExtendedGraphemeClusters.cpp.gyb

C_COMPILE_FLAGS ${UUID_INCLUDE}
LINK_LIBRARIES
GYB_SOURCES
UnicodeExtendedGraphemeClusters.cpp.gyb
LINK_LIBS
swiftDemangling
${UUID_LIBRARIES}
LLVM_COMPONENT_DEPENDS support)
LINK_COMPONENTS
support)
target_include_directories(swiftBasic
PRIVATE
${UUID_INCLUDE_DIRS})

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_LIBRARIES
LINK_LIBS
swiftAST
swiftParse
)
Expand Down
7 changes: 4 additions & 3 deletions lib/Demangling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ add_swift_host_library(swiftDemangling
OldRemangler.cpp
Punycode.cpp
Remangler.cpp
TypeDecoder.cpp
C_COMPILE_FLAGS
-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1)
TypeDecoder.cpp)
target_compile_definitions(swiftDemangling
PRIVATE
LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1)

3 changes: 2 additions & 1 deletion lib/Driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ set(swiftDriver_targetDefines)
add_swift_host_library(swiftDriver STATIC
${swiftDriver_sources}
DEPENDS SwiftOptions
LINK_LIBRARIES swiftAST swiftBasic swiftOption)
LINK_LIBS
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_LIBRARIES
LINK_LIBS
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_LIBRARIES
LINK_LIBS
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_LIBRARIES
LINK_LIBS
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_LIBRARIES
LINK_LIBS
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_LIBRARIES
LINK_LIBS
swiftIDE
swiftFrontend
swiftSILGen
swiftSILOptimizer
swiftIRGen
LLVM_COMPONENT_DEPENDS
LINK_COMPONENTS
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_LIBRARIES
LINK_LIBS
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

LLVM_COMPONENT_DEPENDS
analysis
LINK_COMPONENTS
analysis
)

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

LINK_LIBRARIES
LINK_LIBS
libcmark_static)
target_compile_definitions(swiftMarkup
PRIVATE
Expand Down
3 changes: 2 additions & 1 deletion lib/Migrator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ add_swift_host_library(swiftMigrator STATIC
Migrator.cpp
MigrationState.cpp
RewriteBufferEditsReceiver.cpp
LINK_LIBRARIES swiftSyntax swiftIDE)
LINK_LIBS
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_LIBRARIES swiftBasic
FILE_DEPENDS SwiftOptions)
LINK_LIBS
swiftBasic)

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_LIBRARIES
LINK_LIBS
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_LIBRARIES
LINK_LIBS
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_LIBRARIES
LINK_LIBS
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_LIBRARIES
LINK_LIBS
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_LIBRARIES
LINK_LIBS
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_LIBRARIES
LINK_LIBS
swiftSIL
)
3 changes: 2 additions & 1 deletion lib/SILOptimizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ add_subdirectory(Utils)

add_swift_host_library(swiftSILOptimizer STATIC
${SILOPTIMIZER_SOURCES}
LINK_LIBRARIES swiftSIL)
LINK_LIBS
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_LIBRARIES
LINK_LIBS
swiftParse
swiftAST
swiftSerialization
Expand Down
Loading

0 comments on commit 121f5b6

Please sign in to comment.