Skip to content

Commit e29479b

Browse files
Merge pull request #190 from stephentyrone/cmake-integer-utilities
CMake build support for the IntegerUtilities module.
2 parents 4a6730b + 996cf7f commit e29479b

File tree

8 files changed

+53
-3
lines changed

8 files changed

+53
-3
lines changed

Sources/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#[[
22
This source file is part of the Swift Numerics open source project
33
4-
Copyright (c) 2019 Apple Inc. and the Swift Numerics project authors
4+
Copyright (c) 2019-2021 Apple Inc. and the Swift Numerics project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66
77
See https://swift.org/LICENSE.txt for license information
88
#]]
99

1010
add_subdirectory(_NumericsShims)
1111
add_subdirectory(ComplexModule)
12+
add_subdirectory(IntegerUtilities)
1213
add_subdirectory(Numerics)
1314
add_subdirectory(RealModule)
1415
if(BUILD_TESTING)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#[[
2+
This source file is part of the Swift Numerics open source project
3+
4+
Copyright (c) 2019-2021 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(IntegerUtilities
11+
Rotate.swift)
12+
set_target_properties(IntegerUtilities PROPERTIES
13+
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
14+
15+
_install_target(IntegerUtilities)
16+
set_property(GLOBAL APPEND PROPERTY SWIFT_NUMERICS_EXPORTS IntegerUtilities)

Sources/Numerics/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ target_compile_options(Numerics PUBLIC
2020
-Xfrontend -validate-tbd-against-ir=none)
2121
target_link_libraries(Numerics PUBLIC
2222
ComplexModule
23+
IntegerUtilities
2324
RealModule)
2425

2526

Sources/Numerics/Numerics.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
//===----------------------------------------------------------------------===//
1111

1212
// A module that re-exports the complete Swift Numerics public API.
13-
@_exported import RealModule
1413
@_exported import ComplexModule
14+
@_exported import IntegerUtilities
15+
@_exported import RealModule

Tests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ find_package(Foundation CONFIG QUIET)
1212
find_package(XCTest CONFIG QUIET)
1313

1414
add_subdirectory(ComplexTests)
15+
add_subdirectory(IntegerUtilitiesTests)
1516
add_subdirectory(RealTests)
1617

1718
add_executable(SwiftNumericsTestRunner
1819
WindowsMain.swift)
1920
target_link_libraries(SwiftNumericsTestRunner PRIVATE
2021
ComplexTests
22+
IntegerUtilitiesTests
2123
RealTests)
2224

2325
add_test(NAME SwiftNumericsTestRunner
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#[[
2+
This source file is part of the Swift Numerics open source project
3+
4+
Copyright (c) 2019-2021 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(IntegerUtilitiesTests
11+
RotateTests.swift)
12+
target_compile_options(IntegerUtilitiesTests PRIVATE
13+
-enable-testing)
14+
target_link_libraries(IntegerUtilitiesTests PUBLIC
15+
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>
16+
Numerics
17+
XCTest)
18+

Tests/IntegerUtilitiesTests/RotateTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import IntegerUtilities
1414
import XCTest
1515

16-
final class IntegerUtilitiesTests: XCTestCase {
16+
final class RotateTests: XCTestCase {
1717
func testRotateUInt8() {
1818
let x: UInt8 = 0b10011100
1919
XCTAssertEqual(0b01001110, x.rotated(right:-7))

Tests/WindowsMain.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import RealTests
1818
@testable
1919
import ComplexTests
2020

21+
@testable
22+
import IntegerUtilitiesTests
23+
2124
extension ComplexTests.ApproximateEqualityTests {
2225
static var all = testCase([
2326
("testFloat", ComplexTests.ApproximateEqualityTests.testFloat),
@@ -80,13 +83,21 @@ extension PropertyTests {
8083
])
8184
}
8285

86+
extension RotateTests {
87+
static var all = testCase([
88+
("testRotateUInt8", RotateTests.testRotateUInt8),
89+
("testRotateInt16", RotateTests.testRotateInt16),
90+
])
91+
}
92+
8393
var testCases = [
8494
ComplexTests.ApproximateEqualityTests.all,
8595
RealTests.ApproximateEqualityTests.all,
8696
ElementaryFunctionChecks.all,
8797
IntegerExponentTests.all,
8898
ArithmeticTests.all,
8999
PropertyTests.all,
100+
RotateTests.all,
90101
]
91102

92103
#if swift(>=5.3) && canImport(_Differentiation)

0 commit comments

Comments
 (0)