Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ build.local.sh
/.vs*
/*build*
/nbproject
/.swiftpm

# Autotools
autom4te.cache
Expand Down
60 changes: 60 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// swift-tools-version: 5.10

import PackageDescription

/// Cocoapods to SPM Notes:
/// My goal is to to minimal changes to support SPM since this is a fork of OSGeo/PROJ.
///
/// * Creating a custom module.modulemap seems to fix build issues when using the proj.h header
/// * The public interface is C for the proj.h API we use, so we don't need to use the C++ headers exposed
/// * The C++ header search paths are added so under the hood we can find the headers.
/// * The 9.4_release_spm does not include proj.db, since with Bundles, we need to load resources in the
/// package that requires it. So projections-ios loads the proj.db from it's own bundle. (In Cocoapods you could
/// reach into other bundles, but not with SPM)
/// * Potentially the 9.6_release_spm can provided proj.db in source, but I haven't figured how that integrates.
/// * CMake autogenerates some files that need to be added like "proj_config.h" (9.6 has more autogenerated files)

let package = Package(
name: "proj",
platforms: [
.iOS(.v13), .macOS(.v12)
],
products: [
.library(
name: "proj",
type: .static,
targets: ["proj"]
),
],
targets: [
.target(
name: "proj",
path: "src",
exclude: [
"apps",
"tests",
"CMakeLists.txt",
"lib_proj.cmake",
"check_md5sum.cmake",
"generate_wkt_parser.cmake",
"general_doc.dox",
"wkt1_grammar.y",
"wkt2_grammar.y",
],
resources: [
],
publicHeadersPath: ".", // The C header files are mixed with src files, we use a modulemap.module to load "proj.h"
cxxSettings: [
.headerSearchPath("../include"),
.headerSearchPath("../include/proj"),
.headerSearchPath("../include/proj/internal"),
.headerSearchPath("../include/proj/internal/vendor/nlohmann"),
],
linkerSettings: [
.linkedLibrary("c++"),
.linkedLibrary("sqlite3"),
]
)
],
cxxLanguageStandard: .cxx11
)
7 changes: 7 additions & 0 deletions src/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module proj {
// Include the header, but not as an `umbrella header "proj.h"`, since it doesn't include all headers in src folder
// The src directory has a C header API and the implementation is C++ under the hood.
header "proj.h"

export *
}
Loading