Skip to content

Commit 8b279c9

Browse files
committed
build: introduce a CMake based build
This enables building DocC as a CMake project. Doing so is motivated by toolchain build times. By using CMake instead of SPM, we see an overall reduction of ~7% in the total toolchain build time on Windows.
1 parent 3fc0c68 commit 8b279c9

File tree

5 files changed

+159
-0
lines changed

5 files changed

+159
-0
lines changed

CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#[[
2+
This source file is part of the Swift open source project
3+
4+
Copyright © 2014 - 2025 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See https://swift.org/LICENSE.txt for license information
8+
]]
9+
10+
cmake_minimum_required(VERSION 3.24)
11+
12+
project(SymbolKit
13+
LANGUAGES Swift)
14+
15+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
16+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
17+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
18+
19+
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
20+
set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
21+
22+
add_subdirectory(Sources)
23+
add_subdirectory(cmake/modules)

Sources/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#[[
2+
This source file is part of the Swift open source project
3+
4+
Copyright © 2014 - 2025 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See https://swift.org/LICENSE.txt for license information
8+
]]
9+
10+
add_subdirectory(SymbolKit)

Sources/SymbolKit/CMakeLists.txt

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#[[
2+
This source file is part of the Swift open source project
3+
4+
Copyright © 2014 - 2025 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See https://swift.org/LICENSE.txt for license information
8+
]]
9+
10+
add_library(SymbolKit
11+
Package.swift
12+
Sources/SymbolKit/Mixin/Mixin+Equals.swift
13+
Sources/SymbolKit/Mixin/Mixin+Hash.swift
14+
Sources/SymbolKit/Mixin/Mixin.swift
15+
Sources/SymbolKit/SymbolGraph/AnyScalar.swift
16+
Sources/SymbolKit/SymbolGraph/LineList/LineList.swift
17+
Sources/SymbolKit/SymbolGraph/LineList/SourceRange/Position.swift
18+
Sources/SymbolKit/SymbolGraph/LineList/SourceRange/SourceRange.swift
19+
Sources/SymbolKit/SymbolGraph/Metadata.swift
20+
Sources/SymbolKit/SymbolGraph/Module.swift
21+
Sources/SymbolKit/SymbolGraph/OperatingSystem.swift
22+
Sources/SymbolKit/SymbolGraph/Platform.swift
23+
Sources/SymbolKit/SymbolGraph/Relationship/ReferenceLocation.swift
24+
Sources/SymbolKit/SymbolGraph/Relationship/Relationship.swift
25+
Sources/SymbolKit/SymbolGraph/Relationship/RelationshipKind.swift
26+
Sources/SymbolKit/SymbolGraph/Relationship/SourceOrigin.swift
27+
Sources/SymbolKit/SymbolGraph/Relationship/Swift/GenericConstraints.swift
28+
Sources/SymbolKit/SymbolGraph/Relationship/Swift/Swift.swift
29+
Sources/SymbolKit/SymbolGraph/SemanticVersion.swift
30+
Sources/SymbolKit/SymbolGraph/Symbol/AccessControl.swift
31+
Sources/SymbolKit/SymbolGraph/Symbol/AlternateDeclarations.swift
32+
Sources/SymbolKit/SymbolGraph/Symbol/Availability/Availability.swift
33+
Sources/SymbolKit/SymbolGraph/Symbol/Availability/AvailabilityItem.swift
34+
Sources/SymbolKit/SymbolGraph/Symbol/Availability/Domain.swift
35+
Sources/SymbolKit/SymbolGraph/Symbol/DeclarationFragments/DeclarationFragments+Simplify.swift
36+
Sources/SymbolKit/SymbolGraph/Symbol/DeclarationFragments/DeclarationFragments.swift
37+
Sources/SymbolKit/SymbolGraph/Symbol/DeclarationFragments/Fragment/Fragment.swift
38+
Sources/SymbolKit/SymbolGraph/Symbol/DeclarationFragments/Fragment/FragmentKind.swift
39+
Sources/SymbolKit/SymbolGraph/Symbol/FunctionSignature/FunctionParameter.swift
40+
Sources/SymbolKit/SymbolGraph/Symbol/FunctionSignature/FunctionSignature.swift
41+
Sources/SymbolKit/SymbolGraph/Symbol/HTTP/HTTP.swift
42+
Sources/SymbolKit/SymbolGraph/Symbol/Identifier.swift
43+
Sources/SymbolKit/SymbolGraph/Symbol/KindIdentifier.swift
44+
Sources/SymbolKit/SymbolGraph/Symbol/Location.swift
45+
Sources/SymbolKit/SymbolGraph/Symbol/Mutability.swift
46+
Sources/SymbolKit/SymbolGraph/Symbol/Names.swift
47+
Sources/SymbolKit/SymbolGraph/Symbol/OverloadData.swift
48+
Sources/SymbolKit/SymbolGraph/Symbol/PlistDetails.swift
49+
Sources/SymbolKit/SymbolGraph/Symbol/Snippet.swift
50+
Sources/SymbolKit/SymbolGraph/Symbol/SPI.swift
51+
Sources/SymbolKit/SymbolGraph/Symbol/Swift/Extension.swift
52+
Sources/SymbolKit/SymbolGraph/Symbol/Swift/GenericConstraint.swift
53+
Sources/SymbolKit/SymbolGraph/Symbol/Swift/GenericParameter.swift
54+
Sources/SymbolKit/SymbolGraph/Symbol/Swift/Generics.swift
55+
Sources/SymbolKit/SymbolGraph/Symbol/Swift/Namespace.swift
56+
Sources/SymbolKit/SymbolGraph/Symbol/Symbol.swift
57+
Sources/SymbolKit/SymbolGraph/Symbol/SymbolKind.swift
58+
Sources/SymbolKit/SymbolGraph/Symbol/ValueConstraints.swift
59+
Sources/SymbolKit/SymbolGraph/SymbolGraph+Overloads.swift
60+
Sources/SymbolKit/SymbolGraph/SymbolGraph.swift
61+
Sources/SymbolKit/UnifiedSymbolGraph/GraphCollector.swift
62+
Sources/SymbolKit/UnifiedSymbolGraph/UnifiedSymbol+Encodable.swift
63+
Sources/SymbolKit/UnifiedSymbolGraph/UnifiedSymbol.swift
64+
Sources/SymbolKit/UnifiedSymbolGraph/UnifiedSymbolGraph+Encodable.swift
65+
Sources/SymbolKit/UnifiedSymbolGraph/UnifiedSymbolGraph+Overloads.swift
66+
Sources/SymbolKit/UnifiedSymbolGraph/UnifiedSymbolGraph.swift
67+
Tests/SymbolKitTests/SymbolGraph/AnyScalarTests.swift
68+
Tests/SymbolKitTests/SymbolGraph/LineList/LineListTests.swift
69+
Tests/SymbolKitTests/SymbolGraph/LineList/SemanticVersionTests.swift
70+
Tests/SymbolKitTests/SymbolGraph/ModuleTests.swift
71+
Tests/SymbolKitTests/SymbolGraph/PlatformTests.swift
72+
Tests/SymbolKitTests/SymbolGraph/Relationship/HashableTests.swift
73+
Tests/SymbolKitTests/SymbolGraph/Relationship/ReferenceLocationTests.swift
74+
Tests/SymbolKitTests/SymbolGraph/Symbol/DeclarationFragments+SimplifyTests.swift
75+
Tests/SymbolKitTests/SymbolGraph/Symbol/FunctionSignatureTests.swift
76+
Tests/SymbolKitTests/SymbolGraph/Symbol/HTTPTests.swift
77+
Tests/SymbolKitTests/SymbolGraph/Symbol/PlistDetailsTests.swift
78+
Tests/SymbolKitTests/SymbolGraph/Symbol/Swift/GenericConstraintTests.swift
79+
Tests/SymbolKitTests/SymbolGraph/Symbol/SymbolKindTests.swift
80+
Tests/SymbolKitTests/SymbolGraph/Symbol/ValueConstraintsTests.swift
81+
Tests/SymbolKitTests/SymbolGraph/SymbolGraph+OverloadsTests.swift
82+
Tests/SymbolKitTests/SymbolGraph/SymbolGraphCreationTests.swift
83+
Tests/SymbolKitTests/SymbolGraph/SymbolGraphTests.swift
84+
Tests/SymbolKitTests/SymbolGraph/SymbolTests.swift
85+
Tests/SymbolKitTests/UnifiedGraph/CrossImportOverlaySymbolGraphs.swift
86+
Tests/SymbolKitTests/UnifiedGraph/GraphCollectorTests.swift
87+
Tests/SymbolKitTests/UnifiedGraph/UnifiedGraph+OverloadsTests.swift
88+
Tests/SymbolKitTests/UnifiedGraph/UnifiedGraphTests.swift
89+
Tests/SymbolKitTests/UnifiedGraph/UnifiedSymbolTests.swift
90+
Tools/dump-unified-graph/DumpUnifiedGraph.swift
91+
Tools/Package.swift)
92+
set_target_properties(SymbolKit PROPERTIES
93+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
94+
95+
set_property(GLOBAL APPEND PROPERTY SYMBOLKIT_EXPORTS SymbolKit)

cmake/modules/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#[[
2+
This source file is part of the Swift open source project
3+
4+
Copyright © 2014 - 2025 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See https://swift.org/LICENSE.txt for license information
8+
]]
9+
10+
set(SYMBOLKIT_EXPORTS_FILE
11+
${CMAKE_CURRENT_BINARY_DIR}/SymbolKitExports.cmake)
12+
configure_file(SymbolKitConfig.cmake.in
13+
${CMAKE_CURRENT_BINARY_DIR}/SymbolKitConfig.cmake)
14+
15+
get_property(SYMBOLKIT_EXPORTS GLOBAL PROPERTY SYMBOLKIT_EXPORTS)
16+
export(TARGETS ${SYMBOLKIT_EXPORTS}
17+
NAMESPACE DocC::
18+
FILE ${SYMBOLKIT_EXPORTS_FILE}
19+
EXPORT_LINK_INTERFACE_LIBRARIES)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#[[
2+
This source file is part of the Swift open source project
3+
4+
Copyright © 2014 - 2025 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See https://swift.org/LICENSE.txt for license information
8+
]]
9+
10+
if(NOT TARGET DocC::SymbolKit)
11+
include("@SYMBOLKIT_EXPORTS_FILE@")
12+
endif()

0 commit comments

Comments
 (0)