From aa76ee56583504f2c8d641dd25d420b5122ee3ec Mon Sep 17 00:00:00 2001 From: Stephen Canon Date: Tue, 25 Feb 2025 15:17:29 -0500 Subject: [PATCH] Link the system math library explicitly when building for Android and Linux --- Package.swift | 10 ++++-- Package@swift-5.0.swift | 46 +++++++++++++++++++++++++++ Sources/_NumericsShims/CMakeLists.txt | 2 ++ 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 Package@swift-5.0.swift diff --git a/Package.swift b/Package.swift index 565d5d6..1d0766d 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.0 +// swift-tools-version:5.2 //===--- Package.swift ----------------------------------------*- swift -*-===// // // This source file is part of the Swift Numerics open source project @@ -25,7 +25,13 @@ let package = Package( // User-facing modules .target(name: "ComplexModule", dependencies: ["RealModule"]), .target(name: "Numerics", dependencies: ["ComplexModule", "RealModule"]), - .target(name: "RealModule", dependencies: ["_NumericsShims"]), + .target( + name: "RealModule", + dependencies: ["_NumericsShims"], + linkerSettings: [ + .linkedLibrary("m", .when(platforms: [.linux, .android])) + ] + ), // Implementation details .target(name: "_NumericsShims", dependencies: []), diff --git a/Package@swift-5.0.swift b/Package@swift-5.0.swift new file mode 100644 index 0000000..717e880 --- /dev/null +++ b/Package@swift-5.0.swift @@ -0,0 +1,46 @@ +// swift-tools-version:5.0 +//===--- Package@swift-5.0.swift ------------------------------*- swift -*-===// +// +// This source file is part of the Swift Numerics open source project +// +// Copyright (c) 2019 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 +// +//===----------------------------------------------------------------------===// + +import PackageDescription + +let package = Package( + + name: "swift-numerics", + products: [ + .library(name: "ComplexModule", targets: ["ComplexModule"]), + .library(name: "Numerics", targets: ["Numerics"]), + .library(name: "RealModule", targets: ["RealModule"]), + ], + + targets: [ + // User-facing modules + .target(name: "ComplexModule", dependencies: ["RealModule"]), + .target(name: "Numerics", dependencies: ["ComplexModule", "RealModule"]), + .target( + name: "RealModule", + dependencies: ["_NumericsShims"], + linkerSettings: [ .linkedLibrary("m", .when(platforms: [.linux])) ] + ), + + // Implementation details + .target(name: "_NumericsShims", dependencies: []), + .target(name: "_TestSupport", dependencies: ["Numerics"]), + + // Unit test bundles + .testTarget(name: "ComplexTests", dependencies: ["_TestSupport"]), + .testTarget(name: "RealTests", dependencies: ["_TestSupport"]), + + // Test executables + .target(name: "ComplexLog", dependencies: ["Numerics", "_TestSupport"], path: "Tests/Executable/ComplexLog"), + .target(name: "ComplexLog1p", dependencies: ["Numerics", "_TestSupport"], path: "Tests/Executable/ComplexLog1p") + ] +) diff --git a/Sources/_NumericsShims/CMakeLists.txt b/Sources/_NumericsShims/CMakeLists.txt index 92ed523..94f7378 100644 --- a/Sources/_NumericsShims/CMakeLists.txt +++ b/Sources/_NumericsShims/CMakeLists.txt @@ -10,5 +10,7 @@ See https://swift.org/LICENSE.txt for license information add_library(_NumericsShims INTERFACE) target_include_directories(_NumericsShims INTERFACE include) +target_link_libraries(_NumericsShims INTERFACE + $<$:m>) set_property(GLOBAL APPEND PROPERTY SWIFT_NUMERICS_EXPORTS _NumericsShims)