From 58e5ede06a7fb39c805b851d927e95424f415d02 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Thu, 26 Mar 2020 10:17:27 +0100 Subject: [PATCH] proj: several improvements - 6.x.x folder instead of all, since v7 add options and change cmake target - use exe in sqlite3 package in order to create proj.db during build process, instead of a python script - add threadsafe option - rename conan class - bump sqlite3 version in requirements - remove dl from system_libs - define PROJ_MSVC_DLL_IMPORT if shared and Visual Studio - add generated execs folder to env PATH - install proj.db in res folder - define PROJ4 as CMake exported target --- recipes/proj/{all => 6.x.x}/CMakeLists.txt | 2 +- recipes/proj/6.x.x/conandata.yml | 8 +++ recipes/proj/{all => 6.x.x}/conanfile.py | 39 ++++++++++----- .../proj/6.x.x/patches/conanize-cmake.patch | 21 ++++++++ .../test_package/CMakeLists.txt | 6 +-- .../{all => 6.x.x}/test_package/conanfile.py | 3 -- .../test_package/test_package.c | 0 recipes/proj/all/conandata.yml | 11 ----- .../0001-Include-libdl-for-sqlite.patch | 25 ---------- .../0002-Use-python-instead-of-sqlite.patch | 49 ------------------- recipes/proj/all/sqlite_init.py | 7 --- recipes/proj/config.yml | 2 +- 12 files changed, 61 insertions(+), 112 deletions(-) rename recipes/proj/{all => 6.x.x}/CMakeLists.txt (75%) create mode 100644 recipes/proj/6.x.x/conandata.yml rename recipes/proj/{all => 6.x.x}/conanfile.py (59%) create mode 100644 recipes/proj/6.x.x/patches/conanize-cmake.patch rename recipes/proj/{all => 6.x.x}/test_package/CMakeLists.txt (57%) rename recipes/proj/{all => 6.x.x}/test_package/conanfile.py (90%) rename recipes/proj/{all => 6.x.x}/test_package/test_package.c (100%) delete mode 100644 recipes/proj/all/conandata.yml delete mode 100644 recipes/proj/all/patches/0001-Include-libdl-for-sqlite.patch delete mode 100644 recipes/proj/all/patches/0002-Use-python-instead-of-sqlite.patch delete mode 100644 recipes/proj/all/sqlite_init.py diff --git a/recipes/proj/all/CMakeLists.txt b/recipes/proj/6.x.x/CMakeLists.txt similarity index 75% rename from recipes/proj/all/CMakeLists.txt rename to recipes/proj/6.x.x/CMakeLists.txt index 7a80c0b2c26dc..4d393c7a86c09 100644 --- a/recipes/proj/all/CMakeLists.txt +++ b/recipes/proj/6.x.x/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.1.2) project(cmake_wrapper) include(conanbuildinfo.cmake) diff --git a/recipes/proj/6.x.x/conandata.yml b/recipes/proj/6.x.x/conandata.yml new file mode 100644 index 0000000000000..47a3dfa23698b --- /dev/null +++ b/recipes/proj/6.x.x/conandata.yml @@ -0,0 +1,8 @@ +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/conanize-cmake.patch" + base_path: "source_subfolder" diff --git a/recipes/proj/all/conanfile.py b/recipes/proj/6.x.x/conanfile.py similarity index 59% rename from recipes/proj/all/conanfile.py rename to recipes/proj/6.x.x/conanfile.py index 7564cedeff41e..757dcb0ea7f22 100644 --- a/recipes/proj/all/conanfile.py +++ b/recipes/proj/6.x.x/conanfile.py @@ -1,8 +1,9 @@ from conans import ConanFile, CMake, tools +import glob import os -class LibaecConan(ConanFile): +class ProjConan(ConanFile): name = "proj" license = "MIT" url = "https://github.com/conan-io/conan-center-index" @@ -13,14 +14,16 @@ class LibaecConan(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], + "threadsafe": [True, False] } default_options = { "shared": False, "fPIC": True, + "threadsafe": True } generators = "cmake" - exports_sources = ["CMakeLists.txt", "sqlite_init.py", "patches/*"] + exports_sources = ["CMakeLists.txt", "patches/*"] _cmake = None @@ -37,7 +40,7 @@ def config_options(self): del self.options.fPIC def requirements(self): - self.requires("sqlite3/3.31.0") + self.requires.add("sqlite3/3.31.1") def source(self): tools.get(**self.conan_data["sources"][self.version]) @@ -50,15 +53,22 @@ def _configure_cmake(self): self._cmake = CMake(self) self._cmake.definitions["PROJ_TESTS"] = False self._cmake.definitions["BUILD_LIBPROJ_SHARED"] = self.options.shared + self._cmake.definitions["USE_THREAD"] = self.options.threadsafe + self._cmake.definitions["ENABLE_LTO"] = False + self._cmake.definitions["JNI_SUPPORT"] = False + self._cmake.definitions["BUILD_CCT"] = True + self._cmake.definitions["BUILD_CS2CS"] = True + self._cmake.definitions["BUILD_GEOD"] = True + self._cmake.definitions["BUILD_GIE"] = True + self._cmake.definitions["BUILD_PROJ"] = True + self._cmake.definitions["BUILD_PROJINFO"] = True + self._cmake.definitions["PROJ_DATA_SUBDIR"] = "res" 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() @@ -66,14 +76,21 @@ 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")) + for data_file in glob.glob(os.path.join(self.package_folder, "res", "*")): + if not data_file.endswith("proj.db"): + os.remove(data_file) def package_info(self): + self.cpp_info.names["cmake_find_package"] = "PROJ4" + self.cpp_info.names["cmake_find_package_multi"] = "PROJ4" 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")) + self.cpp_info.system_libs.append("m") + if self.options.threadsafe: + self.cpp_info.system_libs.append("pthread") + if self.options.shared and self.settings.compiler == "Visual Studio": + self.cpp_info.defines.append("PROJ_MSVC_DLL_IMPORT") + self.env_info.PROJ_LIB.append(os.path.join(self.package_folder, "res")) + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/proj/6.x.x/patches/conanize-cmake.patch b/recipes/proj/6.x.x/patches/conanize-cmake.patch new file mode 100644 index 0000000000000..3174250770f1d --- /dev/null +++ b/recipes/proj/6.x.x/patches/conanize-cmake.patch @@ -0,0 +1,21 @@ +--- a/src/lib_proj.cmake ++++ b/src/lib_proj.cmake +@@ -311,7 +311,7 @@ source_group("Source Files\\Transformations" + source_group("Source Files\\ISO19111" + FILES ${SRC_LIBPROJ_ISO19111}) + +-include_directories(${CMAKE_SOURCE_DIR}/include) ++include_directories(${PROJ4_SOURCE_DIR}/include) + + include_directories(${CMAKE_CURRENT_BINARY_DIR}) + source_group("CMake Files" FILES CMakeLists.txt) +@@ -440,8 +440,7 @@ if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT) + target_link_libraries(${PROJ_CORE_TARGET} ${CMAKE_THREAD_LIBS_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} diff --git a/recipes/proj/all/test_package/CMakeLists.txt b/recipes/proj/6.x.x/test_package/CMakeLists.txt similarity index 57% rename from recipes/proj/all/test_package/CMakeLists.txt rename to recipes/proj/6.x.x/test_package/CMakeLists.txt index b727bf869b3e4..ee81befcd0098 100644 --- a/recipes/proj/all/test_package/CMakeLists.txt +++ b/recipes/proj/6.x.x/test_package/CMakeLists.txt @@ -1,11 +1,9 @@ -cmake_minimum_required(VERSION 3.1.3) +cmake_minimum_required(VERSION 2.8.11) 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) +set_property(TARGET ${PROJECT_NAME} PROPERTY LINKER_LANGUAGE CXX) diff --git a/recipes/proj/all/test_package/conanfile.py b/recipes/proj/6.x.x/test_package/conanfile.py similarity index 90% rename from recipes/proj/all/test_package/conanfile.py rename to recipes/proj/6.x.x/test_package/conanfile.py index badbb8306f936..bd7165a553cf4 100644 --- a/recipes/proj/all/test_package/conanfile.py +++ b/recipes/proj/6.x.x/test_package/conanfile.py @@ -1,6 +1,3 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - from conans import ConanFile, CMake, tools import os diff --git a/recipes/proj/all/test_package/test_package.c b/recipes/proj/6.x.x/test_package/test_package.c similarity index 100% rename from recipes/proj/all/test_package/test_package.c rename to recipes/proj/6.x.x/test_package/test_package.c diff --git a/recipes/proj/all/conandata.yml b/recipes/proj/all/conandata.yml deleted file mode 100644 index 386dcfacf39c4..0000000000000 --- a/recipes/proj/all/conandata.yml +++ /dev/null @@ -1,11 +0,0 @@ -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/patches/0001-Include-libdl-for-sqlite.patch b/recipes/proj/all/patches/0001-Include-libdl-for-sqlite.patch deleted file mode 100644 index 746abd5b415e4..0000000000000 --- a/recipes/proj/all/patches/0001-Include-libdl-for-sqlite.patch +++ /dev/null @@ -1,25 +0,0 @@ -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 deleted file mode 100644 index 073c387ce68a4..0000000000000 --- a/recipes/proj/all/patches/0002-Use-python-instead-of-sqlite.patch +++ /dev/null @@ -1,49 +0,0 @@ -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 deleted file mode 100644 index 1f9cd3a2296f8..0000000000000 --- a/recipes/proj/all/sqlite_init.py +++ /dev/null @@ -1,7 +0,0 @@ -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/config.yml b/recipes/proj/config.yml index ebeae9ed2047c..84b1cd5cd0e35 100644 --- a/recipes/proj/config.yml +++ b/recipes/proj/config.yml @@ -1,3 +1,3 @@ versions: "6.3.0": - folder: all + folder: "6.x.x"