Skip to content

Commit c3eb369

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 4c245d4 commit c3eb369

File tree

5 files changed

+133
-0
lines changed

5 files changed

+133
-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 DocC open source project
3+
4+
Copyright (c) 2024 Apple Inc. and the DocC 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 DocC open source project
3+
4+
Copyright (c) 2024 Apple Inc. and the DocC 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: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#[[
2+
This source file is part of the DocC open source project
3+
4+
Copyright (c) 2024 Apple Inc. and the DocC 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+
Mixin/Mixin+Equals.swift
12+
Mixin/Mixin+Hash.swift
13+
Mixin/Mixin.swift
14+
SymbolGraph/AnyScalar.swift
15+
SymbolGraph/LineList/LineList.swift
16+
SymbolGraph/LineList/SourceRange/Position.swift
17+
SymbolGraph/LineList/SourceRange/SourceRange.swift
18+
SymbolGraph/Metadata.swift
19+
SymbolGraph/Module.swift
20+
SymbolGraph/OperatingSystem.swift
21+
SymbolGraph/Platform.swift
22+
SymbolGraph/Relationship/ReferenceLocation.swift
23+
SymbolGraph/Relationship/Relationship.swift
24+
SymbolGraph/Relationship/RelationshipKind.swift
25+
SymbolGraph/Relationship/SourceOrigin.swift
26+
SymbolGraph/Relationship/Swift/GenericConstraints.swift
27+
SymbolGraph/Relationship/Swift/Swift.swift
28+
SymbolGraph/SemanticVersion.swift
29+
SymbolGraph/Symbol/AccessControl.swift
30+
SymbolGraph/Symbol/AlternateDeclarations.swift
31+
SymbolGraph/Symbol/Availability/Availability.swift
32+
SymbolGraph/Symbol/Availability/AvailabilityItem.swift
33+
SymbolGraph/Symbol/Availability/Domain.swift
34+
SymbolGraph/Symbol/DeclarationFragments/DeclarationFragments+Simplify.swift
35+
SymbolGraph/Symbol/DeclarationFragments/DeclarationFragments.swift
36+
SymbolGraph/Symbol/DeclarationFragments/Fragment/Fragment.swift
37+
SymbolGraph/Symbol/DeclarationFragments/Fragment/FragmentKind.swift
38+
SymbolGraph/Symbol/FunctionSignature/FunctionParameter.swift
39+
SymbolGraph/Symbol/FunctionSignature/FunctionSignature.swift
40+
SymbolGraph/Symbol/HTTP/HTTP.swift
41+
SymbolGraph/Symbol/Identifier.swift
42+
SymbolGraph/Symbol/KindIdentifier.swift
43+
SymbolGraph/Symbol/Location.swift
44+
SymbolGraph/Symbol/Mutability.swift
45+
SymbolGraph/Symbol/Names.swift
46+
SymbolGraph/Symbol/OverloadData.swift
47+
SymbolGraph/Symbol/PlistDetails.swift
48+
SymbolGraph/Symbol/Snippet.swift
49+
SymbolGraph/Symbol/SPI.swift
50+
SymbolGraph/Symbol/Swift/Extension.swift
51+
SymbolGraph/Symbol/Swift/GenericConstraint.swift
52+
SymbolGraph/Symbol/Swift/GenericParameter.swift
53+
SymbolGraph/Symbol/Swift/Generics.swift
54+
SymbolGraph/Symbol/Swift/Namespace.swift
55+
SymbolGraph/Symbol/Symbol.swift
56+
SymbolGraph/Symbol/SymbolKind.swift
57+
SymbolGraph/Symbol/ValueConstraints.swift
58+
SymbolGraph/SymbolGraph+Overloads.swift
59+
SymbolGraph/SymbolGraph.swift
60+
UnifiedSymbolGraph/GraphCollector.swift
61+
UnifiedSymbolGraph/UnifiedSymbol+Encodable.swift
62+
UnifiedSymbolGraph/UnifiedSymbol.swift
63+
UnifiedSymbolGraph/UnifiedSymbolGraph+Encodable.swift
64+
UnifiedSymbolGraph/UnifiedSymbolGraph+Overloads.swift
65+
UnifiedSymbolGraph/UnifiedSymbolGraph.swift)
66+
set_target_properties(SymbolKit PROPERTIES
67+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
68+
69+
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 DocC open source project
3+
4+
Copyright (c) 2024 Apple Inc. and the DocC 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 DocC open source project
3+
4+
Copyright (c) 2024 Apple Inc. and the DocC 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)