diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/proj')
5 files changed, 212 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/proj/7.nix b/nixpkgs/pkgs/development/libraries/proj/7.nix new file mode 100644 index 000000000000..4e1ade0bd56b --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/proj/7.nix @@ -0,0 +1,59 @@ +{ lib +, stdenv +, fetchFromGitHub +, cmake +, pkg-config +, sqlite +, libtiff +, curl +, gtest +, fetchpatch +}: + +stdenv.mkDerivation rec { + pname = "proj"; + version = "7.2.1"; + + src = fetchFromGitHub { + owner = "OSGeo"; + repo = "PROJ"; + rev = version; + sha256 = "0mymvfvs8xggl4axvlj7kc1ksd9g94kaz6w1vdv0x2y5mqk93gx9"; + }; + + patches = [ + (fetchpatch { # https://github.com/OSGeo/PROJ/issues/2557 + name = "gie_self_tests-fail.diff"; # included in >= 8.0.1 + url = "https://github.com/OSGeo/PROJ/commit/6f1a3c4648bf06862dca0b3725cbb3b7ee0284e3.diff"; + sha256 = "0gapny0a9c3r0x9szjgn86sspjrrf4vwbija77b17w6ci5cq4pdf"; + }) + ./tests-sqlite-3.39.patch + ]; + + postPatch = lib.optionalString (version == "7.2.1") '' + substituteInPlace CMakeLists.txt \ + --replace "MAJOR 7 MINOR 2 PATCH 0" "MAJOR 7 MINOR 2 PATCH 1" + ''; + + outputs = [ "out" "dev"]; + + nativeBuildInputs = [ cmake pkg-config ]; + + buildInputs = [ sqlite libtiff curl ]; + + nativeCheckInputs = [ gtest ]; + + cmakeFlags = [ + "-DUSE_EXTERNAL_GTEST=ON" + ]; + + doCheck = true; + + meta = with lib; { + description = "Cartographic Projections Library"; + homepage = "https://proj4.org"; + license = licenses.mit; + platforms = platforms.unix; + maintainers = with maintainers; [ dotlambda ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/proj/default.nix b/nixpkgs/pkgs/development/libraries/proj/default.nix new file mode 100644 index 000000000000..69aa94408b94 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/proj/default.nix @@ -0,0 +1,74 @@ +{ lib +, stdenv +, fetchFromGitHub +, fetchpatch +, cmake +, pkg-config +, buildPackages +, callPackage +, sqlite +, libtiff +, curl +, gtest +, nlohmann_json +, python3 +, cacert +}: + +stdenv.mkDerivation (finalAttrs: rec { + pname = "proj"; + version = "9.2.0"; + + src = fetchFromGitHub { + owner = "OSGeo"; + repo = "PROJ"; + rev = version; + hash = "sha256-NC5H7ufIXit+PVDwNDhz5cv44fduTytsdmNOWyqDDYQ="; + }; + + patches = [ + # https://github.com/OSGeo/PROJ/pull/3252 + ./only-add-curl-for-static-builds.patch + ]; + + outputs = [ "out" "dev" ]; + + nativeBuildInputs = [ cmake pkg-config ]; + + buildInputs = [ sqlite libtiff curl nlohmann_json ]; + + nativeCheckInputs = [ cacert gtest ]; + + cmakeFlags = [ + "-DUSE_EXTERNAL_GTEST=ON" + "-DRUN_NETWORK_DEPENDENT_TESTS=OFF" + "-DNLOHMANN_JSON_ORIGIN=external" + "-DEXE_SQLITE3=${buildPackages.sqlite}/bin/sqlite3" + ]; + + preCheck = + let + libPathEnvVar = if stdenv.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH"; + in + '' + export HOME=$TMPDIR + export TMP=$TMPDIR + export ${libPathEnvVar}=$PWD/lib + ''; + + doCheck = true; + + passthru.tests = { + python = python3.pkgs.pyproj; + proj = callPackage ./tests.nix { proj = finalAttrs.finalPackage; }; + }; + + meta = with lib; { + changelog = "https://github.com/OSGeo/PROJ/blob/${src.rev}/docs/source/news.rst"; + description = "Cartographic Projections Library"; + homepage = "https://proj.org/"; + license = licenses.mit; + maintainers = with maintainers; teams.geospatial.members ++ [ dotlambda ]; + platforms = platforms.unix; + }; +}) diff --git a/nixpkgs/pkgs/development/libraries/proj/only-add-curl-for-static-builds.patch b/nixpkgs/pkgs/development/libraries/proj/only-add-curl-for-static-builds.patch new file mode 100644 index 000000000000..2997edd8957a --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/proj/only-add-curl-for-static-builds.patch @@ -0,0 +1,55 @@ +From 831063f8206cab1ad3e90b204a1c3f8c87c3d5cc Mon Sep 17 00:00:00 2001 +From: Even Rouault <even.rouault@spatialys.com> +Date: Tue, 5 Jul 2022 19:40:53 +0200 +Subject: [PATCH] proj-config.cmake generation: only add find_dependency(CURL) + for static builds + +--- + cmake/project-config.cmake.in | 30 +++++++++++++++++------------- + 1 file changed, 17 insertions(+), 13 deletions(-) + +diff --git a/cmake/project-config.cmake.in b/cmake/project-config.cmake.in +index 40dbaaa2..c1ecd601 100644 +--- a/cmake/project-config.cmake.in ++++ b/cmake/project-config.cmake.in +@@ -15,20 +15,24 @@ include(CMakeFindDependencyMacro) + + cmake_policy(PUSH) + cmake_policy(SET CMP0012 NEW) +-if("@ENABLE_TIFF@") +- find_dependency(TIFF) ++if(NOT "@BUILD_SHARED_LIBS@") ++ if("@ENABLE_TIFF@") ++ find_dependency(TIFF) ++ endif() + endif() +-if("@CURL_ENABLED@") +- # Chainload CURL usage requirements +- find_dependency(CURL) +- # Target CURL::libcurl only defined since CMake 3.12 +- if(NOT TARGET CURL::libcurl) +- add_library(CURL::libcurl INTERFACE IMPORTED) +- set_target_properties(CURL::libcurl PROPERTIES +- INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}" +- INTERFACE_LINK_LIBRARIES "${CURL_LIBRARIES}" +- ) +- endif() ++if(NOT "@BUILD_SHARED_LIBS@") ++ if("@CURL_ENABLED@") ++ # Chainload CURL usage requirements ++ find_dependency(CURL) ++ # Target CURL::libcurl only defined since CMake 3.12 ++ if(NOT TARGET CURL::libcurl) ++ add_library(CURL::libcurl INTERFACE IMPORTED) ++ set_target_properties(CURL::libcurl PROPERTIES ++ INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}" ++ INTERFACE_LINK_LIBRARIES "${CURL_LIBRARIES}" ++ ) ++ endif() ++ endif() + endif() + cmake_policy(POP) + +-- +2.39.2 + diff --git a/nixpkgs/pkgs/development/libraries/proj/tests-sqlite-3.39.patch b/nixpkgs/pkgs/development/libraries/proj/tests-sqlite-3.39.patch new file mode 100644 index 000000000000..0654ff5eadb6 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/proj/tests-sqlite-3.39.patch @@ -0,0 +1,13 @@ +Drop tests that time out with newest sqlite. +https://github.com/OSGeo/PROJ/issues/3254 + +--- a/test/cli/CMakeLists.txt ++++ b/test/cli/CMakeLists.txt +@@ -16 +15,0 @@ +-proj_add_test_script_sh("testprojinfo" PROJINFO_BIN) +--- a/test/unit/CMakeLists.txt ++++ b/test/unit/CMakeLists.txt +@@ -144,3 +143,0 @@ +-add_test(NAME proj_test_cpp_api COMMAND proj_test_cpp_api) +-set_property(TEST proj_test_cpp_api +- PROPERTY ENVIRONMENT ${PROJ_TEST_ENVIRONMENT}) diff --git a/nixpkgs/pkgs/development/libraries/proj/tests.nix b/nixpkgs/pkgs/development/libraries/proj/tests.nix new file mode 100644 index 000000000000..38126f06dd4d --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/proj/tests.nix @@ -0,0 +1,11 @@ +{ runCommand, proj }: + +let + inherit (proj) pname; +in +runCommand "${pname}-tests" { meta.timeout = 60; } + '' + ${proj}/bin/projinfo EPSG:4326 \ + | grep '+proj=longlat +datum=WGS84 +no_defs +type=crs' + touch $out + '' |