Skip to content

Commit

Permalink
(conan-io#7810) proj: add 8.1.1 + bump dependencies + modernize
Browse files Browse the repository at this point in the history
* bump dependencies

* modernize

* prefer to fix iOS build by disabling CMAKE_MACOSX_BUNDLE

it allows to avoid patches

* add proj/8.1.1

* fix -Wcomment warning in test package
  • Loading branch information
SpaceIm authored and ivanvurbanov committed Dec 2, 2021
1 parent c61291c commit 8d85b29
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 22 deletions.
6 changes: 6 additions & 0 deletions recipes/proj/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"8.1.1":
url: "https://github.com/OSGeo/PROJ/releases/download/8.1.1/proj-8.1.1.tar.gz"
sha256: "82f1345e5fa530c407cb1fc0752e83f8d08d2b98772941bbdc7820241f7fada2"
"8.1.0":
url: "https://github.com/OSGeo/PROJ/releases/download/8.1.0/proj-8.1.0.tar.gz"
sha256: "22c5cdc5aa0832077b16c95ebeec748a0942811c1c3438c33d43c8d2ead59f48"
Expand Down Expand Up @@ -30,6 +33,9 @@ sources:
url: "https://github.com/OSGeo/PROJ/releases/download/6.3.1/proj-6.3.1.tar.gz"
sha256: "6de0112778438dcae30fcc6942dee472ce31399b9e5a2b67e8642529868c86f8"
patches:
"8.1.1":
- patch_file: "patches/use-cmake-targets-8.1.1.patch"
base_path: "source_subfolder"
"8.1.0":
- patch_file: "patches/use-cmake-targets-8.1.0.patch"
base_path: "source_subfolder"
Expand Down
31 changes: 14 additions & 17 deletions recipes/proj/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,36 @@ class ProjConan(ConanFile):
name = "proj"
description = "Cartographic Projections and Coordinate Transformations Library."
license = "MIT"
topics = ("conan", "dsp", "proj", "proj4", "projections", "gis", "geospatial")
topics = ("dsp", "proj", "proj4", "projections", "gis", "geospatial")
homepage = "https://proj.org"
url = "https://github.com/conan-io/conan-center-index"
exports_sources = ["CMakeLists.txt", "patches/**"]
generators = "cmake", "cmake_find_package"

settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"threadsafe": [True, False],
"with_tiff": [True, False],
"with_curl": [True, False],
"build_executables": [True, False]
"build_executables": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"threadsafe": True,
"with_tiff": True,
"with_curl": True,
"build_executables": True
"build_executables": True,
}

generators = "cmake", "cmake_find_package"
_cmake = None

def export_sources(self):
self.copy("CMakeLists.txt")
for patch in self.conan_data.get("patches", {}).get(self.version, []):
self.copy(patch["patch_file"])

@property
def _source_subfolder(self):
return "source_subfolder"
Expand All @@ -49,12 +54,12 @@ def configure(self):
del self.options.fPIC

def requirements(self):
self.requires("nlohmann_json/3.9.1")
self.requires("nlohmann_json/3.10.4")
self.requires("sqlite3/3.36.0")
if self.options.get_safe("with_tiff"):
self.requires("libtiff/4.2.0")
self.requires("libtiff/4.3.0")
if self.options.get_safe("with_curl"):
self.requires("libcurl/7.77.0")
self.requires("libcurl/7.79.1")

def build_requirements(self):
if hasattr(self, "settings_build"):
Expand All @@ -80,15 +85,6 @@ def _patch_sources(self):
tools.replace_in_file(cmakelists,
"find_program(EXE_SQLITE3 sqlite3)",
"find_program(EXE_SQLITE3 sqlite3 PATHS {} NO_DEFAULT_PATH)".format(sqlite3_exe_build_context_paths))
# Fix executables installation on iOS
# might be fixed upstream by https://github.com/OSGeo/PROJ/pull/2764
execs = ["cct", "cs2cs", "geod", "gie", "proj", "projinfo"]
if tools.Version(self.version) >= "7.0.0":
execs.append("projsync")
for exec in execs:
tools.replace_in_file(os.path.join(self._source_subfolder, "src", "bin_{}.cmake".format(exec)),
"RUNTIME DESTINATION ${BINDIR}",
"DESTINATION ${BINDIR}")
# unvendor nlohmann_json
if tools.Version(self.version) < "8.1.0":
tools.rmdir(os.path.join(self._source_subfolder, "include", "proj", "internal", "nlohmann"))
Expand Down Expand Up @@ -118,6 +114,7 @@ def _configure_cmake(self):
self._cmake.definitions["BUILD_PROJSYNC"] = self.options.build_executables and self.options.with_curl
if tools.Version(self.version) >= "8.1.0":
self._cmake.definitions["NLOHMANN_JSON_ORIGIN"] = "external"
self._cmake.definitions["CMAKE_MACOSX_BUNDLE"] = False
self._cmake.configure()
return self._cmake

Expand Down
31 changes: 31 additions & 0 deletions recipes/proj/all/patches/use-cmake-targets-8.1.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--- a/src/lib_proj.cmake
+++ b/src/lib_proj.cmake
@@ -393,8 +393,7 @@ if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
target_link_libraries(proj PRIVATE ${CMAKE_THREAD_LIBS_INIT})
endif()

-target_include_directories(proj PRIVATE ${SQLITE3_INCLUDE_DIR})
-target_link_libraries(proj PRIVATE ${SQLITE3_LIBRARY})
+target_link_libraries(proj PRIVATE CONAN_PKG::sqlite3)

if(NLOHMANN_JSON STREQUAL "external")
target_compile_definitions(proj PRIVATE EXTERNAL_NLOHMANN_JSON)
@@ -404,16 +403,14 @@ endif()

if(TIFF_ENABLED)
target_compile_definitions(proj PRIVATE -DTIFF_ENABLED)
- target_include_directories(proj PRIVATE ${TIFF_INCLUDE_DIR})
- target_link_libraries(proj PRIVATE ${TIFF_LIBRARY})
+ target_link_libraries(proj PRIVATE TIFF::TIFF)
endif()

if(CURL_ENABLED)
target_compile_definitions(proj PRIVATE -DCURL_ENABLED)
- target_include_directories(proj PRIVATE ${CURL_INCLUDE_DIR})
target_link_libraries(proj
PRIVATE
- ${CURL_LIBRARY}
+ CURL::libcurl
$<$<CXX_COMPILER_ID:MSVC>:ws2_32>
$<$<CXX_COMPILER_ID:MSVC>:wldap32>
$<$<CXX_COMPILER_ID:MSVC>:advapi32>
2 changes: 1 addition & 1 deletion recipes/proj/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1)
project(test_package C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
conan_basic_setup(TARGETS)

add_executable(test_package test_package.c)
if(PROJ_VERSION_GE_7)
Expand Down
4 changes: 2 additions & 2 deletions recipes/proj/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from conans import ConanFile, CMake, tools
import os

from conans import ConanFile, CMake, tools

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
Expand All @@ -13,6 +13,6 @@ def build(self):
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
4 changes: 2 additions & 2 deletions recipes/proj/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* From PROJ quickstart */
/* From PROJ quickstart */

#include <stdio.h>
#include <proj.h>
Expand Down Expand Up @@ -35,7 +35,7 @@ int main (void) {
P = P_for_GIS;

/* a coordinate union representing Copenhagen: 55d N, 12d E */
/* Given that we have used proj_normalize_for_visualization(), the order of
/* Given that we have used proj_normalize_for_visualization(), the order of */
/* coordinates is longitude, latitude, and values are expressed in degrees. */
a = proj_coord (12, 55, 0, 0);

Expand Down
2 changes: 2 additions & 0 deletions recipes/proj/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"8.1.1":
folder: "all"
"8.1.0":
folder: "all"
"8.0.1":
Expand Down

0 comments on commit 8d85b29

Please sign in to comment.