Skip to content

Commit d0bfb60

Browse files
committed
build: add a CMake based build
This is meant to support building swift-markdown for re-use in the toolchain build. It does not follow best practices (opting for a single file approach rather than a CMakeLists.txt per directory) and currently needs some refinement for integrating an existing CMark build, but provides the skeleton for further experimentation.
1 parent c211079 commit d0bfb60

File tree

5 files changed

+169
-0
lines changed

5 files changed

+169
-0
lines changed

CMakeLists.txt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#[[
2+
This source file is part of the Swift System open source project
3+
4+
Copyright (c) 2020 Apple Inc. and the Swift System 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.19.0)
11+
12+
if(POLICY CMP0077)
13+
cmake_policy(SET CMP0077 NEW)
14+
endif()
15+
16+
if(POLICY CMP0091)
17+
cmake_policy(SET CMP0091 NEW)
18+
endif()
19+
20+
project(SwiftMarkdown
21+
LANGUAGES C Swift)
22+
23+
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
24+
25+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
26+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
27+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
28+
29+
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
30+
set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
31+
32+
include(FetchContent)
33+
34+
set(_SM_VENDOR_DEPENDENCIES)
35+
36+
set(BUILD_EXAMPLES NO)
37+
set(BUILD_TESTING NO)
38+
39+
find_package(ArgumentParser CONFIG)
40+
if(NOT ArgumentParser_FOUND)
41+
FetchContent_Declare(ArgumentParser
42+
GIT_REPOSITORY https://github.com/apple/swift-argument-parser
43+
GIT_TAG 1.2.3)
44+
list(APPEND _SM_VENDOR_DEPENDENCIES ArgumentParser)
45+
endif()
46+
47+
find_package(cmark-gfm CONFIG)
48+
if(NOT cmark-gfm_FOUND)
49+
FetchContent_Declare(cmark-gfm
50+
GIT_REPOSITORY https://github.com/apple/swift-cmark
51+
GIT_TAG gfm)
52+
list(APPEND _SM_VENDOR_DEPENDENCIES cmark-gfm)
53+
endif()
54+
55+
if(_SM_VENDOR_DEPENDENCIES)
56+
FetchContent_MakeAvailable(${_SM_VENDOR_DEPENDENCIES})
57+
endif()
58+
59+
add_subdirectory(Sources)
60+

Sources/CAtomic/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#[[
2+
This source file is part of the Swift System open source project
3+
4+
Copyright (c) 2020 Apple Inc. and the Swift System 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(CAtomic STATIC
11+
CAtomic.c)
12+
target_include_directories(CAtomic PUBLIC
13+
include)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module CAtomic {
2+
header "CAtomic.h"
3+
export *
4+
}

Sources/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#[[
2+
This source file is part of the Swift System open source project
3+
4+
Copyright (c) 2020 Apple Inc. and the Swift System 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(CAtomic)
11+
add_subdirectory(Markdown)

Sources/Markdown/CMakeLists.txt

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#[[
2+
This source file is part of the Swift System open source project
3+
4+
Copyright (c) 2020 Apple Inc. and the Swift System 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(Markdown
11+
Base/ChildIndexPath.swift
12+
Base/DirectiveArgument.swift
13+
Base/Document.swift
14+
Base/LiteralMarkup.swift
15+
Base/Markup.swift
16+
Base/MarkupChildren.swift
17+
Base/MarkupData.swift
18+
Base/PlainTextConvertibleMarkup.swift
19+
Base/RawMarkup.swift
20+
"Block Nodes/Block Container Blocks/Doxygen Commands/DoxygenParameter.swift"
21+
"Block Nodes/Block Container Blocks/Doxygen Commands/DoxygenReturns.swift"
22+
"Block Nodes/Block Container Blocks/BlockDirective.swift"
23+
"Block Nodes/Block Container Blocks/BlockQuote.swift"
24+
"Block Nodes/Block Container Blocks/CustomBlock.swift"
25+
"Block Nodes/Block Container Blocks/ListItem.swift"
26+
"Block Nodes/Block Container Blocks/OrderedList.swift"
27+
"Block Nodes/Block Container Blocks/UnorderedList.swift"
28+
"Block Nodes/Inline Container Blocks/Paragraph.swift"
29+
"Block Nodes/Leaf Blocks/CodeBlock.swift"
30+
"Block Nodes/Leaf Blocks/Heading.swift"
31+
"Block Nodes/Leaf Blocks/HTMLBlock.swift"
32+
"Block Nodes/Leaf Blocks/ThematicBreak.swift"
33+
"Block Nodes/Tables/Table.swift"
34+
"Block Nodes/Tables/TableBody.swift"
35+
"Block Nodes/Tables/TableCell.swift"
36+
"Block Nodes/Tables/TableCellContainer.swift"
37+
"Block Nodes/Tables/TableHead.swift"
38+
"Block Nodes/Tables/TableRow.swift"
39+
Infrastructure/Replacement.swift
40+
Infrastructure/SourceLocation.swift
41+
"Inline Nodes/Inline Containers/Emphasis.swift"
42+
"Inline Nodes/Inline Containers/Image.swift"
43+
"Inline Nodes/Inline Containers/InlineAttributes.swift"
44+
"Inline Nodes/Inline Containers/Link.swift"
45+
"Inline Nodes/Inline Containers/Strikethrough.swift"
46+
"Inline Nodes/Inline Containers/Strong.swift"
47+
"Inline Nodes/Inline Leaves/CustomInline.swift"
48+
"Inline Nodes/Inline Leaves/InlineCode.swift"
49+
"Inline Nodes/Inline Leaves/InlineHTML.swift"
50+
"Inline Nodes/Inline Leaves/LineBreak.swift"
51+
"Inline Nodes/Inline Leaves/SoftBreak.swift"
52+
"Inline Nodes/Inline Leaves/SymbolLink.swift"
53+
"Inline Nodes/Inline Leaves/Text.swift"
54+
"Interpretive Nodes/Aside.swift"
55+
Parser/BlockDirectiveParser.swift
56+
Parser/CommonMarkConverter.swift
57+
Parser/LazySplitLines.swift
58+
Parser/ParseOptions.swift
59+
Parser/RangeAdjuster.swift
60+
Parser/RangerTracker.swift
61+
Rewriter/MarkupRewriter.swift
62+
"Structural Restrictions/BasicBlockContainer.swift"
63+
"Structural Restrictions/BasicInlineContainer.swift"
64+
"Structural Restrictions/BlockContainer.swift"
65+
"Structural Restrictions/BlockMarkup.swift"
66+
"Structural Restrictions/InlineContainer.swift"
67+
"Structural Restrictions/InlineMarkup.swift"
68+
"Structural Restrictions/ListItemContainer.swift"
69+
Utility/AtomicCounter.swift
70+
Utility/CharacterExtensions.swift
71+
Utility/CollectionExtensions.swift
72+
Utility/StringExtensions.swift
73+
Visitor/MarkupVisitor.swift
74+
Walker/MarkupWalker.swift
75+
Walker/Walkers/MarkupFormatter.swift
76+
Walker/Walkers/MarkupTreeDumper.swift)
77+
target_link_libraries(Markdown PRIVATE
78+
ArgumentParser
79+
libcmark-gfm
80+
libcmark-gfm-extensions
81+
CAtomic)

0 commit comments

Comments
 (0)