Skip to content

Commit aa76ee5

Browse files
committed
Link the system math library explicitly when building for Android and Linux
1 parent d42ab14 commit aa76ee5

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

Package.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.0
1+
// swift-tools-version:5.2
22
//===--- Package.swift ----------------------------------------*- swift -*-===//
33
//
44
// This source file is part of the Swift Numerics open source project
@@ -25,7 +25,13 @@ let package = Package(
2525
// User-facing modules
2626
.target(name: "ComplexModule", dependencies: ["RealModule"]),
2727
.target(name: "Numerics", dependencies: ["ComplexModule", "RealModule"]),
28-
.target(name: "RealModule", dependencies: ["_NumericsShims"]),
28+
.target(
29+
name: "RealModule",
30+
dependencies: ["_NumericsShims"],
31+
linkerSettings: [
32+
.linkedLibrary("m", .when(platforms: [.linux, .android]))
33+
]
34+
),
2935

3036
// Implementation details
3137
.target(name: "_NumericsShims", dependencies: []),

[email protected]

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// swift-tools-version:5.0
2+
//===--- [email protected] ------------------------------*- swift -*-===//
3+
//
4+
// This source file is part of the Swift Numerics open source project
5+
//
6+
// Copyright (c) 2019 Apple Inc. and the Swift Numerics project authors
7+
// Licensed under Apache License v2.0 with Runtime Library Exception
8+
//
9+
// See https://swift.org/LICENSE.txt for license information
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import PackageDescription
14+
15+
let package = Package(
16+
17+
name: "swift-numerics",
18+
products: [
19+
.library(name: "ComplexModule", targets: ["ComplexModule"]),
20+
.library(name: "Numerics", targets: ["Numerics"]),
21+
.library(name: "RealModule", targets: ["RealModule"]),
22+
],
23+
24+
targets: [
25+
// User-facing modules
26+
.target(name: "ComplexModule", dependencies: ["RealModule"]),
27+
.target(name: "Numerics", dependencies: ["ComplexModule", "RealModule"]),
28+
.target(
29+
name: "RealModule",
30+
dependencies: ["_NumericsShims"],
31+
linkerSettings: [ .linkedLibrary("m", .when(platforms: [.linux])) ]
32+
),
33+
34+
// Implementation details
35+
.target(name: "_NumericsShims", dependencies: []),
36+
.target(name: "_TestSupport", dependencies: ["Numerics"]),
37+
38+
// Unit test bundles
39+
.testTarget(name: "ComplexTests", dependencies: ["_TestSupport"]),
40+
.testTarget(name: "RealTests", dependencies: ["_TestSupport"]),
41+
42+
// Test executables
43+
.target(name: "ComplexLog", dependencies: ["Numerics", "_TestSupport"], path: "Tests/Executable/ComplexLog"),
44+
.target(name: "ComplexLog1p", dependencies: ["Numerics", "_TestSupport"], path: "Tests/Executable/ComplexLog1p")
45+
]
46+
)

Sources/_NumericsShims/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ See https://swift.org/LICENSE.txt for license information
1010
add_library(_NumericsShims INTERFACE)
1111
target_include_directories(_NumericsShims INTERFACE
1212
include)
13+
target_link_libraries(_NumericsShims INTERFACE
14+
$<$<PLATFORM_ID:Linux>:m>)
1315

1416
set_property(GLOBAL APPEND PROPERTY SWIFT_NUMERICS_EXPORTS _NumericsShims)

0 commit comments

Comments
 (0)