Skip to content

Commit 294c79d

Browse files
authored
Merge branch 'main' into create-target-for-common-code
2 parents b413e1d + b816349 commit 294c79d

File tree

13 files changed

+743
-43
lines changed

13 files changed

+743
-43
lines changed

CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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(SwiftDocC
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+
set(CMAKE_Swift_LANGUAGE_VERSION 5)
22+
23+
enable_language(C)
24+
include(GNUInstallDirs)
25+
26+
# NOTE(compnerd) workaround CMake issues
27+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-swift-version 5>")
28+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature ConciseMagicFile>")
29+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature ExistentialAny>")
30+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature InternalImportsByDefault>")
31+
32+
find_package(ArgumentParser)
33+
find_package(SwiftASN1)
34+
find_package(SwiftCrypto)
35+
find_package(SwiftMarkdown)
36+
find_package(LMDB)
37+
find_package(SymbolKit)
38+
find_package(cmark-gfm)
39+
40+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:-package-name;SwiftDocC>")
41+
42+
add_subdirectory(Sources)

CONTRIBUTING.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,32 @@ by running the test suite in a Docker environment that simulates Swift on Linux.
350350
cd swift-docc
351351
swift run docc
352352
```
353-
353+
354+
## Updating Build Rules
355+
356+
In order to build DocC as part of the Windows toolchain distribution uniformly,
357+
a parallel CMake based build exists. Note that this is **not** supported for
358+
development purposes (you cannot execute the test suite with this build).
359+
360+
CMake requires that the full file list is kept up-to-date. When adding or
361+
removing files in a given module, the `CMakeLists.txt` list must be updated to
362+
the file list.
363+
364+
The 1-line script below lists all the Swift files in the current directory tree.
365+
You can use the script's output to replace the list of files in the CMakeLists.txt file for each target that you added files to or removed files from.
366+
367+
```bash
368+
python -c "print('\n'.join((f'{chr(34)}{path}{chr(34)}' if ' ' in path else path) for path in sorted(str(path) for path in __import__('pathlib').Path('.').rglob('*.swift'))))"
369+
```
370+
371+
This should provide the listing of files in the module that can be used to
372+
update the `CMakeLists.txt` associated with the target.
373+
374+
In the case that a new target is added to the project, the new directory would
375+
need to add the new library or executable target (`add_library` and
376+
`add_executable` respectively) and the new target subdirectory must be listed in
377+
the `Sources/CMakeLists.txt` (via `add_subdirectory`).
378+
354379
## Continuous Integration
355380

356381
Swift-DocC uses [swift-ci](https://ci.swift.org) infrastructure for its continuous integration

Package.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ let package = Package(
4949
.product(name: "CLMDB", package: "swift-lmdb"),
5050
.product(name: "Crypto", package: "swift-crypto"),
5151
],
52+
exclude: ["CMakeLists.txt"],
5253
swiftSettings: swiftSettings
5354
),
5455
.testTarget(
@@ -75,6 +76,7 @@ let package = Package(
7576
.product(name: "NIOHTTP1", package: "swift-nio", condition: .when(platforms: [.macOS, .iOS, .linux, .android])),
7677
.product(name: "ArgumentParser", package: "swift-argument-parser")
7778
],
79+
exclude: ["CMakeLists.txt"],
7880
swiftSettings: swiftSettings
7981
),
8082
.testTarget(
@@ -109,6 +111,7 @@ let package = Package(
109111
dependencies: [
110112
.target(name: "SwiftDocCUtilities"),
111113
],
114+
exclude: ["CMakeLists.txt"],
112115
swiftSettings: swiftSettings
113116
),
114117

@@ -149,7 +152,6 @@ let package = Package(
149152
],
150153
swiftSettings: swiftSettings
151154
),
152-
153155
]
154156
)
155157

Sources/CMakeLists.txt

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+
add_subdirectory(SwiftDocC)
11+
add_subdirectory(SwiftDocCUtilities)
12+
add_subdirectory(docc)

0 commit comments

Comments
 (0)