From 996cf7f5b98b998ae92efc3700a4163d1b1be3cf Mon Sep 17 00:00:00 2001 From: Stephen Canon Date: Thu, 26 Aug 2021 15:18:40 -0400 Subject: [PATCH] CMake build support for the IntegerUtilities module. --- Sources/CMakeLists.txt | 3 ++- Sources/IntegerUtilities/CMakeLists.txt | 16 ++++++++++++++++ Sources/Numerics/CMakeLists.txt | 1 + Sources/Numerics/Numerics.swift | 3 ++- Tests/CMakeLists.txt | 2 ++ Tests/IntegerUtilitiesTests/CMakeLists.txt | 18 ++++++++++++++++++ Tests/IntegerUtilitiesTests/RotateTests.swift | 2 +- Tests/WindowsMain.swift | 11 +++++++++++ 8 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 Sources/IntegerUtilities/CMakeLists.txt create mode 100644 Tests/IntegerUtilitiesTests/CMakeLists.txt diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index c7cbf9d..4bd3902 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -1,7 +1,7 @@ #[[ This source file is part of the Swift Numerics open source project -Copyright (c) 2019 Apple Inc. and the Swift Numerics project authors +Copyright (c) 2019-2021 Apple Inc. and the Swift Numerics project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -9,6 +9,7 @@ See https://swift.org/LICENSE.txt for license information add_subdirectory(_NumericsShims) add_subdirectory(ComplexModule) +add_subdirectory(IntegerUtilities) add_subdirectory(Numerics) add_subdirectory(RealModule) if(BUILD_TESTING) diff --git a/Sources/IntegerUtilities/CMakeLists.txt b/Sources/IntegerUtilities/CMakeLists.txt new file mode 100644 index 0000000..f09216e --- /dev/null +++ b/Sources/IntegerUtilities/CMakeLists.txt @@ -0,0 +1,16 @@ +#[[ +This source file is part of the Swift Numerics open source project + +Copyright (c) 2019-2021 Apple Inc. and the Swift Numerics project authors +Licensed under Apache License v2.0 with Runtime Library Exception + +See https://swift.org/LICENSE.txt for license information +#]] + +add_library(IntegerUtilities + Rotate.swift) +set_target_properties(IntegerUtilities PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) + +_install_target(IntegerUtilities) +set_property(GLOBAL APPEND PROPERTY SWIFT_NUMERICS_EXPORTS IntegerUtilities) diff --git a/Sources/Numerics/CMakeLists.txt b/Sources/Numerics/CMakeLists.txt index a4a219a..8104049 100644 --- a/Sources/Numerics/CMakeLists.txt +++ b/Sources/Numerics/CMakeLists.txt @@ -20,6 +20,7 @@ target_compile_options(Numerics PUBLIC -Xfrontend -validate-tbd-against-ir=none) target_link_libraries(Numerics PUBLIC ComplexModule + IntegerUtilities RealModule) diff --git a/Sources/Numerics/Numerics.swift b/Sources/Numerics/Numerics.swift index 360ba9a..2aa9903 100644 --- a/Sources/Numerics/Numerics.swift +++ b/Sources/Numerics/Numerics.swift @@ -10,5 +10,6 @@ //===----------------------------------------------------------------------===// // A module that re-exports the complete Swift Numerics public API. -@_exported import RealModule @_exported import ComplexModule +@_exported import IntegerUtilities +@_exported import RealModule diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index b879f0e..b842677 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -12,12 +12,14 @@ find_package(Foundation CONFIG QUIET) find_package(XCTest CONFIG QUIET) add_subdirectory(ComplexTests) +add_subdirectory(IntegerUtilitiesTests) add_subdirectory(RealTests) add_executable(SwiftNumericsTestRunner WindowsMain.swift) target_link_libraries(SwiftNumericsTestRunner PRIVATE ComplexTests + IntegerUtilitiesTests RealTests) add_test(NAME SwiftNumericsTestRunner diff --git a/Tests/IntegerUtilitiesTests/CMakeLists.txt b/Tests/IntegerUtilitiesTests/CMakeLists.txt new file mode 100644 index 0000000..287cf1b --- /dev/null +++ b/Tests/IntegerUtilitiesTests/CMakeLists.txt @@ -0,0 +1,18 @@ +#[[ +This source file is part of the Swift Numerics open source project + +Copyright (c) 2019-2021 Apple Inc. and the Swift Numerics project authors +Licensed under Apache License v2.0 with Runtime Library Exception + +See https://swift.org/LICENSE.txt for license information +#]] + +add_library(IntegerUtilitiesTests + RotateTests.swift) +target_compile_options(IntegerUtilitiesTests PRIVATE + -enable-testing) +target_link_libraries(IntegerUtilitiesTests PUBLIC + $<$>:Foundation> + Numerics + XCTest) + diff --git a/Tests/IntegerUtilitiesTests/RotateTests.swift b/Tests/IntegerUtilitiesTests/RotateTests.swift index 9a5a453..ab440b7 100644 --- a/Tests/IntegerUtilitiesTests/RotateTests.swift +++ b/Tests/IntegerUtilitiesTests/RotateTests.swift @@ -13,7 +13,7 @@ import IntegerUtilities import XCTest -final class IntegerUtilitiesTests: XCTestCase { +final class RotateTests: XCTestCase { func testRotateUInt8() { let x: UInt8 = 0b10011100 XCTAssertEqual(0b01001110, x.rotated(right:-7)) diff --git a/Tests/WindowsMain.swift b/Tests/WindowsMain.swift index c0e6002..b956a8c 100644 --- a/Tests/WindowsMain.swift +++ b/Tests/WindowsMain.swift @@ -18,6 +18,9 @@ import RealTests @testable import ComplexTests +@testable +import IntegerUtilitiesTests + extension ComplexTests.ApproximateEqualityTests { static var all = testCase([ ("testFloat", ComplexTests.ApproximateEqualityTests.testFloat), @@ -80,6 +83,13 @@ extension PropertyTests { ]) } +extension RotateTests { + static var all = testCase([ + ("testRotateUInt8", RotateTests.testRotateUInt8), + ("testRotateInt16", RotateTests.testRotateInt16), + ]) +} + var testCases = [ ComplexTests.ApproximateEqualityTests.all, RealTests.ApproximateEqualityTests.all, @@ -87,6 +97,7 @@ var testCases = [ IntegerExponentTests.all, ArithmeticTests.all, PropertyTests.all, + RotateTests.all, ] #if swift(>=5.3) && canImport(_Differentiation)