From 90e8e89b21f10f14f1268b6f6a7991ec04cfb5fc Mon Sep 17 00:00:00 2001 From: Julien Pilet Date: Wed, 8 Mar 2023 14:15:21 +0100 Subject: [PATCH 1/2] gdal: Add support for spatialite and rasterlite2, update to 3.6.2 --- recipes/gdal/config.yml | 2 + recipes/gdal/post_3.5.0/CMakeLists.txt | 12 + recipes/gdal/post_3.5.0/conandata.yml | 6 + recipes/gdal/post_3.5.0/conanfile.py | 36 +++ .../3.6.2/0-replace-find-package.patch | 266 ++++++++++++++++++ 5 files changed, 322 insertions(+) create mode 100644 recipes/gdal/post_3.5.0/patches/3.6.2/0-replace-find-package.patch diff --git a/recipes/gdal/config.yml b/recipes/gdal/config.yml index 3a324b7465d34..4bc4346545107 100644 --- a/recipes/gdal/config.yml +++ b/recipes/gdal/config.yml @@ -1,4 +1,6 @@ versions: + "3.6.2": + folder: "post_3.5.0" "3.5.2": folder: "post_3.5.0" "3.5.1": diff --git a/recipes/gdal/post_3.5.0/CMakeLists.txt b/recipes/gdal/post_3.5.0/CMakeLists.txt index c0e666f41f1de..7d1d7fd9c4143 100644 --- a/recipes/gdal/post_3.5.0/CMakeLists.txt +++ b/recipes/gdal/post_3.5.0/CMakeLists.txt @@ -76,6 +76,18 @@ endif() if (${GDAL_USE_SQLITE3}) find_package(SQLite3) + set(SQLite3_HAS_MUTEX_ALLOC ON) +endif() + +if (${GDAL_USE_SPATIALITE}) + find_package(libspatialite REQUIRED) + add_library(SPATIALITE::SPATIALITE ALIAS libspatialite::libspatialite) +endif() + +if (${GDAL_USE_RASTERLITE2}) + find_package(librasterlite2 REQUIRED) + add_library(RASTERLITE2::RASTERLITE2 ALIAS librasterlite2::librasterlite2) + string(REPLACE "-beta" "" RASTERLITE2_VERSION_STRING ${librasterlite2_VERSION}) endif() if (${GDAL_USE_LIBXML2}) diff --git a/recipes/gdal/post_3.5.0/conandata.yml b/recipes/gdal/post_3.5.0/conandata.yml index 2dbc2d17b374f..a18607882cedc 100644 --- a/recipes/gdal/post_3.5.0/conandata.yml +++ b/recipes/gdal/post_3.5.0/conandata.yml @@ -1,4 +1,7 @@ sources: + "3.6.2": + url: "https://github.com/OSGeo/gdal/releases/download/v3.6.2/gdal-3.6.2.tar.gz" + sha256: "cd5bf004af85b88414676b0d5694d3192414e556961ee3d47164f3298078a818" "3.5.2": url: "https://github.com/OSGeo/gdal/releases/download/v3.5.2/gdal-3.5.2.tar.gz" sha256: "fbd696e1b2a858fbd2eb3718db16b14ed9ba82521d3578770d480c74fe1146d2" @@ -6,6 +9,9 @@ sources: url: "https://github.com/OSGeo/gdal/releases/download/v3.5.1/gdal-3.5.1.tar.gz" sha256: "7c4406ca010dc8632703a0a326f39e9db25d9f1f6ebaaeca64a963e3fac123d1" patches: + "3.6.2": + - patch_file: "patches/3.6.2/0-replace-find-package.patch" + base_path: "source_subfolder" "3.5.2": - patch_file: "patches/3.5.2/0-replace-find-package.patch" base_path: "source_subfolder" diff --git a/recipes/gdal/post_3.5.0/conanfile.py b/recipes/gdal/post_3.5.0/conanfile.py index d03de4e5125cc..0bd6d62f0a6f4 100644 --- a/recipes/gdal/post_3.5.0/conanfile.py +++ b/recipes/gdal/post_3.5.0/conanfile.py @@ -68,6 +68,8 @@ class GdalConan(ConanFile): "with_proj": [True, False], "with_qhull": [True, False], "with_sqlite3": [True, False], + "with_spatialite": [True, False], + "with_rasterlite2": [True, False], "with_webp": [True, False], "with_xerces": [True, False], "with_xml2": [True, False], @@ -118,6 +120,8 @@ class GdalConan(ConanFile): "with_proj": True, "with_qhull": True, "with_sqlite3": True, + "with_spatialite": True, + "with_rasterlite2": False, "with_webp": False, "with_xerces": False, "with_xml2": False, @@ -275,6 +279,12 @@ def requirements(self): if self.options.with_sqlite3: self.requires("sqlite3/3.39.3") + if self.options.with_spatialite: + self.requires("libspatialite/5.0.1") + + if self.options.with_rasterlite2: + self.requires("librasterlite2/1.1.0-beta1") + if self.options.with_webp: self.requires("libwebp/1.2.4") @@ -314,6 +324,17 @@ def validate(self): self.output.error(msg) raise ConanInvalidConfiguration(msg) + + if self.options.with_spatialite and not self.options.with_sqlite3: + msg = "with_spatialite requires with_sqlite3, but with_sqlite3 is disabled" + self.output.error(msg) + raise ConanInvalidConfiguration(msg) + + if self.options.with_rasterlite2 and not self.options.with_spatialite: + msg = "with_rasterlite2 requires with_spatialite, but with_spatialite is disabled" + self.output.error(msg) + raise ConanInvalidConfiguration(msg) + def source(self): get(self, **self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) @@ -664,6 +685,15 @@ def _configure_cmake(self): cmake.definitions["GDAL_CONAN_PACKAGE_FOR_SQLITE3"] = "sqlite3" cmake.definitions["TARGET_FOR_SQLITE3"] = \ self.dependencies["sqlite3"].cpp_info.get_property("cmake_target_name") + if self.options.with_spatialite: + cmake.definitions["GDAL_USE_SPATIALITE"] = True + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_SPATIALITE"] = "libspatialite" + cmake.definitions["TARGET_FOR_SPATIALITE"] = "libspatialite::libspatialite" + if self.options.with_rasterlite2: + cmake.definitions["GDAL_USE_RASTERLITE2"] = True + cmake.definitions["GDAL_CONAN_PACKAGE_FOR_RASTERLITE2"] = "librasterlite2" + cmake.definitions["TARGET_FOR_RASTERLITE2"] = \ + self.dependencies["librasterlite2"].cpp_info.get_property("cmake_target_name") else: cmake.definitions["SQLite3_FOUND"] = False @@ -868,6 +898,12 @@ def package_info(self): if self.options.with_sqlite3: self.cpp_info.requires.extend(['sqlite3::sqlite']) + if self.options.with_spatialite: + self.cpp_info.requires.extend(['libspatialite::libspatialite']) + + if self.options.with_rasterlite2: + self.cpp_info.requires.extend(['librasterlite2::librasterlite2']) + if self.options.with_webp: self.cpp_info.requires.extend(['libwebp::libwebp']) diff --git a/recipes/gdal/post_3.5.0/patches/3.6.2/0-replace-find-package.patch b/recipes/gdal/post_3.5.0/patches/3.6.2/0-replace-find-package.patch new file mode 100644 index 0000000000000..867a43cc7f1be --- /dev/null +++ b/recipes/gdal/post_3.5.0/patches/3.6.2/0-replace-find-package.patch @@ -0,0 +1,266 @@ +diff --git a/alg/CMakeLists.txt b/alg/CMakeLists.txt +index edf75158c7..4200309ca8 100644 +--- a/alg/CMakeLists.txt ++++ b/alg/CMakeLists.txt +@@ -72,7 +72,7 @@ if (GDAL_USE_OPENCL) + target_sources(alg PRIVATE gdalwarpkernel_opencl.h gdalwarpkernel_opencl.cpp) + endif () + +-gdal_target_link_libraries(alg PRIVATE PROJ::proj) ++target_link_libraries(alg PUBLIC PROJ::proj) + + if (GDAL_USE_QHULL_INTERNAL) + target_compile_definitions(alg PRIVATE -DINTERNAL_QHULL) +diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt +index faba6a825f..f288b97577 100644 +--- a/apps/CMakeLists.txt ++++ b/apps/CMakeLists.txt +@@ -25,7 +25,7 @@ target_include_directories( + appslib PRIVATE $ $ + $ $) + +-gdal_target_link_libraries(appslib PRIVATE PROJ::proj) ++target_link_libraries(appslib PUBLIC PROJ::proj) + + set_property(TARGET appslib PROPERTY POSITION_INDEPENDENT_CODE ${GDAL_OBJECT_LIBRARIES_POSITION_INDEPENDENT_CODE}) + if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16) +diff --git a/cmake/helpers/CheckDependentLibraries.cmake b/cmake/helpers/CheckDependentLibraries.cmake +index be14b66185..a7563d2a17 100644 +--- a/cmake/helpers/CheckDependentLibraries.cmake ++++ b/cmake/helpers/CheckDependentLibraries.cmake +@@ -11,7 +11,10 @@ Detect GDAL dependencies and set variable HAVE_* + include(CheckFunctionExists) + include(CMakeDependentOption) + include(FeatureSummary) +-include(DefineFindPackage2) ++ ++# Conan recipes should rely on config files from generators so let's just disble GDAL's ++include(ConanFindPackage) ++ + include(CheckSymbolExists) + + option( +@@ -111,47 +114,7 @@ macro (gdal_check_package name purpose) + set(_find_dependency_args "") + find_package2(${name} QUIET OUT_DEPENDENCY _find_dependency) + if (NOT DEFINED ${key}_FOUND) +- set(_find_package_args) +- if (_GCP_VERSION) +- list(APPEND _find_package_args ${_GCP_VERSION}) +- endif () +- if (_GCP_CONFIG) +- list(APPEND _find_package_args CONFIG) +- endif () +- if (_GCP_COMPONENTS) +- list(APPEND _find_package_args COMPONENTS ${_GCP_COMPONENTS}) +- endif () +- if (_GCP_PATHS) +- list(APPEND _find_package_args PATHS ${_GCP_PATHS}) +- endif () +- if (_GCP_NAMES) +- set(GDAL_CHECK_PACKAGE_${name}_NAMES "${_GCP_NAMES}" CACHE STRING "Config file name for ${name}") +- mark_as_advanced(GDAL_CHECK_PACKAGE_${name}_NAMES) +- endif () +- if (_GCP_TARGETS) +- set(GDAL_CHECK_PACKAGE_${name}_TARGETS "${_GCP_TARGETS}" CACHE STRING "Target name candidates for ${name}") +- mark_as_advanced(GDAL_CHECK_PACKAGE_${name}_TARGETS) +- endif () +- if (GDAL_CHECK_PACKAGE_${name}_NAMES) +- find_package(${name} NAMES ${GDAL_CHECK_PACKAGE_${name}_NAMES} ${_find_package_args}) +- gdal_check_package_target(${name} ${GDAL_CHECK_PACKAGE_${name}_TARGETS} REQUIRED) +- if (${name}_FOUND) +- get_filename_component(_find_dependency_args "${${name}_CONFIG}" NAME) +- string(REPLACE ";" " " _find_dependency_args "${name} NAMES ${GDAL_CHECK_PACKAGE_${name}_NAMES} CONFIGS ${_find_dependency_args} ${_find_package_args}") +- endif () +- endif () +- if (NOT ${name}_FOUND) +- find_package(${name} ${_find_package_args}) +- if (${name}_FOUND) +- gdal_check_package_target(${name} ${GDAL_CHECK_PACKAGE_${name}_TARGETS}) +- elseif (${key}_FOUND) # Some find modules do not set _FOUND +- gdal_check_package_target(${key} ${GDAL_CHECK_PACKAGE_${name}_TARGETS}) +- set(${name}_FOUND "${key}_FOUND") +- endif () +- if (${name}_FOUND) +- string(REPLACE ";" " " _find_dependency_args "${name} ${_find_package_args}") +- endif() +- endif () ++ message(FATAL_ERROR "Conan recipes should rely on config files from generators so let's just disble GDAL's") + endif () + if (${key}_FOUND OR ${name}_FOUND) + set(HAVE_${key} ON) +@@ -345,14 +308,15 @@ if (GDAL_USE_CRYPTOPP) + endif () + + # First check with CMake config files (starting at version 8, due to issues with earlier ones), and then fallback to the FindPROJ module. +-find_package(PROJ 9 CONFIG QUIET) +-if (NOT PROJ_FOUND) +- find_package(PROJ 8 CONFIG QUIET) +-endif() ++find_package2(PROJ) ++target_include_directories(PROJ::proj INTERFACE ${PROJ_INCLUDE_DIRS}) ++#if (NOT PROJ_FOUND) ++# find_package(proj 8 CONFIG QUIET) ++#endif() + if (PROJ_FOUND) + string(APPEND GDAL_IMPORT_DEPENDENCIES "find_dependency(PROJ ${PROJ_VERSION_MAJOR} CONFIG)\n") + else() +- find_package(PROJ 6.0 REQUIRED) ++ find_package(proj 6.0 REQUIRED) + string(APPEND GDAL_IMPORT_DEPENDENCIES "find_dependency(PROJ 6.0)\n") + endif () + +@@ -412,15 +376,10 @@ gdal_check_package(JSONC "json-c library (external)" CAN_DISABLE + TARGETS json-c::json-c JSONC::JSONC + ) + gdal_internal_library(JSONC REQUIRED) +-if(TARGET json-c::json-c) +- get_target_property(include_dirs json-c::json-c INTERFACE_INCLUDE_DIRECTORIES) +- find_path(GDAL_JSON_INCLUDE_DIR NAMES json.h PATHS ${include_dirs} PATH_SUFFIXES json-c NO_DEFAULT_PATH) +- list(APPEND include_dirs "${GDAL_JSON_INCLUDE_DIR}") +- list(REMOVE_DUPLICATES include_dirs) +- set_target_properties(json-c::json-c PROPERTIES +- INTERFACE_INCLUDE_DIRECTORIES "${GDAL_JSON_INCLUDE_DIR}" +- ) +-endif() ++get_target_property(include_dirs json-c::json-c INTERFACE_INCLUDE_DIRECTORIES) ++list(APPEND include_dirs "${JSONC_INCLUDE_DIRS}/json-c") ++set_target_properties(json-c::json-c PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${include_dirs}") ++message("Setting include for json-c: ${include_dirs}") + + gdal_check_package(OpenCAD "libopencad (external, used by OpenCAD driver)" CAN_DISABLE) + gdal_internal_library(OPENCAD) +@@ -532,7 +491,7 @@ if (GDAL_USE_RASTERLITE2) + endif () + cmake_dependent_option(GDAL_USE_RASTERLITE2 "Set ON to use Rasterlite2" ON HAVE_RASTERLITE2 OFF) + +-find_package(LibKML COMPONENTS DOM ENGINE) ++find_package(LibKML COMPONENTS kmlengine kmldom kmlbase) + if (GDAL_USE_LIBKML) + if (NOT LibKML_FOUND) + message(FATAL_ERROR "Configured to use GDAL_USE_LIBKML, but not found") +diff --git a/cmake/helpers/ConanFindPackage.cmake b/cmake/helpers/ConanFindPackage.cmake +new file mode 100644 +index 0000000000..9dfa8193a3 +--- /dev/null ++++ b/cmake/helpers/ConanFindPackage.cmake +@@ -0,0 +1,43 @@ ++ ++function(define_find_package2 pkgname include_file library_name) ++endfunction() ++ ++function(find_package2 pkgname) ++ set(_options QUIET REQUIRED) ++ set(_oneValueArgs OUT_DEPENDENCY) ++ set(_multiValueArgs) ++ cmake_parse_arguments(arg "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) ++ if(arg_QUIET) ++ set(${pkgname}_FIND_QUIETLY TRUE) ++ endif() ++ if(arg_REQUIRED) ++ set(${pkgname}_FIND_REQUIRED TRUE) ++ endif() ++ ++ string(TOUPPER ${pkgname} key) ++ ++ set(docstring "Configured for conan package ${GDAL_CONAN_PACKAGE_FOR_${key}}") ++ if (DEFINED GDAL_CONAN_PACKAGE_FOR_${key}) ++ message("Using conan package ${GDAL_CONAN_PACKAGE_FOR_${key}} for dependency ${pkgname}") ++ set(conan_package ${GDAL_CONAN_PACKAGE_FOR_${key}}) ++ string(TOUPPER ${conan_package} conan_package_upper) ++ ++ set(${key}_INCLUDE_DIRS "${CONAN_INCLUDE_DIRS_${conan_package_upper}}" CACHE STRING ${docstring}) ++ if (NOT TARGET_FOR_${key}) ++ set(TARGET_FOR_${key} "${conan_package}::${conan_package}") ++ endif() ++ set(${key}_LIBRARIES "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${key}_LIBRARY "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${key}_TARGET "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${pkgname}_INCLUDE_DIRS "CONAN_INCLUDE_DIRS_${conan_package_upper}" CACHE STRING ${docstring}) ++ set(${pkgname}_LIBRARIES "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${pkgname}_LIBRARY "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${pkgname}_TARGET "${TARGET_FOR_${key}}" CACHE STRING ${docstring}) ++ set(${key}_FOUND TRUE CACHE BOOL ${docstring}) ++ ++ else () ++ message("dependency ${pkgname} has no conan package") ++ set(${key}_FOUND FALSE CACHE BOOL ${docstring}) ++ endif() ++ ++endfunction() +diff --git a/frmts/hfa/CMakeLists.txt b/frmts/hfa/CMakeLists.txt +index e5b7138e91..039cac7361 100644 +--- a/frmts/hfa/CMakeLists.txt ++++ b/frmts/hfa/CMakeLists.txt +@@ -15,7 +15,8 @@ add_gdal_driver( + hfa_overviews.cpp + BUILTIN) + gdal_standard_includes(gdal_HFA) +-target_include_directories(gdal_HFA PRIVATE $) ++target_link_libraries(gdal_HFA INTERFACE PROJ::proj) ++target_include_directories(gdal_HFA PRIVATE ${PROJ_INCLUDE_DIRS}) + target_compile_definitions(gdal_HFA PRIVATE $) + + if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12) +diff --git a/gdal.cmake b/gdal.cmake +index 0b9ce5169f..df90eb27aa 100644 +--- a/gdal.cmake ++++ b/gdal.cmake +@@ -844,25 +844,6 @@ if (NOT GDAL_ENABLE_MACOSX_FRAMEWORK) + ${CMAKE_CURRENT_BINARY_DIR}/GDALConfig.cmake @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/GDALConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/gdal/) + +- # Generate gdal-config utility command and pkg-config module gdal.pc +- include(GdalGenerateConfig) +- gdal_generate_config( +- TARGET +- "${GDAL_LIB_TARGET_NAME}" +- GLOBAL_PROPERTY +- "gdal_private_link_libraries" +- GDAL_CONFIG +- "${PROJECT_BINARY_DIR}/apps/gdal-config" +- PKG_CONFIG +- "${CMAKE_CURRENT_BINARY_DIR}/gdal.pc") +- install( +- PROGRAMS ${PROJECT_BINARY_DIR}/apps/gdal-config +- DESTINATION ${CMAKE_INSTALL_BINDIR} +- COMPONENT applications) +- install( +- FILES ${CMAKE_CURRENT_BINARY_DIR}/gdal.pc +- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig +- COMPONENT libraries) + endif () + + configure_file(${GDAL_CMAKE_TEMPLATE_PATH}/uninstall.cmake.in ${PROJECT_BINARY_DIR}/cmake_uninstall.cmake @ONLY) +diff --git a/ogr/CMakeLists.txt b/ogr/CMakeLists.txt +index 776e804025..69f0a5caff 100644 +--- a/ogr/CMakeLists.txt ++++ b/ogr/CMakeLists.txt +@@ -89,12 +89,12 @@ endif () + + target_compile_definitions(ogr PRIVATE HAVE_MITAB) + +-gdal_target_link_libraries(ogr PRIVATE PROJ::proj) ++target_link_libraries(ogr PUBLIC PROJ::proj) + + # External libs then + if (GDAL_USE_GEOS) + target_compile_definitions(ogr PRIVATE -DHAVE_GEOS=1) +- gdal_target_link_libraries(ogr PRIVATE ${GEOS_TARGET}) ++ target_link_libraries(ogr PUBLIC ${GEOS_TARGET}) + endif () + + if (GDAL_USE_SFCGAL) +diff --git a/ogr/ogr_proj_p.h b/ogr/ogr_proj_p.h +index 1440432f29..2d330ecb32 100644 +--- a/ogr/ogr_proj_p.h ++++ b/ogr/ogr_proj_p.h +@@ -29,7 +29,7 @@ + #ifndef OGR_PROJ_P_H_INCLUDED + #define OGR_PROJ_P_H_INCLUDED + +-#include "proj.h" ++#include + + #include "cpl_mem_cache.h" + From e40bd810ab09eb6f02753c6c4f03e0d8a547f01d Mon Sep 17 00:00:00 2001 From: Julien Pilet Date: Thu, 9 Mar 2023 09:02:12 +0100 Subject: [PATCH 2/2] Disable sqlite3 and spatialite by default --- recipes/gdal/post_3.5.0/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/gdal/post_3.5.0/conanfile.py b/recipes/gdal/post_3.5.0/conanfile.py index 0bd6d62f0a6f4..8f548e53583ff 100644 --- a/recipes/gdal/post_3.5.0/conanfile.py +++ b/recipes/gdal/post_3.5.0/conanfile.py @@ -119,8 +119,8 @@ class GdalConan(ConanFile): "with_poppler": False, "with_proj": True, "with_qhull": True, - "with_sqlite3": True, - "with_spatialite": True, + "with_sqlite3": False, + "with_spatialite": False, "with_rasterlite2": False, "with_webp": False, "with_xerces": False,