From de0f7321b4c7582a2cf8b5e2aac26cfb277bc6cf Mon Sep 17 00:00:00 2001 From: Brennan Ashton Date: Wed, 29 Jan 2020 23:26:48 -0800 Subject: [PATCH] Add proj/6.3.0 Signed-off-by: Brennan Ashton --- recipes/proj/all/CMakeLists.txt | 7 ++ recipes/proj/all/conandata.yml | 11 +++ recipes/proj/all/conanfile.py | 79 +++++++++++++++++++ .../0001-Include-libdl-for-sqlite.patch | 25 ++++++ .../0002-Use-python-instead-of-sqlite.patch | 49 ++++++++++++ recipes/proj/all/sqlite_init.py | 7 ++ recipes/proj/all/test_package/CMakeLists.txt | 11 +++ recipes/proj/all/test_package/conanfile.py | 20 +++++ recipes/proj/all/test_package/test_package.c | 52 ++++++++++++ recipes/proj/config.yml | 3 + 10 files changed, 264 insertions(+) create mode 100644 recipes/proj/all/CMakeLists.txt create mode 100644 recipes/proj/all/conandata.yml create mode 100644 recipes/proj/all/conanfile.py create mode 100644 recipes/proj/all/patches/0001-Include-libdl-for-sqlite.patch create mode 100644 recipes/proj/all/patches/0002-Use-python-instead-of-sqlite.patch create mode 100644 recipes/proj/all/sqlite_init.py create mode 100644 recipes/proj/all/test_package/CMakeLists.txt create mode 100644 recipes/proj/all/test_package/conanfile.py create mode 100644 recipes/proj/all/test_package/test_package.c create mode 100644 recipes/proj/config.yml diff --git a/recipes/proj/all/CMakeLists.txt b/recipes/proj/all/CMakeLists.txt new file mode 100644 index 0000000000000..7a80c0b2c26dc --- /dev/null +++ b/recipes/proj/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.11) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory("source_subfolder") diff --git a/recipes/proj/all/conandata.yml b/recipes/proj/all/conandata.yml new file mode 100644 index 0000000000000..386dcfacf39c4 --- /dev/null +++ b/recipes/proj/all/conandata.yml @@ -0,0 +1,11 @@ +sources: + "6.3.0": + url: https://github.com/OSGeo/PROJ/releases/download/6.3.0/proj-6.3.0.tar.gz + sha256: 68ce9ba0005d442c2c1d238a3b9bc6654c358159b4af467b91e8d5b407c79c77 + +patches: + "6.3.0": + - patch_file: "patches/0001-Include-libdl-for-sqlite.patch" + base_path: "source_subfolder" + - patch_file: "patches/0002-Use-python-instead-of-sqlite.patch" + base_path: "source_subfolder" diff --git a/recipes/proj/all/conanfile.py b/recipes/proj/all/conanfile.py new file mode 100644 index 0000000000000..7564cedeff41e --- /dev/null +++ b/recipes/proj/all/conanfile.py @@ -0,0 +1,79 @@ +from conans import ConanFile, CMake, tools +import os + + +class LibaecConan(ConanFile): + name = "proj" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://proj.org" + description = "Cartographic Projections and Coordinate Transformations Library" + topics = ("conan", "dsp", "proj", "proj4", "projections", "gis", "geospatial") + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + generators = "cmake" + exports_sources = ["CMakeLists.txt", "sqlite_init.py", "patches/*"] + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def requirements(self): + self.requires("sqlite3/3.31.0") + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + extracted_dir = self.name + "-" + self.version + os.rename(extracted_dir, self._source_subfolder) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["PROJ_TESTS"] = False + self._cmake.definitions["BUILD_LIBPROJ_SHARED"] = self.options.shared + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + for patch in self.conan_data["patches"][self.version]: + tools.patch(**patch) + tools.replace_in_file(os.path.join(self._source_subfolder, "src", "lib_proj.cmake"), + "include_directories(${CMAKE_SOURCE_DIR}/include)", + "include_directories(${PROJ4_SOURCE_DIR}/include)") + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + self.copy("*.db", + src=os.path.join(self.package_folder, "share", "proj"), + dst=os.path.join(self.package_folder, "lib", "proj")) + tools.rmdir(os.path.join(self.package_folder, "share")) + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + + def package_info(self): + self.cpp_info.libs = tools.collect_libs(self) + if self.settings.os == "Linux": + self.cpp_info.system_libs = ["pthread", "dl", "m"] + self.env_info.PROJ_LIB.append(os.path.join(self.package_folder, "lib", "proj")) diff --git a/recipes/proj/all/patches/0001-Include-libdl-for-sqlite.patch b/recipes/proj/all/patches/0001-Include-libdl-for-sqlite.patch new file mode 100644 index 0000000000000..746abd5b415e4 --- /dev/null +++ b/recipes/proj/all/patches/0001-Include-libdl-for-sqlite.patch @@ -0,0 +1,25 @@ +From abe15bcef2004069d5e356c94acd9ffbdf17f16e Mon Sep 17 00:00:00 2001 +From: Brennan Ashton +Date: Wed, 29 Jan 2020 22:59:46 -0800 +Subject: [PATCH 1/2] Include libdl for sqlite + +--- + src/lib_proj.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/lib_proj.cmake b/src/lib_proj.cmake +index bc27bafe..280bb959 100644 +--- a/src/lib_proj.cmake ++++ b/src/lib_proj.cmake +@@ -441,7 +441,7 @@ if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT) + endif() + + include_directories(${SQLITE3_INCLUDE_DIR}) +-target_link_libraries(${PROJ_CORE_TARGET} ${SQLITE3_LIBRARY}) ++target_link_libraries(${PROJ_CORE_TARGET} CONAN_PKG::sqlite3) + + if(MSVC AND BUILD_LIBPROJ_SHARED) + target_compile_definitions(${PROJ_CORE_TARGET} +-- +2.20.1 + diff --git a/recipes/proj/all/patches/0002-Use-python-instead-of-sqlite.patch b/recipes/proj/all/patches/0002-Use-python-instead-of-sqlite.patch new file mode 100644 index 0000000000000..073c387ce68a4 --- /dev/null +++ b/recipes/proj/all/patches/0002-Use-python-instead-of-sqlite.patch @@ -0,0 +1,49 @@ +From fd091e736f87f623373b9362d3ee9867e9204419 Mon Sep 17 00:00:00 2001 +From: Brennan Ashton +Date: Thu, 30 Jan 2020 09:45:58 -0800 +Subject: [PATCH 2/2] Use python instead of sqlite + +--- + CMakeLists.txt | 5 ----- + data/CMakeLists.txt | 6 +++++- + 2 files changed, 5 insertions(+), 6 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 53a88de4..50c11238 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -117,11 +117,6 @@ include(policies) + ################################################################################ + # Check for sqlite3 + ################################################################################ +-find_program(EXE_SQLITE3 sqlite3) +-if(NOT EXE_SQLITE3) +- message(SEND_ERROR "sqlite3 binary not found!") +-endif() +- + find_package(Sqlite3 REQUIRED) + if(NOT SQLITE3_FOUND) + message(SEND_ERROR "sqlite3 dependency not found!") +diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt +index 8f3965f2..2e8f7c85 100644 +--- a/data/CMakeLists.txt ++++ b/data/CMakeLists.txt +@@ -40,10 +40,14 @@ add_custom_command( + + add_custom_target(generate_all_sql_in ALL DEPENDS ${ALL_SQL_IN}) + ++find_package(PythonInterp) ++if(NOT PYTHONINTERP_FOUND) ++ message(SEND_ERROR "python executable not found!") ++endif() + add_custom_command( + OUTPUT ${PROJ_DB} + COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJ_DB} +- COMMAND ${EXE_SQLITE3} -init ${ALL_SQL_IN} ${PROJ_DB} .quit ++ COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/sqlite_init.py ${PROJ_DB} ${ALL_SQL_IN} + # note: we didn't port yet the foreign_key_check done in Makefile.am + DEPENDS generate_all_sql_in ${ALL_SQL_IN} + COMMENT "Generating proj.db" +-- +2.20.1 + diff --git a/recipes/proj/all/sqlite_init.py b/recipes/proj/all/sqlite_init.py new file mode 100644 index 0000000000000..1f9cd3a2296f8 --- /dev/null +++ b/recipes/proj/all/sqlite_init.py @@ -0,0 +1,7 @@ +import sqlite3 +import sys + +con = sqlite3.connect(sys.argv[1]) +with open(sys.argv[2], 'rb') as sql_init: + con.executescript(sql_init.read().decode("UTF-8")) +con.close() diff --git a/recipes/proj/all/test_package/CMakeLists.txt b/recipes/proj/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..b727bf869b3e4 --- /dev/null +++ b/recipes/proj/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1.3) +project(test_package) + +set(CMAKE_VERBOSE_MAKEFILE TRUE) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX) diff --git a/recipes/proj/all/test_package/conanfile.py b/recipes/proj/all/test_package/conanfile.py new file mode 100644 index 0000000000000..badbb8306f936 --- /dev/null +++ b/recipes/proj/all/test_package/conanfile.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/proj/all/test_package/test_package.c b/recipes/proj/all/test_package/test_package.c new file mode 100644 index 0000000000000..6857d446d88d4 --- /dev/null +++ b/recipes/proj/all/test_package/test_package.c @@ -0,0 +1,52 @@ +/* From PROJ quickstart */ + +#include +#include + +int main (void) { + PJ_CONTEXT *C; + PJ *P; + PJ* P_for_GIS; + PJ_COORD a, b; + + /* or you may set C=PJ_DEFAULT_CTX if you are sure you will */ + /* use PJ objects from only one thread */ + C = proj_context_create(); + + P = proj_create_crs_to_crs (C, + "EPSG:4326", + "+proj=utm +zone=32 +datum=WGS84", /* or EPSG:32632 */ + NULL); + + if (0==P) { + fprintf(stderr, "Oops\n"); + return 1; + } + + /* This will ensure that the order of coordinates for the input CRS */ + /* will be longitude, latitude, whereas EPSG:4326 mandates latitude, */ + /* longitude */ + P_for_GIS = proj_normalize_for_visualization(C, P); + if( 0 == P_for_GIS ) { + fprintf(stderr, "Oops\n"); + return 1; + } + proj_destroy(P); + 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 + /* coordinates is longitude, latitude, and values are expressed in degrees. */ + a = proj_coord (12, 55, 0, 0); + + /* transform to UTM zone 32, then back to geographical */ + b = proj_trans (P, PJ_FWD, a); + printf ("easting: %.3f, northing: %.3f\n", b.enu.e, b.enu.n); + b = proj_trans (P, PJ_INV, b); + printf ("longitude: %g, latitude: %g\n", b.lp.lam, b.lp.phi); + + /* Clean up */ + proj_destroy (P); + proj_context_destroy (C); /* may be omitted in the single threaded case */ + return 0; +} diff --git a/recipes/proj/config.yml b/recipes/proj/config.yml new file mode 100644 index 0000000000000..ebeae9ed2047c --- /dev/null +++ b/recipes/proj/config.yml @@ -0,0 +1,3 @@ +versions: + "6.3.0": + folder: all