Skip to content

Commit 110beef

Browse files
Merge pull request #105 from compnerd/cmake
build: add initial CMake based build system
2 parents c634b5d + 697e935 commit 110beef

File tree

12 files changed

+353
-0
lines changed

12 files changed

+353
-0
lines changed

CMakeLists.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#[[
2+
This source file is part of the Swift Numerics open source project
3+
4+
Copyright (c) 2019 Apple Inc. and the Swift Numerics 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.16)
11+
project(swift-numerics
12+
LANGUAGES Swift)
13+
14+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
15+
16+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
17+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
18+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
19+
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
20+
21+
include(CTest)
22+
include(SwiftSupport)
23+
24+
add_subdirectory(Sources)
25+
if(BUILD_TESTING)
26+
add_subdirectory(Tests)
27+
endif()
28+
29+
get_property(SWIFT_NUMERICS_EXPORTS GLOBAL PROPERTY SWIFT_NUMERICS_EXPORTS)
30+
export(TARGETS ${SWIFT_NUMERICS_EXPORTS}
31+
NAMESPACE SwiftNumerics::
32+
FILE swift-numerics-config.cmake
33+
EXPORT_LINK_INTERFACE_LIBRARIES)

Sources/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 Numerics open source project
3+
4+
Copyright (c) 2019 Apple Inc. and the Swift Numerics 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(_NumericsShims)
11+
add_subdirectory(ComplexModule)
12+
add_subdirectory(Numerics)
13+
add_subdirectory(RealModule)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#[[
2+
This source file is part of the Swift Numerics open source project
3+
4+
Copyright (c) 2019 Apple Inc. and the Swift Numerics 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(ComplexModule
11+
Arithmetic.swift
12+
Complex.swift
13+
Differentiable.swift)
14+
set_target_properties(ComplexModule PROPERTIES
15+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
16+
target_link_libraries(ComplexModule PUBLIC
17+
RealModule)
18+
19+
20+
_install_target(ComplexModule)
21+
set_property(GLOBAL APPEND PROPERTY SWIFT_NUMERICS_EXPORTS ComplexModule)

Sources/Numerics/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#[[
2+
This source file is part of the Swift Numerics open source project
3+
4+
Copyright (c) 2019 Apple Inc. and the Swift Numerics 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(Numerics
11+
Numerics.swift)
12+
set_target_properties(Numerics PROPERTIES
13+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
14+
target_link_libraries(Numerics PUBLIC
15+
ComplexModule
16+
RealModule)
17+
18+
19+
_install_target(Numerics)
20+
set_property(GLOBAL APPEND PROPERTY SWIFT_NUMERICS_EXPORTS Numerics)

Sources/RealModule/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#[[
2+
This source file is part of the Swift Numerics open source project
3+
4+
Copyright (c) 2019 Apple Inc. and the Swift Numerics 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(RealModule
11+
AlgebraicField.swift
12+
Double+Real.swift
13+
ElementaryFunctions.swift
14+
Float+Real.swift
15+
Float80+Real.swift
16+
Real.swift
17+
RealFunctions.swift)
18+
set_target_properties(RealModule PROPERTIES
19+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
20+
target_link_libraries(RealModule PUBLIC
21+
_NumericsShims)
22+
23+
24+
_install_target(RealModule)
25+
set_property(GLOBAL APPEND PROPERTY SWIFT_NUMERICS_EXPORTS RealModule)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#[[
2+
This source file is part of the Swift Numerics open source project
3+
4+
Copyright (c) 2019 Apple Inc. and the Swift Numerics 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(_NumericsShims INTERFACE)
11+
target_include_directories(_NumericsShims INTERFACE
12+
include)
13+
14+
set_property(GLOBAL APPEND PROPERTY SWIFT_NUMERICS_EXPORTS _NumericsShims)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module _NumericsShims {
2+
header "_NumericsShims.h"
3+
}

Tests/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#[[
2+
This source file is part of the Swift Numerics open source project
3+
4+
Copyright (c) 2019 Apple Inc. and the Swift Numerics 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+
find_package(dispatch CONFIG QUIET)
11+
find_package(Foundation CONFIG QUIET)
12+
find_package(XCTest CONFIG QUIET)
13+
14+
add_subdirectory(ComplexTests)
15+
add_subdirectory(RealTests)
16+
17+
add_executable(SwiftNumericsTestRunner
18+
WindowsMain.swift)
19+
target_link_libraries(SwiftNumericsTestRunner PRIVATE
20+
ComplexTests
21+
RealTests)
22+
23+
add_test(NAME SwiftNumericsTestRunner
24+
COMMAND SwiftNumericsTestRunner)

Tests/ComplexTests/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#[[
2+
This source file is part of the Swift Numerics open source project
3+
4+
Copyright (c) 2019 Apple Inc. and the Swift Numerics 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(ComplexTests
11+
ArithmeticTests.swift
12+
DifferentiableTests.swift
13+
PropertyTests.swift)
14+
set_target_properties(ComplexTests PROPERTIES
15+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
16+
target_compile_options(ComplexTests PRIVATE
17+
-enable-testing)
18+
target_link_libraries(ComplexTests PUBLIC
19+
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>
20+
ComplexModule
21+
XCTest)

Tests/RealTests/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 Numerics open source project
3+
4+
Copyright (c) 2019 Apple Inc. and the Swift Numerics 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(RealTests
11+
IntegerExponentTests.swift
12+
RealTests.swift
13+
RealTestSupport.swift)
14+
target_compile_options(RealTests PRIVATE
15+
-enable-testing)
16+
target_link_libraries(RealTests PUBLIC
17+
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>
18+
RealModule
19+
XCTest)

0 commit comments

Comments
 (0)