Skip to content

Commit 1104b9e

Browse files
committed
Adds Swift Package Manager support around the proj.h C API
1 parent 842f251 commit 1104b9e

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ build.local.sh
2323
/.vs*
2424
/*build*
2525
/nbproject
26+
/.swiftpm
2627

2728
# Autotools
2829
autom4te.cache

Package.swift

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// swift-tools-version: 5.10
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "proj",
7+
platforms: [
8+
.iOS(.v13), .macOS(.v13)
9+
],
10+
products: [
11+
.library(
12+
name: "proj",
13+
// type: .static,
14+
type: .dynamic,
15+
targets: ["proj"]
16+
),
17+
],
18+
targets: [
19+
.target(
20+
name: "proj",
21+
path: "src",
22+
exclude: [
23+
"apps",
24+
"tests",
25+
"CMakeLists.txt",
26+
"lib_proj.cmake",
27+
"check_md5sum.cmake",
28+
"generate_wkt_parser.cmake",
29+
"general_doc.dox",
30+
"wkt1_grammar.y",
31+
"wkt2_grammar.y",
32+
],
33+
resources: [
34+
// .copy("../proj.db") // What is this?
35+
],
36+
publicHeadersPath: ".", // The C header files are mixed with src files, we use a modulemap.module to load "proj.h"
37+
cSettings: [
38+
// .headerSearchPath("../include/proj"),
39+
// .headerSearchPath("../include/proj/internal"),
40+
// .headerSearchPath("../include/proj/internal/vendor/nlohmann"),
41+
],
42+
cxxSettings: [
43+
.headerSearchPath("../include"),
44+
.headerSearchPath("../include/proj"),
45+
.headerSearchPath("../include/proj/internal"),
46+
.headerSearchPath("../include/proj/internal/vendor/nlohmann"),
47+
],
48+
linkerSettings: [
49+
.linkedLibrary("c++"),
50+
.linkedLibrary("sqlite3"),
51+
]
52+
)
53+
],
54+
cxxLanguageStandard: .cxx17
55+
)

src/module.modulemap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module proj {
2+
// Include the header, but not as an `umbrella header "proj.h"`, since it doesn't include all headers in src folder
3+
// The src directory has a C header API and the implementation is C++ under the hood.
4+
header "proj.h"
5+
6+
export *
7+
}

0 commit comments

Comments
 (0)