Skip to content

Commit 8ac6d59

Browse files
committed
[CMake] Introduce add_swift_host_library and use it for all libraries.
There was a lot of CMake code repeated across the various libraries. Consolidate that into a new `add_swift_host_library` and use it throughout.
1 parent a566bcc commit 8ac6d59

File tree

12 files changed

+41
-136
lines changed

12 files changed

+41
-136
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
2323

2424
set(CMAKE_MACOSX_RPATH YES)
2525

26+
include(AddSwiftHostLibrary)
27+
2628
# Ensure that we do not link the _StringProcessing module. But we can
2729
# only pass this flag for new-enough compilers that support it.
2830
file(WRITE "${CMAKE_BINARY_DIR}/tmp/empty-check-string-processing.swift" "")

Sources/IDEUtils/CMakeLists.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,11 @@
66
# See http://swift.org/LICENSE.txt for license information
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9-
add_library(IDEUtils
9+
add_swift_host_library(IDEUtils
1010
gyb_generated/SyntaxClassification.swift
1111
Syntax+Classifications.swift
1212
SyntaxClassifier.swift
1313
)
1414

1515
target_link_libraries(IDEUtils PUBLIC
1616
SwiftSyntax)
17-
18-
set_property(GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS IDEUtils)
19-
20-
# NOTE: workaround for CMake not setting up include flags yet
21-
set_target_properties(IDEUtils PROPERTIES
22-
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
23-
24-
install(TARGETS IDEUtils
25-
EXPORT SwiftSyntaxTargets
26-
ARCHIVE DESTINATION lib
27-
LIBRARY DESTINATION lib
28-
RUNTIME DESTINATION bin)

Sources/SwiftBasicFormat/CMakeLists.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,11 @@
66
# See http://swift.org/LICENSE.txt for license information
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9-
add_library(SwiftBasicFormat
9+
add_swift_host_library(SwiftBasicFormat
1010
generated/BasicFormat.swift
1111
SyntaxProtocol+Formatted.swift
1212
Trivia+Indented.swift
1313
)
1414

1515
target_link_libraries(SwiftBasicFormat PUBLIC
1616
SwiftSyntax)
17-
18-
set_property(GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS SwiftBasicFormat)
19-
20-
# NOTE: workaround for CMake not setting up include flags yet
21-
set_target_properties(SwiftBasicFormat PROPERTIES
22-
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
23-
24-
install(TARGETS SwiftBasicFormat
25-
EXPORT SwiftSyntaxTargets
26-
ARCHIVE DESTINATION lib
27-
LIBRARY DESTINATION lib
28-
RUNTIME DESTINATION bin)

Sources/SwiftCompilerSupport/CMakeLists.txt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# See http://swift.org/LICENSE.txt for license information
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9-
add_library(SwiftCompilerSupport
9+
add_swift_host_library(SwiftCompilerSupport
1010
ConsistencyCheck.swift
1111
)
1212

@@ -17,16 +17,3 @@ target_link_libraries(SwiftCompilerSupport PUBLIC
1717
SwiftParserDiagnostics
1818
SwiftOperators
1919
)
20-
21-
set_property(GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS SwiftCompilerSupport)
22-
23-
# NOTE: workaround for CMake not setting up include flags yet
24-
set_target_properties(SwiftCompilerSupport PROPERTIES
25-
INTERFACE_INCLUDE_DIRECTORIES
26-
"${CMAKE_Swift_MODULE_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}")
27-
28-
install(TARGETS SwiftCompilerSupport
29-
EXPORT SwiftSyntaxTargets
30-
ARCHIVE DESTINATION lib
31-
LIBRARY DESTINATION lib
32-
RUNTIME DESTINATION bin)

Sources/SwiftDiagnostics/CMakeLists.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# See http://swift.org/LICENSE.txt for license information
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9-
add_library(SwiftDiagnostics
9+
add_swift_host_library(SwiftDiagnostics
1010
Diagnostic.swift
1111
DiagnosticsFormatter.swift
1212
FixIt.swift
@@ -16,15 +16,3 @@ add_library(SwiftDiagnostics
1616

1717
target_link_libraries(SwiftDiagnostics PUBLIC
1818
SwiftSyntax)
19-
20-
set_property(GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS SwiftDiagnostics)
21-
22-
# NOTE: workaround for CMake not setting up include flags yet
23-
set_target_properties(SwiftDiagnostics PROPERTIES
24-
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
25-
26-
install(TARGETS SwiftDiagnostics
27-
EXPORT SwiftSyntaxTargets
28-
ARCHIVE DESTINATION lib
29-
LIBRARY DESTINATION lib
30-
RUNTIME DESTINATION bin)

Sources/SwiftOperators/CMakeLists.txt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# See http://swift.org/LICENSE.txt for license information
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9-
add_library(SwiftOperators
9+
add_swift_host_library(SwiftOperators
1010
Operator.swift
1111
OperatorError+Diagnostics.swift
1212
OperatorError.swift
@@ -23,16 +23,3 @@ target_link_libraries(SwiftOperators PUBLIC
2323
SwiftSyntax
2424
SwiftDiagnostics
2525
SwiftParser)
26-
27-
set_property(GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS SwiftOperators)
28-
29-
# NOTE: workaround for CMake not setting up include flags yet
30-
set_target_properties(SwiftOperators PROPERTIES
31-
INTERFACE_INCLUDE_DIRECTORIES
32-
"${CMAKE_Swift_MODULE_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}")
33-
34-
install(TARGETS SwiftOperators
35-
EXPORT SwiftSyntaxTargets
36-
ARCHIVE DESTINATION lib
37-
LIBRARY DESTINATION lib
38-
RUNTIME DESTINATION bin)

Sources/SwiftParser/CMakeLists.txt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# See http://swift.org/LICENSE.txt for license information
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9-
add_library(SwiftParser
9+
add_swift_host_library(SwiftParser
1010
Attributes.swift
1111
Availability.swift
1212
CharacterInfo.swift
@@ -40,16 +40,3 @@ add_library(SwiftParser
4040
target_link_libraries(SwiftParser PUBLIC
4141
SwiftSyntax
4242
SwiftDiagnostics)
43-
44-
set_property(GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS SwiftParser)
45-
46-
# NOTE: workaround for CMake not setting up include flags yet
47-
set_target_properties(SwiftParser PROPERTIES
48-
INTERFACE_INCLUDE_DIRECTORIES
49-
"${CMAKE_Swift_MODULE_DIRECTORY}")
50-
51-
install(TARGETS SwiftParser
52-
EXPORT SwiftSyntaxTargets
53-
ARCHIVE DESTINATION lib
54-
LIBRARY DESTINATION lib
55-
RUNTIME DESTINATION bin)

Sources/SwiftParserDiagnostics/CMakeLists.txt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# See http://swift.org/LICENSE.txt for license information
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9-
add_library(SwiftParserDiagnostics
9+
add_swift_host_library(SwiftParserDiagnostics
1010
DiagnosticExtensions.swift
1111
MissingNodesError.swift
1212
ParserDiagnosticMessages.swift
@@ -20,16 +20,3 @@ target_link_libraries(SwiftParserDiagnostics PUBLIC
2020
SwiftDiagnostics
2121
SwiftParser
2222
SwiftSyntax)
23-
24-
set_property(GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS SwiftParserDiagnostics)
25-
26-
# NOTE: workaround for CMake not setting up include flags yet
27-
set_target_properties(SwiftParserDiagnostics PROPERTIES
28-
INTERFACE_INCLUDE_DIRECTORIES
29-
"${CMAKE_Swift_MODULE_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}")
30-
31-
install(TARGETS SwiftParserDiagnostics
32-
EXPORT SwiftSyntaxTargets
33-
ARCHIVE DESTINATION lib
34-
LIBRARY DESTINATION lib
35-
RUNTIME DESTINATION bin)

Sources/SwiftSyntax/CMakeLists.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# See http://swift.org/LICENSE.txt for license information
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9-
add_library(SwiftSyntax
9+
add_swift_host_library(SwiftSyntax
1010
AbsolutePosition.swift
1111
BumpPtrAllocator.swift
1212
CommonAncestor.swift
@@ -54,15 +54,3 @@ add_library(SwiftSyntax
5454
gyb_generated/syntax_nodes/SyntaxStmtNodes.swift
5555
gyb_generated/syntax_nodes/SyntaxTypeNodes.swift
5656
)
57-
58-
set_property(GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS SwiftSyntax)
59-
60-
# NOTE: workaround for CMake not setting up include flags yet
61-
set_target_properties(SwiftSyntax PROPERTIES
62-
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
63-
64-
install(TARGETS SwiftSyntax
65-
EXPORT SwiftSyntaxTargets
66-
ARCHIVE DESTINATION lib
67-
LIBRARY DESTINATION lib
68-
RUNTIME DESTINATION bin)

Sources/SwiftSyntaxBuilder/CMakeLists.txt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# See http://swift.org/LICENSE.txt for license information
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9-
add_library(SwiftSyntaxBuilder
9+
add_swift_host_library(SwiftSyntaxBuilder
1010
ConvenienceInitializers.swift
1111
HasTrailingComma.swift
1212
Indenter.swift
@@ -29,16 +29,3 @@ target_link_libraries(SwiftSyntaxBuilder PUBLIC
2929
SwiftParserDiagnostics
3030
SwiftSyntax
3131
)
32-
33-
set_property(GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS SwiftSyntaxBuilder)
34-
35-
# NOTE: workaround for CMake not setting up include flags yet
36-
set_target_properties(SwiftSyntaxBuilder PROPERTIES
37-
INTERFACE_INCLUDE_DIRECTORIES
38-
"${CMAKE_Swift_MODULE_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}")
39-
40-
install(TARGETS SwiftSyntaxBuilder
41-
EXPORT SwiftSyntaxTargets
42-
ARCHIVE DESTINATION lib
43-
LIBRARY DESTINATION lib
44-
RUNTIME DESTINATION bin)

0 commit comments

Comments
 (0)