Skip to content

Commit b9eb417

Browse files
authored
build: add a CMake based build for Windows (#44)
Since swift-package-manager doesn't work on Windows yet, add a CMake based build system.
1 parent 49edf19 commit b9eb417

File tree

12 files changed

+131
-0
lines changed

12 files changed

+131
-0
lines changed

CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
cmake_minimum_required(VERSION 3.16.0)
2+
3+
project(swift-argument-parser
4+
LANGUAGES Swift)
5+
6+
option(BUILD_EXAMPLES "Build Example Programs" TRUE)
7+
8+
include(CTest)
9+
10+
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
11+
12+
find_package(Foundation QUIET)
13+
find_package(XCTest QUIET)
14+
15+
add_subdirectory(Sources)
16+
if(BUILD_EXAMPLES)
17+
add_subdirectory(Examples)
18+
endif()
19+
if(BUILD_TESTING)
20+
add_subdirectory(Tests)
21+
endif()
22+
23+
export(TARGETS ArgumentParser
24+
FILE swift-argument-parser-config.cmake)

Examples/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
add_subdirectory(math)
2+
add_subdirectory(repeat)
3+
add_subdirectory(roll)

Examples/math/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
add_executable(math
2+
main.swift)
3+
target_link_libraries(math PRIVATE
4+
ArgumentParser)

Examples/repeat/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
add_executable(repeat
2+
main.swift)
3+
target_link_libraries(repeat PRIVATE
4+
ArgumentParser)

Examples/roll/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
add_executable(roll
2+
main.swift
3+
SplitMix64.swift)
4+
target_link_libraries(roll PRIVATE
5+
ArgumentParser)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
add_library(ArgumentParser
2+
"Parsable Properties/Argument.swift"
3+
"Parsable Properties/ArgumentHelp.swift"
4+
"Parsable Properties/Flag.swift"
5+
"Parsable Properties/NameSpecification.swift"
6+
"Parsable Properties/Option.swift"
7+
"Parsable Properties/OptionGroup.swift"
8+
"Parsable Properties/ValidationError.swift"
9+
10+
"Parsable Types/CommandConfiguration.swift"
11+
"Parsable Types/ExpressibleByArgument.swift"
12+
"Parsable Types/ParsableArguments.swift"
13+
"Parsable Types/ParsableCommand.swift"
14+
15+
Parsing/ArgumentDecoder.swift
16+
Parsing/ArgumentDefinition.swift
17+
Parsing/ArgumentSet.swift
18+
Parsing/ArgumentSetSequence.swift
19+
Parsing/CommandParser.swift
20+
Parsing/InputOrigin.swift
21+
Parsing/Name.swift
22+
Parsing/Parsed.swift
23+
Parsing/ParsedValues.swift
24+
Parsing/ParserError.swift
25+
Parsing/SplitArguments.swift
26+
27+
Usage/HelpCommand.swift
28+
Usage/HelpGenerator.swift
29+
Usage/MessageInfo.swift
30+
Usage/UsageGenerator.swift
31+
32+
Utilities/StringExtensions.swift
33+
Utilities/Tree.swift)
34+
set_target_properties(ArgumentParser PROPERTIES
35+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
36+
target_compile_options(ArgumentParser PRIVATE
37+
$<$<BOOL:${BUILD_TESTING}>:-enable-testing>)
38+
target_link_libraries(ArgumentParser PRIVATE
39+
Foundation)

Sources/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
add_subdirectory(ArgumentParser)
2+
if(BUILD_TESTING)
3+
add_subdirectory(TestHelpers)
4+
endif()

Sources/TestHelpers/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
add_library(TestHelpers
2+
StringHelpers.swift
3+
TestHelpers.swift)
4+
set_target_properties(TestHelpers PROPERTIES
5+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
6+
target_link_libraries(TestHelpers PUBLIC
7+
ArgumentParser
8+
XCTest)

Tests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
add_subdirectory(EndToEndTests)
2+
add_subdirectory(UnitTests)

Tests/EndToEndTests/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
add_library(EndToEndTests
2+
CustomParsingEndToEndTests.swift
3+
DefaultsEndToEndTests.swift
4+
EnumEndToEndTests.swift
5+
FlagsEndToEndTests.swift
6+
LongNameWithShortDashEndToEndTests.swift
7+
NestedCommandEndToEndTests.swift
8+
OptionalEndToEndTests.swift
9+
OptionGroupEndToEndTests.swift
10+
PositionalEndToEndTests.swift
11+
RawRepresentableEndToEndTests.swift
12+
RepeatingEndToEndTests.swift
13+
ShortNameEndToEndTests.swift
14+
SimpleEndToEndTests.swift
15+
SingleValueParsingStrategyTests.swift
16+
SubcommandEndToEndTests.swift
17+
ValidationEndToEndTests.swift)
18+
target_link_libraries(EndToEndTests PUBLIC
19+
TestHelpers)

0 commit comments

Comments
 (0)