diff --git a/.gitignore b/.gitignore index 6a1f50c..006df60 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .docker/ **/build +**/build-release +**/build-aux velox/all/source_subfolder diff --git a/build.py b/build.py index 472697c..0480fda 100644 --- a/build.py +++ b/build.py @@ -61,7 +61,7 @@ def system(command): system("conan export marisa/all marisa/0.2.6@") system("conan export meson/all meson/1.2.2@") system("conan export ninja/all ninja/1.11.1@") - system("conan export nlohmann_json/all nlohmann_json/3.11.2@") + system("conan export nlohmann_json/all nlohmann_json/3.11.3@") system("conan export onetbb/all onetbb/2021.7.0@") system("conan export onetbb/all onetbb/2021.9.0@") system("conan export opentelemetry-proto/all opentelemetry-proto/0.19.0@") @@ -80,7 +80,17 @@ def system(command): system("conan export xz_utils/all xz_utils/5.4.0@") system("conan export yaml-cpp/all yaml-cpp/0.7.0@") system("conan export zlib/all zlib/1.2.13@") - system("conan export zstd/all zstd/1.5.4@") + system("conan export zstd/all zstd/1.5.5@") system("conan export b2/portable b2/5.2.1@") system("conan export cmake/binary cmake/3.30.0@") system("conan export openssl/3.x.x openssl/3.1.2@") + + system("conan export rocksdb/all rocksdb/6.29.5@milvus/dev") + #gdal related + system("conan export json-c/all json-c/0.17@") + system("conan export sqlite3/all sqlite3/3.44.2@") + system("conan export proj/all proj/9.3.1@") + system("conan export libtiff/all libtiff/4.6.0@") + system("conan export libgeotiff/all libgeotiff/1.7.1@") + system("conan export geos/all geos/3.12.0@") + system("conan export gdal/all gdal/3.5.3@") diff --git a/gdal/all/conanfile.py b/gdal/all/conanfile.py index 75862a5..859bbe6 100644 --- a/gdal/all/conanfile.py +++ b/gdal/all/conanfile.py @@ -90,7 +90,7 @@ class GdalConan(ConanFile): } default_options = { "shared": True, - "fPIC": False, + "fPIC": True, "tools": False, "with_armadillo": False, "with_arrow": True, @@ -103,23 +103,23 @@ class GdalConan(ConanFile): "with_curl": True, "with_dds": False, "with_ecw": False, - "with_expat": True, + "with_expat": False, "with_exr": False, "with_freexl": False, "with_geos": True, - "with_gif": True, + "with_gif": False, "with_gta": False, "with_hdf4": False, "with_hdf5": False, "with_heif": False, - "with_jpeg": "libjpeg", + "with_jpeg": False, "with_jxl": False, "with_kea": False, "with_lerc": False, "with_libaec": False, "with_libarchive": False, "with_libcsf": False, - "with_libdeflate": True, + "with_libdeflate": False, "with_libiconv": True, "with_libkml": False, "with_libtiff": "deprecated", @@ -137,14 +137,14 @@ class GdalConan(ConanFile): "with_pcre2": False, # "with_pdfium": False, "with_pg": False, - "with_png": True, + "with_png": False, "with_podofo": False, "with_poppler": False, "with_proj": "deprecated", "with_publicdecompwt": False, - "with_qhull": True, + "with_qhull": False, "with_rasterlite2": False, - "with_shapelib": True, + "with_shapelib": False, "with_spatialite": False, "with_sqlite3": False, "with_tiledb": False, diff --git a/geos/all/conandata.yml b/geos/all/conandata.yml new file mode 100644 index 0000000..e6c8d9c --- /dev/null +++ b/geos/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "3.12.0": + url: "https://github.com/libgeos/geos/releases/download/3.12.0/geos-3.12.0.tar.bz2" + sha256: "d96db96011259178a35555a0f6d6e75a739e52a495a6b2aa5efb3d75390fbc39" diff --git a/geos/all/conanfile.py b/geos/all/conanfile.py new file mode 100644 index 0000000..1eefc04 --- /dev/null +++ b/geos/all/conanfile.py @@ -0,0 +1,156 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd, stdcpp_library +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir, replace_in_file +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.54.0" + + +class GeosConan(ConanFile): + name = "geos" + description = "GEOS is a C++ library for performing operations on two-dimensional vector geometries." + license = "LGPL-2.1" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://libgeos.org/" + topics = ("osgeo", "geometry", "topology", "geospatial") + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "inline": [True, False], + "utils": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "inline": True, + "utils": True, + } + + @property + def _min_cppstd(self): + return "14" if Version(self.version) >= "3.12.0" else "11" + + @property + def _compilers_minimum_version(self): + return { + "14": { + "gcc": "6", + "clang": "5", + "apple-clang": "10", + "Visual Studio": "15", + "msvc": "191", + }, + }.get(self._min_cppstd, {}) + + @property + def _has_inline_option(self): + return Version(self.version) < "3.11.0" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if not self._has_inline_option: + del self.options.inline + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.settings.compiler.cppstd: + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if Version(self.version) < "3.11.0": + # these 2 options are declared before project() in geos < 3.11.0 + tc.cache_variables["BUILD_SHARED_LIBS"] = self.options.shared + tc.cache_variables["BUILD_BENCHMARKS"] = False + else: + tc.variables["BUILD_BENCHMARKS"] = False + tc.cache_variables["CMAKE_BUILD_TYPE"] = str(self.settings.build_type) + if self._has_inline_option: + tc.variables["DISABLE_GEOS_INLINE"] = not self.options.inline + tc.variables["BUILD_TESTING"] = False + tc.variables["BUILD_DOCUMENTATION"] = False + tc.variables["BUILD_ASTYLE"] = False + tc.variables["BUILD_GEOSOP"] = self.options.utils + tc.generate() + + def _patch_sources(self): + # Avoid setting CMAKE_BUILD_TYPE default when multi-config generators are used. + # https://github.com/libgeos/geos/pull/945 + if Version(self.version) <= "3.12.1": + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "set(CMAKE_BUILD_TYPE ${DEFAULT_BUILD_TYPE})", "") + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + copy(self, "geos.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "geos") + # Avoid to create unwanted geos::geos target + # (geos_c component overrides this global target and it's fine since it depends on all other components) + self.cpp_info.set_property("cmake_target_name", "GEOS::geos_c") + self.cpp_info.set_property("pkg_config_name", "geos") + + self.cpp_info.filenames["cmake_find_package"] = "geos" + self.cpp_info.filenames["cmake_find_package_multi"] = "geos" + self.cpp_info.names["cmake_find_package"] = "GEOS" + self.cpp_info.names["cmake_find_package_multi"] = "GEOS" + + # GEOS::geos_cxx_flags + self.cpp_info.components["geos_cxx_flags"].set_property("cmake_target_name", "GEOS::geos_cxx_flags") + self.cpp_info.components["geos_cxx_flags"].defines.append("USE_UNSTABLE_GEOS_CPP_API") + if self.options.get_safe("inline"): + self.cpp_info.components["geos_cxx_flags"].defines.append("GEOS_INLINE") + if self.settings.os == "Windows": + self.cpp_info.components["geos_cxx_flags"].defines.append("TTMATH_NOASM") + + # GEOS::geos + self.cpp_info.components["geos_cpp"].set_property("cmake_target_name", "GEOS::geos") + self.cpp_info.components["geos_cpp"].names["cmake_find_package"] = "geos" + self.cpp_info.components["geos_cpp"].names["cmake_find_package_multi"] = "geos" + self.cpp_info.components["geos_cpp"].libs = ["geos"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["geos_cpp"].system_libs.append("m") + if not self.options.shared: + libcxx = stdcpp_library(self) + if libcxx: + self.cpp_info.components["geos_cpp"].system_libs.append(libcxx) + self.cpp_info.components["geos_cpp"].requires = ["geos_cxx_flags"] + + # GEOS::geos_c + self.cpp_info.components["geos_c"].set_property("cmake_target_name", "GEOS::geos_c") + self.cpp_info.components["geos_c"].libs = ["geos_c"] + self.cpp_info.components["geos_c"].requires = ["geos_cpp"] + + if self.options.utils: + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/geos/all/test_package/CMakeLists.txt b/geos/all/test_package/CMakeLists.txt new file mode 100644 index 0000000..18b3080 --- /dev/null +++ b/geos/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(geos CONFIG REQUIRED geos_c) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE GEOS::geos_c) diff --git a/geos/all/test_package/conanfile.py b/geos/all/test_package/conanfile.py new file mode 100644 index 0000000..0a6bc68 --- /dev/null +++ b/geos/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/geos/all/test_package/test_package.c b/geos/all/test_package/test_package.c new file mode 100644 index 0000000..d5eb60e --- /dev/null +++ b/geos/all/test_package/test_package.c @@ -0,0 +1,37 @@ +#include + +#include +#include +#include + +void notice(const char *fmt, ...) { + va_list ap; + + fprintf(stdout, "NOTICE: "); + + va_start(ap, fmt); + vfprintf(stdout, fmt, ap); + va_end(ap); + fprintf(stdout, "\n"); +} + +void log_and_exit(const char *fmt, ...) { + va_list ap; + + fprintf(stdout, "ERROR: "); + + va_start(ap, fmt); + vfprintf(stdout, fmt, ap); + va_end(ap); + fprintf(stdout, "\n"); + exit(1); +} + +int main() { + initGEOS(notice, log_and_exit); + printf("GEOS version %s\n", GEOSversion()); + + finishGEOS(); + + return EXIT_SUCCESS; +} diff --git a/geos/all/test_v1_package/CMakeLists.txt b/geos/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000..0d20897 --- /dev/null +++ b/geos/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/geos/all/test_v1_package/conanfile.py b/geos/all/test_v1_package/conanfile.py new file mode 100644 index 0000000..38f4483 --- /dev/null +++ b/geos/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/geos/config.yml b/geos/config.yml new file mode 100644 index 0000000..9bd12ad --- /dev/null +++ b/geos/config.yml @@ -0,0 +1,4 @@ +versions: + "3.12.0": + folder: all + diff --git a/json-c/all/conandata.yml b/json-c/all/conandata.yml new file mode 100644 index 0000000..382ee21 --- /dev/null +++ b/json-c/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.17": + url: "https://github.com/json-c/json-c/archive/json-c-0.17-20230812.tar.gz" + sha256: "024d302a3aadcbf9f78735320a6d5aedf8b77876c8ac8bbb95081ca55054c7eb" \ No newline at end of file diff --git a/json-c/all/conanfile.py b/json-c/all/conanfile.py new file mode 100644 index 0000000..2035858 --- /dev/null +++ b/json-c/all/conanfile.py @@ -0,0 +1,75 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.54.0" + + +class JSONCConan(ConanFile): + name = "json-c" + description = "A JSON implementation in C" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/json-c/json-c" + topics = ("json", "encoding", "decoding", "manipulation") + + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + if Version(self.version) >= "0.15": + tc.variables["BUILD_STATIC_LIBS"] = not self.options.shared + tc.variables["DISABLE_STATIC_FPIC"] = not self.options.get_safe("fPIC", True) + # To install relocatable shared libs on Macos + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW" + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.libs = ["json-c"] + + self.cpp_info.set_property("cmake_file_name", "json-c") + self.cpp_info.set_property("cmake_target_name", "json-c::json-c") + self.cpp_info.set_property("pkg_config_name", "json-c") + self.cpp_info.includedirs = ["include", os.path.join("include", "json-c")] + + if Version(self.version) >= "0.17" and self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["m",]) diff --git a/json-c/all/test_package/CMakeLists.txt b/json-c/all/test_package/CMakeLists.txt new file mode 100644 index 0000000..5e91efd --- /dev/null +++ b/json-c/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(json-c REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE json-c::json-c) diff --git a/json-c/all/test_package/conanfile.py b/json-c/all/test_package/conanfile.py new file mode 100644 index 0000000..0a6bc68 --- /dev/null +++ b/json-c/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/json-c/all/test_package/test_package.c b/json-c/all/test_package/test_package.c new file mode 100644 index 0000000..00498b7 --- /dev/null +++ b/json-c/all/test_package/test_package.c @@ -0,0 +1,29 @@ +#include +#include +#include + +int main() { + /*Creating a json object*/ + json_object * jobj = json_object_new_object(); + + /*Creating a json array*/ + json_object *jarray = json_object_new_array(); + + /*Creating json strings*/ + json_object *jstring1 = json_object_new_string("c"); + json_object *jstring2 = json_object_new_string("c++"); + json_object *jstring3 = json_object_new_string("php"); + + /*Adding the above created json strings to the array*/ + json_object_array_add(jarray,jstring1); + json_object_array_add(jarray,jstring2); + json_object_array_add(jarray,jstring3); + + /*Form the json object*/ + json_object_object_add(jobj,"Categories", jarray); + + /*Now printing the json object*/ + printf ("The json object created: %s\n",json_object_to_json_string(jobj)); + + return EXIT_SUCCESS; +} diff --git a/json-c/all/test_v1_package/CMakeLists.txt b/json-c/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000..0d20897 --- /dev/null +++ b/json-c/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/json-c/all/test_v1_package/conanfile.py b/json-c/all/test_v1_package/conanfile.py new file mode 100644 index 0000000..38f4483 --- /dev/null +++ b/json-c/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/json-c/config.yml b/json-c/config.yml new file mode 100644 index 0000000..5b74371 --- /dev/null +++ b/json-c/config.yml @@ -0,0 +1,4 @@ +versions: + "0.17": + folder: all + diff --git a/libgeotiff/all/conandata.yml b/libgeotiff/all/conandata.yml new file mode 100644 index 0000000..649caea --- /dev/null +++ b/libgeotiff/all/conandata.yml @@ -0,0 +1,7 @@ +sources: + "1.7.1": + url: "https://github.com/OSGeo/libgeotiff/releases/download/1.7.1/libgeotiff-1.7.1.tar.gz" + sha256: "05ab1347aaa471fc97347d8d4269ff0c00f30fa666d956baba37948ec87e55d6" +patches: + "1.7.1": + - patch_file: "patches/fix-cmake-1.7.1.patch" diff --git a/libgeotiff/all/conanfile.py b/libgeotiff/all/conanfile.py new file mode 100644 index 0000000..557e23e --- /dev/null +++ b/libgeotiff/all/conanfile.py @@ -0,0 +1,127 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, collect_libs, copy, export_conandata_patches, get, rmdir, save +import os +import textwrap + +required_conan_version = ">=1.53.0" + + +class LibgeotiffConan(ConanFile): + name = "libgeotiff" + description = "Libgeotiff is an open source library normally hosted on top " \ + "of libtiff for reading, and writing GeoTIFF information tags." + license = ["MIT", "BSD-3-Clause"] + topics = ("geotiff", "tiff") + homepage = "https://github.com/OSGeo/libgeotiff" + url = "https://github.com/conan-io/conan-center-index" + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + # libgeotiff/include/xtiffio.h includes libtiff/include/tiffio.h + self.requires("libtiff/4.6.0", transitive_headers=True, transitive_libs=True) + self.requires("proj/9.3.1") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["WITH_UTILITIES"] = False + tc.variables["WITH_TOWGS84"] = True + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + apply_conandata_patches(self) + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "cmake")) + rmdir(self, os.path.join(self.package_folder, "doc")) + rmdir(self, os.path.join(self.package_folder, "share")) + self._create_cmake_module_variables( + os.path.join(self.package_folder, self._module_vars_file) + ) + self._create_cmake_module_alias_targets( + os.path.join(self.package_folder, self._module_target_file), + {"geotiff_library": "geotiff::geotiff"} + ) + + def _create_cmake_module_variables(self, module_file): + content = textwrap.dedent("""\ + set(GEOTIFF_FOUND ${GeoTIFF_FOUND}) + if(DEFINED GeoTIFF_INCLUDE_DIR) + set(GEOTIFF_INCLUDE_DIR ${GeoTIFF_INCLUDE_DIR}) + endif() + if(DEFINED GeoTIFF_LIBRARIES) + set(GEOTIFF_LIBRARIES ${GeoTIFF_LIBRARIES}) + endif() + """) + save(self, module_file, content) + + def _create_cmake_module_alias_targets(self, module_file, targets): + content = "" + for alias, aliased in targets.items(): + content += textwrap.dedent(f"""\ + if(TARGET {aliased} AND NOT TARGET {alias}) + add_library({alias} INTERFACE IMPORTED) + set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased}) + endif() + """) + save(self, module_file, content) + + @property + def _module_vars_file(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake") + + @property + def _module_target_file(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-targets.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_module_file_name", "GeoTIFF") + self.cpp_info.set_property("cmake_build_modules", [self._module_vars_file]) + self.cpp_info.set_property("cmake_file_name", "geotiff") + self.cpp_info.set_property("cmake_target_name", "geotiff_library") + + self.cpp_info.names["cmake_find_package"] = "GeoTIFF" + self.cpp_info.names["cmake_find_package_multi"] = "geotiff" + self.cpp_info.build_modules["cmake_find_package"] = [self._module_vars_file] + self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_target_file] + + self.cpp_info.libs = collect_libs(self) + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("m") diff --git a/libgeotiff/all/patches/fix-cmake-1.5.1.patch b/libgeotiff/all/patches/fix-cmake-1.5.1.patch new file mode 100644 index 0000000..ad58c33 --- /dev/null +++ b/libgeotiff/all/patches/fix-cmake-1.5.1.patch @@ -0,0 +1,102 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -5,6 +5,7 @@ + # Author: Mateusz Loskot + # + ############################################################################### ++CMAKE_MINIMUM_REQUIRED(VERSION 3.1) + PROJECT(GeoTIFF) + + SET(GEOTIFF_LIB_NAME geotiff) +@@ -12,7 +13,6 @@ SET(GEOTIFF_LIBRARY_TARGET geotiff_library) + + ############################################################################## + # CMake settings +-CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0) + + SET(CMAKE_COLOR_MAKEFILE ON) + +@@ -54,7 +54,7 @@ IF(CMAKE_BUILD_TYPE MATCHES Debug) + SET(GEOTIFF_BUILD_PEDANTIC TRUE) + ENDIF() + +-if (CMAKE_MAJOR_VERSION GREATER 2) ++if(0) # No ! we want CMP0042 NEW for relocatable shared lib on macOS + cmake_policy(SET CMP0022 OLD) # interface link libraries + cmake_policy(SET CMP0042 OLD) # osx rpath + endif() +@@ -80,8 +80,9 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) + + IF(WIN32) + IF(MSVC) +- ADD_DEFINITIONS(-DBUILD_AS_DLL=1) +- ADD_DEFINITIONS(/DW4) ++ IF(BUILD_SHARED_LIBS) ++ ADD_DEFINITIONS(-DBUILD_AS_DLL=1) ++ ENDIF() + if (NOT (MSVC_VERSION VERSION_LESS 1400)) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) +@@ -92,7 +93,7 @@ IF(WIN32) + ENDIF() + + IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) +- SET(COMPILE_FLAGS "-fPIC -Wall -Wno-long-long") ++ SET(COMPILE_FLAGS "-Wall -Wno-long-long") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILE_FLAGS} -std=c99") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILE_FLAGS} -std=c++98") + IF(GEOTIFF_BUILD_PEDANTIC) +@@ -120,6 +121,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}) + INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/libxtiff) + + # TIFF support - required, default=ON ++if(0) + SET(WITH_TIFF TRUE CACHE BOOL "Choose if TIFF support should be built") + + FIND_PACKAGE(PROJ NO_MODULE QUIET) +@@ -192,6 +194,7 @@ IF(WITH_TIFF) + ADD_DEFINITIONS(-DHAVE_TIFF=1) + ENDIF(TIFF_FOUND) + ENDIF(WITH_TIFF) ++endif() + + # Turn off TOWGS84 support + SET(WITH_TOWGS84 TRUE CACHE BOOL "Build with TOWGS84 support") +@@ -300,7 +303,6 @@ INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION include) + ############################################################################### + # Build libxtiff library + +-ADD_SUBDIRECTORY(libxtiff) + + ############################################################################### + # Build libgeotiff library +@@ -345,7 +347,7 @@ IF(UNIX) + VERSION ${LINK_VERSION} + SOVERSION ${LINK_SOVERSION} + CLEAN_DIRECT_OUTPUT 1 ) +- if (APPLE) ++ if (0) # no custom install_name, we want @rpath + set_target_properties( + ${GEOTIFF_LIBRARY_TARGET} + PROPERTIES +@@ -361,11 +363,15 @@ ENDIF(UNIX) + SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES + OUTPUT_NAME ${GEOTIFF_LIB_NAME}) + +-TARGET_LINK_LIBRARIES(${GEOTIFF_LIBRARY_TARGET} +- ${TIFF_LIBRARIES} +- ${PROJ_LIBRARIES} +- ${ZLIB_LIBRARIES} +- ${JPEG_LIBRARIES}) ++find_package(TIFF REQUIRED) ++target_link_libraries(${GEOTIFF_LIBRARY_TARGET} TIFF::TIFF) ++find_package(proj4 QUIET CONFIG) ++if(TARGET PROJ4::proj) ++ target_link_libraries(${GEOTIFF_LIBRARY_TARGET} PROJ4::proj) ++else() ++ find_package(proj REQUIRED CONFIG) ++ target_link_libraries(${GEOTIFF_LIBRARY_TARGET} PROJ::proj) ++endif() + + # INSTALL(TARGETS ${GEOTIFF_ARCHIVE_TARGET} ${GEOTIFF_LIBRARY_TARGET} + # RUNTIME DESTINATION ${GEOTIFF_BIN_DIR} diff --git a/libgeotiff/all/patches/fix-cmake-1.6.0.patch b/libgeotiff/all/patches/fix-cmake-1.6.0.patch new file mode 100644 index 0000000..b6dc6db --- /dev/null +++ b/libgeotiff/all/patches/fix-cmake-1.6.0.patch @@ -0,0 +1,102 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -5,6 +5,7 @@ + # Author: Mateusz Loskot + # + ############################################################################### ++CMAKE_MINIMUM_REQUIRED(VERSION 3.1) + PROJECT(GeoTIFF) + + SET(GEOTIFF_LIB_NAME geotiff) +@@ -12,7 +13,6 @@ SET(GEOTIFF_LIBRARY_TARGET geotiff_library) + + ############################################################################## + # CMake settings +-CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0) + + SET(CMAKE_COLOR_MAKEFILE ON) + +@@ -54,7 +54,7 @@ IF(CMAKE_BUILD_TYPE MATCHES Debug) + SET(GEOTIFF_BUILD_PEDANTIC TRUE) + ENDIF() + +-if (CMAKE_MAJOR_VERSION GREATER 2) ++if(0) # No ! we want CMP0042 NEW for relocatable shared lib on macOS + cmake_policy(SET CMP0022 OLD) # interface link libraries + cmake_policy(SET CMP0042 OLD) # osx rpath + endif() +@@ -80,8 +80,9 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) + + IF(WIN32) + IF(MSVC) +- ADD_DEFINITIONS(-DBUILD_AS_DLL=1) +- ADD_DEFINITIONS(/DW4) ++ IF(BUILD_SHARED_LIBS) ++ ADD_DEFINITIONS(-DBUILD_AS_DLL=1) ++ ENDIF() + if (NOT (MSVC_VERSION VERSION_LESS 1400)) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) +@@ -92,7 +93,7 @@ IF(WIN32) + ENDIF() + + IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) +- SET(COMPILE_FLAGS "-fPIC -Wall -Wno-long-long") ++ SET(COMPILE_FLAGS "-Wall -Wno-long-long") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILE_FLAGS} -std=c99") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILE_FLAGS} -std=c++98") + IF(GEOTIFF_BUILD_PEDANTIC) +@@ -120,6 +121,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}) + INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/libxtiff) + + # TIFF support - required, default=ON ++if(0) + SET(WITH_TIFF TRUE CACHE BOOL "Choose if TIFF support should be built") + + FIND_PACKAGE(PROJ NO_MODULE QUIET) +@@ -192,6 +194,7 @@ IF(WITH_TIFF) + ADD_DEFINITIONS(-DHAVE_TIFF=1) + ENDIF(TIFF_FOUND) + ENDIF(WITH_TIFF) ++endif() + + # Turn off TOWGS84 support + SET(WITH_TOWGS84 TRUE CACHE BOOL "Build with TOWGS84 support") +@@ -301,7 +304,6 @@ INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION include) + ############################################################################### + # Build libxtiff library + +-ADD_SUBDIRECTORY(libxtiff) + + ############################################################################### + # Build libgeotiff library +@@ -346,7 +348,7 @@ IF(UNIX) + VERSION ${LINK_VERSION} + SOVERSION ${LINK_SOVERSION} + CLEAN_DIRECT_OUTPUT 1 ) +- if (APPLE) ++ if (0) # no custom install_name, we want @rpath + set_target_properties( + ${GEOTIFF_LIBRARY_TARGET} + PROPERTIES +@@ -362,11 +364,15 @@ ENDIF(UNIX) + SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES + OUTPUT_NAME ${GEOTIFF_LIB_NAME}) + +-TARGET_LINK_LIBRARIES(${GEOTIFF_LIBRARY_TARGET} +- ${TIFF_LIBRARIES} +- ${PROJ_LIBRARIES} +- ${ZLIB_LIBRARIES} +- ${JPEG_LIBRARIES}) ++find_package(TIFF REQUIRED) ++target_link_libraries(${GEOTIFF_LIBRARY_TARGET} TIFF::TIFF) ++find_package(proj4 QUIET CONFIG) ++if(TARGET PROJ4::proj) ++ target_link_libraries(${GEOTIFF_LIBRARY_TARGET} PROJ4::proj) ++else() ++ find_package(proj REQUIRED CONFIG) ++ target_link_libraries(${GEOTIFF_LIBRARY_TARGET} PROJ::proj) ++endif() + + # INSTALL(TARGETS ${GEOTIFF_ARCHIVE_TARGET} ${GEOTIFF_LIBRARY_TARGET} + # RUNTIME DESTINATION ${GEOTIFF_BIN_DIR} diff --git a/libgeotiff/all/patches/fix-cmake-1.7.1.patch b/libgeotiff/all/patches/fix-cmake-1.7.1.patch new file mode 100644 index 0000000..4922575 --- /dev/null +++ b/libgeotiff/all/patches/fix-cmake-1.7.1.patch @@ -0,0 +1,78 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -5,6 +5,7 @@ + # Author: Mateusz Loskot + # + ############################################################################### ++CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0) + PROJECT(GeoTIFF) + + SET(GEOTIFF_LIB_NAME geotiff) +@@ -12,7 +13,6 @@ SET(GEOTIFF_LIBRARY_TARGET geotiff_library) + + ############################################################################## + # CMake settings +-CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0) + + SET(CMAKE_COLOR_MAKEFILE ON) + +@@ -88,7 +88,7 @@ IF(WIN32) + ENDIF() + + IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) +- SET(COMPILE_FLAGS "-fPIC -Wall -Wno-long-long") ++ SET(COMPILE_FLAGS "-Wall -Wno-long-long") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILE_FLAGS} -std=c99") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILE_FLAGS} -std=c++98") + IF(GEOTIFF_BUILD_PEDANTIC) +@@ -115,15 +115,14 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/libxtiff) + # TIFF support - required, default=ON + SET(WITH_TIFF TRUE CACHE BOOL "Choose if TIFF support should be built") + +-FIND_PACKAGE(PROJ NO_MODULE QUIET) +-if (NOT PROJ_FOUND) ++FIND_PACKAGE(proj NO_MODULE QUIET) ++if (0) + FIND_PACKAGE(PROJ) + endif () + + IF(PROJ_FOUND) + INCLUDE_DIRECTORIES(${PROJ_INCLUDE_DIR}) + ELSE() +- MESSAGE(FATAL_ERROR "Failed to detect PROJ >= 6") + ENDIF() + + # Zlib support - optional, default=OFF +@@ -164,6 +163,7 @@ IF(WITH_TIFF) + FIND_PACKAGE(TIFF REQUIRED) + endif () + ++ if(0) + IF(TIFF_FOUND) + # Confirm required API is available + INCLUDE(CheckFunctionExists) +@@ -184,6 +184,7 @@ IF(WITH_TIFF) + INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR}) + ADD_DEFINITIONS(-DHAVE_TIFF=1) + ENDIF(TIFF_FOUND) ++ endif() + ENDIF(WITH_TIFF) + + # Turn off TOWGS84 support +@@ -275,7 +276,6 @@ INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION ${GEOTIFF_INCLUDE_DIR}) + ############################################################################### + # Build libxtiff library + +-ADD_SUBDIRECTORY(libxtiff) + + ############################################################################### + # Build libgeotiff library +@@ -319,7 +319,7 @@ if(UNIX) + VERSION ${LINK_VERSION} + SOVERSION ${LINK_SOVERSION} + CLEAN_DIRECT_OUTPUT 1 ) +- if (APPLE) ++ if (0) # no custom install_name, we want @rpath + set_target_properties( + ${GEOTIFF_LIBRARY_TARGET} + PROPERTIES diff --git a/libgeotiff/all/test_package/CMakeLists.txt b/libgeotiff/all/test_package/CMakeLists.txt new file mode 100644 index 0000000..6f7f666 --- /dev/null +++ b/libgeotiff/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(geotiff REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE geotiff_library) diff --git a/libgeotiff/all/test_package/conanfile.py b/libgeotiff/all/test_package/conanfile.py new file mode 100644 index 0000000..0a6bc68 --- /dev/null +++ b/libgeotiff/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/libgeotiff/all/test_package/test_package.c b/libgeotiff/all/test_package/test_package.c new file mode 100644 index 0000000..93799f1 --- /dev/null +++ b/libgeotiff/all/test_package/test_package.c @@ -0,0 +1,98 @@ +/* + * makegeo.c -- example client code for LIBGEO geographic + * TIFF tag support. + * + * Author: Niles D. Ritter + * + * Revision History: + * 31 October, 1995 Fixed reversed lat-long coordinates NDR + * + */ + +#include "geotiffio.h" +#include "xtiffio.h" +#include +#include + +void SetUpTIFFDirectory(TIFF *tif); +void SetUpGeoKeys(GTIF *gtif); +void WriteImage(TIFF *tif); + +#define WIDTH 20L +#define HEIGHT 20L + +int main() +{ + char *fname = "newgeo.tif"; + TIFF *tif; /* TIFF-level descriptor */ + GTIF *gtif; /* GeoKey-level descriptor */ + + tif=XTIFFOpen(fname,"w"); + if (!tif) goto failure; + + gtif = GTIFNew(tif); + if (!gtif) + { + printf("failed in GTIFNew\n"); + goto failure; + } + + SetUpTIFFDirectory(tif); + SetUpGeoKeys(gtif); + WriteImage(tif); + + GTIFWriteKeys(gtif); + GTIFFree(gtif); + XTIFFClose(tif); + return 0; + +failure: + printf("failure in makegeo\n"); + if (tif) TIFFClose(tif); + if (gtif) GTIFFree(gtif); + return -1; +} + + +void SetUpTIFFDirectory(TIFF *tif) +{ + double tiepoints[6]={0,0,0,130.0,32.0,0.0}; + double pixscale[3]={1,1,0}; + + TIFFSetField(tif,TIFFTAG_IMAGEWIDTH, WIDTH); + TIFFSetField(tif,TIFFTAG_IMAGELENGTH, HEIGHT); + TIFFSetField(tif,TIFFTAG_COMPRESSION, COMPRESSION_NONE); + TIFFSetField(tif,TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); + TIFFSetField(tif,TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(tif,TIFFTAG_BITSPERSAMPLE, 8); + TIFFSetField(tif,TIFFTAG_ROWSPERSTRIP, 20L); + + TIFFSetField(tif,TIFFTAG_GEOTIEPOINTS, 6,tiepoints); + TIFFSetField(tif,TIFFTAG_GEOPIXELSCALE, 3,pixscale); +} + +void SetUpGeoKeys(GTIF *gtif) +{ + GTIFKeySet(gtif, GTModelTypeGeoKey, TYPE_SHORT, 1, ModelGeographic); + GTIFKeySet(gtif, GTRasterTypeGeoKey, TYPE_SHORT, 1, RasterPixelIsArea); + GTIFKeySet(gtif, GTCitationGeoKey, TYPE_ASCII, 0, "Just An Example"); + GTIFKeySet(gtif, GeographicTypeGeoKey, TYPE_SHORT, 1, KvUserDefined); + GTIFKeySet(gtif, GeogCitationGeoKey, TYPE_ASCII, 0, "Everest Ellipsoid Used."); + GTIFKeySet(gtif, GeogAngularUnitsGeoKey, TYPE_SHORT, 1, Angular_Degree); + GTIFKeySet(gtif, GeogLinearUnitsGeoKey, TYPE_SHORT, 1, Linear_Meter); + GTIFKeySet(gtif, GeogGeodeticDatumGeoKey, TYPE_SHORT, 1, KvUserDefined); + GTIFKeySet(gtif, GeogEllipsoidGeoKey, TYPE_SHORT, 1, Ellipse_Everest_1830_1967_Definition); + GTIFKeySet(gtif, GeogSemiMajorAxisGeoKey, TYPE_DOUBLE, 1, (double)6377298.556); + GTIFKeySet(gtif, GeogInvFlatteningGeoKey, TYPE_DOUBLE, 1, (double)300.8017); +} + +void WriteImage(TIFF *tif) +{ + int i; + char buffer[WIDTH]; + + memset(buffer,0,(size_t)WIDTH); + for (i=0;i=1.2.11 <2]") + if self.options.libdeflate: + self.requires("libdeflate/1.19") + if self.options.lzma: + self.requires("xz_utils/5.4.5") + if self.options.jpeg == "libjpeg": + self.requires("libjpeg/9e") + elif self.options.jpeg == "libjpeg-turbo": + self.requires("libjpeg-turbo/3.0.2") + elif self.options.jpeg == "mozjpeg": + self.requires("mozjpeg/4.1.5") + if self.options.jbig: + self.requires("jbig/20160605") + if self.options.zstd: + self.requires("zstd/1.5.5") + if self.options.webp: + self.requires("libwebp/1.3.2") + + def validate(self): + if self.options.libdeflate and not self.options.zlib: + raise ConanInvalidConfiguration("libtiff:libdeflate=True requires libtiff:zlib=True") + + def build_requirements(self): + if Version(self.version) >= "4.5.1": + # https://github.com/conan-io/conan/issues/3482#issuecomment-662284561 + self.tool_requires("cmake/[>=3.18 <4]") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["lzma"] = self.options.lzma + tc.variables["jpeg"] = bool(self.options.jpeg) + tc.variables["jpeg12"] = False + tc.variables["jbig"] = self.options.jbig + tc.variables["zlib"] = self.options.zlib + tc.variables["libdeflate"] = self.options.libdeflate + tc.variables["zstd"] = self.options.zstd + tc.variables["webp"] = self.options.webp + tc.variables["lerc"] = False # TODO: add lerc support for libtiff versions >= 4.3.0 + if Version(self.version) >= "4.5.0": + # Disable tools, test, contrib, man & html generation + tc.variables["tiff-tools"] = False + tc.variables["tiff-tests"] = False + tc.variables["tiff-contrib"] = False + tc.variables["tiff-docs"] = False + tc.variables["cxx"] = self.options.cxx + # BUILD_SHARED_LIBS must be set in command line because defined upstream before project() + tc.cache_variables["BUILD_SHARED_LIBS"] = bool(self.options.shared) + tc.cache_variables["CMAKE_FIND_PACKAGE_PREFER_CONFIG"] = True + tc.generate() + deps = CMakeDeps(self) + if Version(self.version) >= "4.5.1": + deps.set_property("jbig", "cmake_target_name", "JBIG::JBIG") + deps.set_property("xz_utils", "cmake_target_name", "liblzma::liblzma") + deps.set_property("libdeflate", "cmake_file_name", "Deflate") + deps.set_property("libdeflate", "cmake_target_name", "Deflate::Deflate") + deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + + # remove FindXXXX for conan dependencies + for module in ["Deflate", "JBIG", "JPEG", "LERC", "WebP", "ZSTD", "liblzma", "LibLZMA"]: + rm(self, f"Find{module}.cmake", os.path.join(self.source_folder, "cmake")) + + # Export symbols of tiffxx for msvc shared + replace_in_file(self, os.path.join(self.source_folder, "libtiff", "CMakeLists.txt"), + "set_target_properties(tiffxx PROPERTIES SOVERSION ${SO_COMPATVERSION})", + "set_target_properties(tiffxx PROPERTIES SOVERSION ${SO_COMPATVERSION} WINDOWS_EXPORT_ALL_SYMBOLS ON)") + + # Disable tools, test, contrib, man & html generation + if Version(self.version) < "4.5.0": + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "add_subdirectory(tools)\nadd_subdirectory(test)\nadd_subdirectory(contrib)\nadd_subdirectory(build)\n" + "add_subdirectory(man)\nadd_subdirectory(html)", "") + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + license_file = "COPYRIGHT" if Version(self.version) < "4.5.0" else "LICENSE.md" + copy(self, license_file, src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"), ignore_case=True, keep_path=False) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "TIFF") + self.cpp_info.set_property("cmake_target_name", "TIFF::TIFF") + self.cpp_info.set_property("pkg_config_name", f"libtiff-{Version(self.version).major}") + suffix = "d" if is_msvc(self) and self.settings.build_type == "Debug" else "" + if self.options.cxx: + self.cpp_info.libs.append(f"tiffxx{suffix}") + self.cpp_info.libs.append(f"tiff{suffix}") + if self.settings.os in ["Linux", "Android", "FreeBSD", "SunOS", "AIX"]: + self.cpp_info.system_libs.append("m") + + self.cpp_info.requires = [] + if self.options.zlib: + self.cpp_info.requires.append("zlib::zlib") + if self.options.libdeflate: + self.cpp_info.requires.append("libdeflate::libdeflate") + if self.options.lzma: + self.cpp_info.requires.append("xz_utils::xz_utils") + if self.options.jpeg == "libjpeg": + self.cpp_info.requires.append("libjpeg::libjpeg") + elif self.options.jpeg == "libjpeg-turbo": + self.cpp_info.requires.append("libjpeg-turbo::jpeg") + elif self.options.jpeg == "mozjpeg": + self.cpp_info.requires.append("mozjpeg::libjpeg") + if self.options.jbig: + self.cpp_info.requires.append("jbig::jbig") + if self.options.zstd: + self.cpp_info.requires.append("zstd::zstd") + if self.options.webp: + self.cpp_info.requires.append("libwebp::libwebp") + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed + self.cpp_info.names["cmake_find_package"] = "TIFF" + self.cpp_info.names["cmake_find_package_multi"] = "TIFF" diff --git a/libtiff/all/patches/4.3.0-0001-cmake-dependencies.patch b/libtiff/all/patches/4.3.0-0001-cmake-dependencies.patch new file mode 100644 index 0000000..497c617 --- /dev/null +++ b/libtiff/all/patches/4.3.0-0001-cmake-dependencies.patch @@ -0,0 +1,91 @@ +--- a/cmake/DeflateCodec.cmake ++++ b/cmake/DeflateCodec.cmake +@@ -35,7 +35,10 @@ set(ZIP_SUPPORT ${ZLIB_SUPPORT}) + + # libdeflate + set(LIBDEFLATE_SUPPORT FALSE) +-find_package(Deflate) ++find_package(libdeflate CONFIG) ++if(libdeflate_FOUND) ++ set(Deflate_FOUND TRUE) ++endif() + option(libdeflate "use libdeflate (optional for faster Deflate support, still requires zlib)" ${Deflate_FOUND}) + if (libdeflate AND Deflate_FOUND AND ZIP_SUPPORT) + set(LIBDEFLATE_SUPPORT TRUE) +--- a/cmake/JBIGCodec.cmake ++++ b/cmake/JBIGCodec.cmake +@@ -27,14 +27,17 @@ + # JBIG-KIT + set(JBIG_SUPPORT FALSE) + +-find_package(JBIG) ++find_package(jbig CONFIG) ++if(jbig_FOUND) ++ set(JBIG_FOUND TRUE) ++endif() + + if(JBIG_FOUND) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${JBIG_LIBRARIES}) +- check_symbol_exists(jbg_newlen "jbig.h" HAVE_JBG_NEWLEN) ++ set(HAVE_JBG_NEWLEN TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + endif() +--- a/cmake/ZSTDCodec.cmake ++++ b/cmake/ZSTDCodec.cmake +@@ -28,14 +28,17 @@ + set(ZSTD_SUPPORT FALSE) + set(ZSTD_USABLE FALSE) + +-find_package(ZSTD) ++find_package(zstd CONFIG) ++if(zstd_FOUND) ++ set(ZSTD_FOUND TRUE) ++endif() + + if(ZSTD_FOUND) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ZSTD_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ZSTD_LIBRARIES}) +- check_symbol_exists(ZSTD_decompressStream "zstd.h" ZSTD_RECENT_ENOUGH) ++ set(ZSTD_RECENT_ENOUGH TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + +--- a/libtiff/CMakeLists.txt ++++ b/libtiff/CMakeLists.txt +@@ -110,7 +110,7 @@ if(ZIP_SUPPORT) + target_link_libraries(tiff PRIVATE ZLIB::ZLIB) + endif() + if(ZIP_SUPPORT AND LIBDEFLATE_SUPPORT) +- target_link_libraries(tiff PRIVATE Deflate::Deflate) ++ target_link_libraries(tiff PRIVATE $,libdeflate::libdeflate,libdeflate::libdeflate_static>) + endif() + if(JPEG_SUPPORT) + target_link_libraries(tiff PRIVATE JPEG::JPEG) +@@ -120,7 +120,7 @@ if(JPEG_SUPPORT) + endif() + endif() + if(JBIG_SUPPORT) +- target_link_libraries(tiff PRIVATE JBIG::JBIG) ++ target_link_libraries(tiff PRIVATE jbig::jbig) + endif() + if(LERC_SUPPORT) + target_link_libraries(tiff PRIVATE LERC::LERC) +@@ -129,10 +129,10 @@ if(LZMA_SUPPORT) + target_link_libraries(tiff PRIVATE LibLZMA::LibLZMA) + endif() + if(ZSTD_SUPPORT) +- target_link_libraries(tiff PRIVATE ZSTD::ZSTD) ++ target_link_libraries(tiff PRIVATE $,zstd::libzstd_shared,zstd::libzstd_static>) + endif() + if(WEBP_SUPPORT) +- target_link_libraries(tiff PRIVATE WebP::WebP) ++ target_link_libraries(tiff PRIVATE WebP::webp) + endif() + target_link_libraries(tiff PRIVATE CMath::CMath) + diff --git a/libtiff/all/patches/4.4.0-0001-cmake-dependencies.patch b/libtiff/all/patches/4.4.0-0001-cmake-dependencies.patch new file mode 100644 index 0000000..e2a9148 --- /dev/null +++ b/libtiff/all/patches/4.4.0-0001-cmake-dependencies.patch @@ -0,0 +1,92 @@ +--- a/cmake/DeflateCodec.cmake ++++ b/cmake/DeflateCodec.cmake +@@ -35,7 +35,10 @@ set(ZIP_SUPPORT ${ZLIB_SUPPORT}) + + # libdeflate + set(LIBDEFLATE_SUPPORT FALSE) +-find_package(Deflate) ++find_package(libdeflate CONFIG) ++if(libdeflate_FOUND) ++ set(Deflate_FOUND TRUE) ++endif() + option(libdeflate "use libdeflate (optional for faster Deflate support, still requires zlib)" ${Deflate_FOUND}) + if (libdeflate AND Deflate_FOUND AND ZIP_SUPPORT) + set(LIBDEFLATE_SUPPORT TRUE) +--- a/cmake/JBIGCodec.cmake ++++ b/cmake/JBIGCodec.cmake +@@ -27,14 +27,17 @@ + # JBIG-KIT + set(JBIG_SUPPORT FALSE) + +-find_package(JBIG) ++find_package(jbig CONFIG) ++if(jbig_FOUND) ++ set(JBIG_FOUND TRUE) ++endif() + + if(JBIG_FOUND) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${JBIG_LIBRARIES}) +- check_symbol_exists(jbg_newlen "jbig.h" HAVE_JBG_NEWLEN) ++ set(HAVE_JBG_NEWLEN TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + endif() +--- a/cmake/ZSTDCodec.cmake ++++ b/cmake/ZSTDCodec.cmake +@@ -28,14 +28,17 @@ + set(ZSTD_SUPPORT FALSE) + set(ZSTD_USABLE FALSE) + +-find_package(ZSTD) ++find_package(zstd CONFIG) ++if(zstd_FOUND) ++ set(ZSTD_FOUND TRUE) ++endif() + + if(ZSTD_FOUND) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ZSTD_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ZSTD_LIBRARIES}) +- check_symbol_exists(ZSTD_decompressStream "zstd.h" ZSTD_RECENT_ENOUGH) ++ set(ZSTD_RECENT_ENOUGH TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + +--- a/libtiff/CMakeLists.txt ++++ b/libtiff/CMakeLists.txt +@@ -114,7 +114,7 @@ if(ZIP_SUPPORT) + string(APPEND tiff_requires_private " zlib") + endif() + if(ZIP_SUPPORT AND LIBDEFLATE_SUPPORT) +- target_link_libraries(tiff PRIVATE Deflate::Deflate) ++ target_link_libraries(tiff PRIVATE $,libdeflate::libdeflate,libdeflate::libdeflate_static>) + list(APPEND tiff_libs_private_list "${Deflate_LIBRARY}") + endif() + if(JPEG_SUPPORT) +@@ -126,7 +126,7 @@ if(JPEG_SUPPORT) + endif() + endif() + if(JBIG_SUPPORT) +- target_link_libraries(tiff PRIVATE JBIG::JBIG) ++ target_link_libraries(tiff PRIVATE jbig::jbig) + list(APPEND tiff_libs_private_list "${JBIG_LIBRARY}") + endif() + if(LERC_SUPPORT) +@@ -141,11 +141,11 @@ if(LZMA_SUPPORT) + string(APPEND tiff_requires_private " liblzma") + endif() + if(ZSTD_SUPPORT) +- target_link_libraries(tiff PRIVATE ZSTD::ZSTD) ++ target_link_libraries(tiff PRIVATE $,zstd::libzstd_shared,zstd::libzstd_static>) + string(APPEND tiff_requires_private " libzstd") + endif() + if(WEBP_SUPPORT) +- target_link_libraries(tiff PRIVATE WebP::WebP) ++ target_link_libraries(tiff PRIVATE WebP::webp) + string(APPEND tiff_requires_private " libwebp") + endif() + target_link_libraries(tiff PRIVATE CMath::CMath) diff --git a/libtiff/all/patches/4.5.0-0001-cmake-dependencies.patch b/libtiff/all/patches/4.5.0-0001-cmake-dependencies.patch new file mode 100644 index 0000000..7780017 --- /dev/null +++ b/libtiff/all/patches/4.5.0-0001-cmake-dependencies.patch @@ -0,0 +1,116 @@ +--- a/cmake/DeflateCodec.cmake ++++ b/cmake/DeflateCodec.cmake +@@ -35,7 +35,10 @@ set(LIBDEFLATE_SUPPORT FALSE) + + # libdeflate + set(LIBDEFLATE_SUPPORT FALSE) +-find_package(Deflate) ++find_package(libdeflate CONFIG) ++if(libdeflate_FOUND) ++ set(Deflate_FOUND TRUE) ++endif() + option(libdeflate "use libdeflate (optional for faster Deflate support, still requires zlib)" ${Deflate_FOUND}) + if (libdeflate AND Deflate_FOUND AND ZIP_SUPPORT) + set(LIBDEFLATE_SUPPORT TRUE) +--- a/cmake/JBIGCodec.cmake ++++ b/cmake/JBIGCodec.cmake +@@ -27,14 +27,17 @@ set(JBIG_SUPPORT FALSE) + # JBIG-KIT + set(JBIG_SUPPORT FALSE) + +-find_package(JBIG) ++find_package(jbig CONFIG) ++if(jbig_FOUND) ++ set(JBIG_FOUND TRUE) ++endif() + + if(JBIG_FOUND) + set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${JBIG_LIBRARIES}) +- check_symbol_exists(jbg_newlen "jbig.h" HAVE_JBG_NEWLEN) ++ set(HAVE_JBG_NEWLEN TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + endif() +--- a/cmake/JPEGCodec.cmake ++++ b/cmake/JPEGCodec.cmake +@@ -47,19 +47,7 @@ + cmake_push_check_state(RESET) + set(CMAKE_REQUIRED_INCLUDES "${JPEG_INCLUDE_DIRS}") + set(CMAKE_REQUIRED_LIBRARIES "${JPEG_LIBRARIES}") +- check_c_source_compiles( +- " +- #include +- #include +- #include \"jpeglib.h\" +- int main() +- { +- jpeg_read_scanlines(0,0,0); +- jpeg12_read_scanlines(0,0,0); +- return 0; +- } +- " +- HAVE_JPEGTURBO_DUAL_MODE_8_12) ++ set(HAVE_JPEGTURBO_DUAL_MODE_8_12 FALSE) + cmake_pop_check_state() + endif() + +--- a/cmake/ZSTDCodec.cmake ++++ b/cmake/ZSTDCodec.cmake +@@ -28,7 +28,10 @@ set(ZSTD_USABLE FALSE) + set(ZSTD_SUPPORT FALSE) + set(ZSTD_USABLE FALSE) + +-find_package(ZSTD) ++find_package(zstd CONFIG) ++if(zstd_FOUND) ++ set(ZSTD_FOUND TRUE) ++endif() + + if(ZSTD_FOUND) + if(NOT DEFINED ZSTD_HAVE_DECOMPRESS_STREAM) +@@ -36,7 +39,7 @@ if(ZSTD_FOUND) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ZSTD_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ZSTD_LIBRARIES}) +- check_symbol_exists(ZSTD_decompressStream "zstd.h" ZSTD_HAVE_DECOMPRESS_STREAM) ++ set(ZSTD_HAVE_DECOMPRESS_STREAM TRUE) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) + endif() +--- a/libtiff/CMakeLists.txt ++++ b/libtiff/CMakeLists.txt +@@ -116,7 +116,7 @@ if(ZIP_SUPPORT AND LIBDEFLATE_SUPPORT) + string(APPEND tiff_requires_private " zlib") + endif() + if(ZIP_SUPPORT AND LIBDEFLATE_SUPPORT) +- target_link_libraries(tiff PRIVATE Deflate::Deflate) ++ target_link_libraries(tiff PRIVATE $,libdeflate::libdeflate,libdeflate::libdeflate_static>) + list(APPEND tiff_libs_private_list "${Deflate_LIBRARY}") + endif() + if(JPEG_SUPPORT) +@@ -130,7 +130,7 @@ if(JBIG_SUPPORT) + endif() + endif() + if(JBIG_SUPPORT) +- target_link_libraries(tiff PRIVATE JBIG::JBIG) ++ target_link_libraries(tiff PRIVATE jbig::jbig) + list(APPEND tiff_libs_private_list "${JBIG_LIBRARY}") + endif() + if(LERC_SUPPORT) +@@ -145,11 +145,11 @@ if(ZSTD_SUPPORT) + string(APPEND tiff_requires_private " liblzma") + endif() + if(ZSTD_SUPPORT) +- target_link_libraries(tiff PRIVATE ZSTD::ZSTD) ++ target_link_libraries(tiff PRIVATE $,zstd::libzstd_shared,zstd::libzstd_static>) + string(APPEND tiff_requires_private " libzstd") + endif() + if(WEBP_SUPPORT) +- target_link_libraries(tiff PRIVATE WebP::WebP) ++ target_link_libraries(tiff PRIVATE WebP::webp) + string(APPEND tiff_requires_private " libwebp") + endif() + if(CMath_LIBRARY) diff --git a/libtiff/all/patches/4.5.1-0001-cmake-dependencies.patch b/libtiff/all/patches/4.5.1-0001-cmake-dependencies.patch new file mode 100644 index 0000000..761950e --- /dev/null +++ b/libtiff/all/patches/4.5.1-0001-cmake-dependencies.patch @@ -0,0 +1,31 @@ +diff --git a/cmake/JPEGCodec.cmake b/cmake/JPEGCodec.cmake +index 8455a3ec..09fe975a 100644 +--- a/cmake/JPEGCodec.cmake ++++ b/cmake/JPEGCodec.cmake +@@ -42,25 +42,7 @@ endif() + if (JPEG_SUPPORT) + # Check for jpeg12_read_scanlines() which has been added in libjpeg-turbo 2.2 + # for dual 8/12 bit mode. +- include(CheckCSourceCompiles) +- include(CMakePushCheckState) +- cmake_push_check_state(RESET) +- set(CMAKE_REQUIRED_INCLUDES "${JPEG_INCLUDE_DIRS}") +- set(CMAKE_REQUIRED_LIBRARIES "${JPEG_LIBRARIES}") +- check_c_source_compiles( +- " +- #include +- #include +- #include \"jpeglib.h\" +- int main() +- { +- jpeg_read_scanlines(0,0,0); +- jpeg12_read_scanlines(0,0,0); +- return 0; +- } +- " +- HAVE_JPEGTURBO_DUAL_MODE_8_12) +- cmake_pop_check_state() ++ set(HAVE_JPEGTURBO_DUAL_MODE_8_12 FALSE) + endif() + + if (NOT HAVE_JPEGTURBO_DUAL_MODE_8_12) diff --git a/libtiff/all/test_package/CMakeLists.txt b/libtiff/all/test_package/CMakeLists.txt new file mode 100644 index 0000000..cd389da --- /dev/null +++ b/libtiff/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +find_package(TIFF REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE TIFF::TIFF) diff --git a/libtiff/all/test_package/conanfile.py b/libtiff/all/test_package/conanfile.py new file mode 100644 index 0000000..0a6bc68 --- /dev/null +++ b/libtiff/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/libtiff/all/test_package/test_package.c b/libtiff/all/test_package/test_package.c new file mode 100644 index 0000000..0b73b99 --- /dev/null +++ b/libtiff/all/test_package/test_package.c @@ -0,0 +1,8 @@ +#include + +int main() +{ + TIFF* tif = TIFFOpen("foo.tif", "w"); + TIFFClose(tif); + return 0; +} diff --git a/libtiff/all/test_v1_package/CMakeLists.txt b/libtiff/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000..0d20897 --- /dev/null +++ b/libtiff/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/libtiff/all/test_v1_package/conanfile.py b/libtiff/all/test_v1_package/conanfile.py new file mode 100644 index 0000000..19e6a0c --- /dev/null +++ b/libtiff/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/libtiff/config.yml b/libtiff/config.yml new file mode 100644 index 0000000..c821764 --- /dev/null +++ b/libtiff/config.yml @@ -0,0 +1,3 @@ +versions: + "4.6.0": + folder: all diff --git a/proj/all/conandata.yml b/proj/all/conandata.yml new file mode 100644 index 0000000..4cfe1ac --- /dev/null +++ b/proj/all/conandata.yml @@ -0,0 +1,10 @@ +sources: + "9.3.1": + url: "https://github.com/OSGeo/PROJ/releases/download/9.3.1/proj-9.3.1.tar.gz" + sha256: "b0f919cb9e1f42f803a3e616c2b63a78e4d81ecfaed80978d570d3a5e29d10bc" +patches: + "9.3.1": + - patch_file: "patches/0001-use-cmake-targets-9.2.1.patch" + patch_type: "conan" + patch_description: "Use cmake targets" + diff --git a/proj/all/conanfile.py b/proj/all/conanfile.py new file mode 100644 index 0000000..ffa2b47 --- /dev/null +++ b/proj/all/conanfile.py @@ -0,0 +1,239 @@ +from conan import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.build import stdcpp_library +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualBuildEnv, VirtualRunEnv +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rmdir, replace_in_file, collect_libs, rm, rename +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version +import os + +required_conan_version = ">=1.60.0 <2 || >=2.0.5" + + +class ProjConan(ConanFile): + name = "proj" + description = "Cartographic Projections and Coordinate Transformations Library." + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://proj.org" + topics = ("dsp", "proj", "proj4", "projections", "gis", "geospatial") + package_type = "library" + 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], + } + default_options = { + "shared": False, + "fPIC": True, + "threadsafe": True, + "with_tiff": True, + "with_curl": True, + "build_executables": True, + } + + @property + def _is_legacy_one_profile(self): + return not hasattr(self, "settings_build") + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if Version(self.version) < "7.0.0": + del self.options.with_tiff + del self.options.with_curl + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("nlohmann_json/3.11.3") + self.requires("sqlite3/3.44.2") + if self.options.get_safe("with_tiff"): + self.requires("libtiff/4.6.0") + if self.options.get_safe("with_curl"): + self.requires("libcurl/[>=7.78.0 <9]") + + def build_requirements(self): + if Version(self.version) >= "9.4.0": + self.tool_requires("cmake/[>=3.16 <4]") + if not self._is_legacy_one_profile: + self.tool_requires("sqlite3/") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + if self._is_legacy_one_profile: + env = VirtualRunEnv(self) + env.generate(scope="build") + + tc = CMakeToolchain(self) + tc.variables["USE_THREAD"] = self.options.threadsafe + tc.variables["BUILD_CCT"] = self.options.build_executables + tc.variables["BUILD_CS2CS"] = self.options.build_executables + tc.variables["BUILD_GEOD"] = self.options.build_executables + tc.variables["BUILD_GIE"] = self.options.build_executables + tc.variables["BUILD_PROJ"] = self.options.build_executables + tc.variables["BUILD_PROJINFO"] = self.options.build_executables + if Version(self.version) < "9.1.0": + tc.variables["PROJ_DATA_SUBDIR"] = "res" + if Version(self.version) < "7.0.0": + tc.variables["PROJ_TESTS"] = False + tc.variables["BUILD_LIBPROJ_SHARED"] = self.options.shared + tc.variables["ENABLE_LTO"] = False + tc.variables["JNI_SUPPORT"] = False + else: + tc.variables["ENABLE_TIFF"] = self.options.with_tiff + tc.variables["ENABLE_CURL"] = self.options.with_curl + tc.variables["BUILD_TESTING"] = False + tc.variables["ENABLE_IPO"] = False + tc.variables["BUILD_PROJSYNC"] = self.options.build_executables and self.options.with_curl + if Version(self.version) >= "8.1.0": + tc.variables["NLOHMANN_JSON_ORIGIN"] = "external" + tc.variables["CMAKE_MACOSX_BUNDLE"] = False + if self.settings.os == "Linux": + # Workaround for: https://github.com/conan-io/conan/issues/13560 + libdirs_host = [l for dependency in self.dependencies.host.values() for l in dependency.cpp_info.aggregated_components().libdirs] + tc.variables["CMAKE_BUILD_RPATH"] = ";".join(libdirs_host) + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + + cmakelists = os.path.join(self.source_folder, "CMakeLists.txt") + + replace_in_file(self, cmakelists, "/W4", "") + + # Fix up usage of SQLite3 finder outputs + if Version(self.version) < "9.4.0": + rm(self, "FindSqlite3.cmake", os.path.join(self.source_folder, "cmake")) + replace_in_file(self, cmakelists, "SQLITE3_FOUND", "SQLite3_FOUND") + replace_in_file(self, cmakelists, "SQLITE3_VERSION", "SQLite3_VERSION") + replace_in_file(self, cmakelists, "find_package(Sqlite3 REQUIRED)", "find_package(SQLite3 REQUIRED)") + + # Let CMake install shared lib with a clean rpath ! + if "7.1.0" <= Version(self.version) < "9.0.0": + replace_in_file(self, cmakelists, "set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)", "") + + # Aggressive workaround against SIP on macOS, to handle sqlite3 executable + # linked to shared sqlite3 lib + if is_apple_os(self): + if Version(self.version) < "8.1.0": + cmake_sqlite_call = "CMakeLists.txt" + pattern = "${EXE_SQLITE3}" + else: + cmake_sqlite_call = "generate_proj_db.cmake" + pattern = "\"${EXE_SQLITE3}\"" + if self._is_legacy_one_profile: + lib_paths = self.dependencies["sqlite3"].cpp_info.libdirs + else: + lib_paths = self.dependencies.build["sqlite3"].cpp_info.libdirs + replace_in_file(self, + os.path.join(self.source_folder, "data", cmake_sqlite_call), + f"COMMAND {pattern}", + f"COMMAND ${{CMAKE_COMMAND}} -E env \"DYLD_LIBRARY_PATH={':'.join(lib_paths)}\" {pattern}" + ) + + # unvendor nlohmann_json + if Version(self.version) < "8.1.0": + rmdir(self, os.path.join(self.source_folder, "include", "proj", "internal", "nlohmann")) + + # Remove warning flags that are unfamiliar to GCC 5 + if Version(self.version) >= "9.0" and self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "8.0": + replace_in_file(self, os.path.join(self.source_folder, "src", "CMakeLists.txt"), "${PROJ_C_WARN_FLAGS}", "") + replace_in_file(self, os.path.join(self.source_folder, "src", "CMakeLists.txt"), "${PROJ_CXX_WARN_FLAGS}", "") + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "COPYING", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + # recover the data ... 9.1.0 saves into share/proj rather than res directly + # the new PROJ_DATA_PATH can't seem to be controlled from conan. + if Version(self.version) >= "9.1.0": + rename(self, src=os.path.join(self.package_folder, "share", "proj"), dst=os.path.join(self.package_folder, "res")) + # delete the rest of the deployed data + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + proj_version = Version(self.version) + cmake_config_filename = "proj" if proj_version >= "7.0.0" else "proj4" + cmake_namespace = "PROJ" if proj_version >= "7.0.0" else "PROJ4" + self.cpp_info.set_property("cmake_file_name", cmake_config_filename) + self.cpp_info.set_property("cmake_target_name", f"{cmake_namespace}::proj") + self.cpp_info.set_property("pkg_config_name", "proj") + self.cpp_info.components["projlib"].set_property("cmake_target_name", f"{cmake_namespace}::proj") + self.cpp_info.components["projlib"].set_property("pkg_config_name", "proj") + + self.cpp_info.components["projlib"].libs = collect_libs(self) + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["projlib"].system_libs.append("m") + if self.options.threadsafe: + self.cpp_info.components["projlib"].system_libs.append("pthread") + elif self.settings.os == "Windows": + if proj_version >= "7.0.0": + self.cpp_info.components["projlib"].system_libs.append("shell32") + if proj_version >= "7.1.0": + self.cpp_info.components["projlib"].system_libs.append("ole32") + if not self.options.shared: + libcxx = stdcpp_library(self) + if libcxx: + self.cpp_info.components["projlib"].system_libs.append(libcxx) + self.cpp_info.components["projlib"].requires.extend(["nlohmann_json::nlohmann_json", "sqlite3::sqlite3"]) + if self.options.get_safe("with_tiff"): + self.cpp_info.components["projlib"].requires.append("libtiff::libtiff") + if self.options.get_safe("with_curl"): + self.cpp_info.components["projlib"].requires.append("libcurl::libcurl") + if Version(self.version) < "8.2.0": + if self.options.shared and is_msvc(self): + self.cpp_info.components["projlib"].defines.append("PROJ_MSVC_DLL_IMPORT") + else: + if not self.options.shared: + self.cpp_info.components["projlib"].defines.append("PROJ_DLL=") + + # see https://proj.org/usage/environmentvars.html#envvar-PROJ_DATA + proj_data_env_var_name = "PROJ_LIB" if Version(self.version) < "9.1.0" else "PROJ_DATA" + res_path = os.path.join(self.package_folder, "res") + self.runenv_info.prepend_path(proj_data_env_var_name, res_path) + if self.options.build_executables: + self.buildenv_info.prepend_path(proj_data_env_var_name, res_path) + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = cmake_config_filename + self.cpp_info.filenames["cmake_find_package_multi"] = cmake_config_filename + self.cpp_info.names["cmake_find_package"] = cmake_namespace + self.cpp_info.names["cmake_find_package_multi"] = cmake_namespace + self.cpp_info.components["projlib"].names["cmake_find_package"] = "proj" + self.cpp_info.components["projlib"].names["cmake_find_package_multi"] = "proj" + if Version(self.version) < "9.1.0": + self.env_info.PROJ_LIB.append(res_path) + else: + self.env_info.PROJ_DATA.append(res_path) + if self.options.build_executables: + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/proj/all/patches/0001-use-cmake-targets-6.x.x.patch b/proj/all/patches/0001-use-cmake-targets-6.x.x.patch new file mode 100644 index 0000000..6bec96d --- /dev/null +++ b/proj/all/patches/0001-use-cmake-targets-6.x.x.patch @@ -0,0 +1,34 @@ +diff -ru a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt 2020-02-10 17:29:51.000000000 +0800 ++++ b/CMakeLists.txt 2022-12-14 21:05:09.821289235 +0800 +@@ -114,6 +114,8 @@ + include(ProjMac) + include(policies) + ++find_package(nlohmann_json REQUIRED) ++ + ################################################################################ + # Check for sqlite3 + ################################################################################ +diff -ru a/src/lib_proj.cmake b/src/lib_proj.cmake +--- a/src/lib_proj.cmake 2019-12-29 06:23:06.000000000 +0800 ++++ b/src/lib_proj.cmake 2022-12-14 20:58:56.856752193 +0800 +@@ -311,7 +311,7 @@ + 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 @@ + 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} nlohmann_json::nlohmann_json SQLite::SQLite3) + + if(MSVC AND BUILD_LIBPROJ_SHARED) + target_compile_definitions(${PROJ_CORE_TARGET} diff --git a/proj/all/patches/0001-use-cmake-targets-7.2.1.patch b/proj/all/patches/0001-use-cmake-targets-7.2.1.patch new file mode 100644 index 0000000..6ee348a --- /dev/null +++ b/proj/all/patches/0001-use-cmake-targets-7.2.1.patch @@ -0,0 +1,37 @@ +diff -ru a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt 2020-12-27 02:57:21.000000000 +0800 ++++ b/CMakeLists.txt 2022-12-14 21:21:31.516729458 +0800 +@@ -121,6 +121,8 @@ + include(ProjMac) + include(policies) + ++find_package(nlohmann_json REQUIRED) ++ + ################################################################################ + # Check for sqlite3 + ################################################################################ +--- a/src/lib_proj.cmake ++++ b/src/lib_proj.cmake +@@ -414,19 +414,16 @@ if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT) + target_link_libraries(${PROJ_CORE_TARGET} ${CMAKE_THREAD_LIBS_INIT}) + endif() + +-target_include_directories(${PROJ_CORE_TARGET} PRIVATE ${SQLITE3_INCLUDE_DIR}) +-target_link_libraries(${PROJ_CORE_TARGET} ${SQLITE3_LIBRARY}) ++target_link_libraries(${PROJ_CORE_TARGET} nlohmann_json::nlohmann_json SQLite::SQLite3) + + if(TIFF_ENABLED) + target_compile_definitions(${PROJ_CORE_TARGET} PRIVATE -DTIFF_ENABLED) +- target_include_directories(${PROJ_CORE_TARGET} PRIVATE ${TIFF_INCLUDE_DIR}) +- target_link_libraries(${PROJ_CORE_TARGET} ${TIFF_LIBRARY}) ++ target_link_libraries(${PROJ_CORE_TARGET} TIFF::TIFF) + endif() + + if(CURL_ENABLED) + target_compile_definitions(${PROJ_CORE_TARGET} PRIVATE -DCURL_ENABLED) +- target_include_directories(${PROJ_CORE_TARGET} PRIVATE ${CURL_INCLUDE_DIR}) +- target_link_libraries(${PROJ_CORE_TARGET} ${CURL_LIBRARY}) ++ target_link_libraries(${PROJ_CORE_TARGET} CURL::libcurl) + endif() + + if(MSVC AND BUILD_SHARED_LIBS) diff --git a/proj/all/patches/0001-use-cmake-targets-8.2.0.patch b/proj/all/patches/0001-use-cmake-targets-8.2.0.patch new file mode 100644 index 0000000..8ce7c18 --- /dev/null +++ b/proj/all/patches/0001-use-cmake-targets-8.2.0.patch @@ -0,0 +1,31 @@ +--- a/src/lib_proj.cmake ++++ b/src/lib_proj.cmake +@@ -453,8 +453,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 SQLite::SQLite3) + + if(NLOHMANN_JSON STREQUAL "external") + target_compile_definitions(proj PRIVATE EXTERNAL_NLOHMANN_JSON) +@@ -464,16 +463,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 + $<$:ws2_32> + $<$:wldap32> + $<$:advapi32> diff --git a/proj/all/patches/0001-use-cmake-targets-9.2.1.patch b/proj/all/patches/0001-use-cmake-targets-9.2.1.patch new file mode 100644 index 0000000..0459aba --- /dev/null +++ b/proj/all/patches/0001-use-cmake-targets-9.2.1.patch @@ -0,0 +1,12 @@ +--- a/src/lib_proj.cmake ++++ b/src/lib_proj.cmake +@@ -438,8 +438,7 @@ + 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 SQLite::SQLite3) + + if(NLOHMANN_JSON STREQUAL "external") + target_compile_definitions(proj PRIVATE EXTERNAL_NLOHMANN_JSON) diff --git a/proj/all/test_package/CMakeLists.txt b/proj/all/test_package/CMakeLists.txt new file mode 100644 index 0000000..4fa8bd9 --- /dev/null +++ b/proj/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package LANGUAGES C) + +add_executable(test_package test_package.c) +if(PROJ_VERSION_GE_7) + find_package(proj REQUIRED CONFIG) + target_link_libraries(test_package PRIVATE PROJ::proj) +else() + find_package(proj4 REQUIRED CONFIG) + target_link_libraries(test_package PRIVATE PROJ4::proj) +endif() diff --git a/proj/all/test_package/conanfile.py b/proj/all/test_package/conanfile.py new file mode 100644 index 0000000..69dbaea --- /dev/null +++ b/proj/all/test_package/conanfile.py @@ -0,0 +1,32 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain +from conan.tools.scm import Version +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["PROJ_VERSION_GE_7"] = Version(self.dependencies["proj"].ref.version) >= "7.0.0" + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/proj/all/test_package/test_package.c b/proj/all/test_package/test_package.c new file mode 100644 index 0000000..3a5964a --- /dev/null +++ b/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/proj/all/test_v1_package/CMakeLists.txt b/proj/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000..0d20897 --- /dev/null +++ b/proj/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/proj/all/test_v1_package/conanfile.py b/proj/all/test_v1_package/conanfile.py new file mode 100644 index 0000000..0a0d55e --- /dev/null +++ b/proj/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.definitions["PROJ_VERSION_GE_7"] = tools.Version(self.deps_cpp_info["proj"].version) >= "7.0.0" + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/proj/config.yml b/proj/config.yml new file mode 100644 index 0000000..079aaeb --- /dev/null +++ b/proj/config.yml @@ -0,0 +1,4 @@ +versions: + "9.3.1": + folder: "all" + diff --git a/sqlite3/all/CMakeLists.txt b/sqlite3/all/CMakeLists.txt new file mode 100644 index 0000000..9d6257e --- /dev/null +++ b/sqlite3/all/CMakeLists.txt @@ -0,0 +1,190 @@ +cmake_minimum_required(VERSION 3.7) +project(sqlite3 LANGUAGES C) + +# Add some options from https://sqlite.org/compile.html +option(SQLITE3_BUILD_EXECUTABLE "Build sqlite command line utility for accessing SQLite databases") +option(ENABLE_JSON1 "Enable JSON SQL functions") +option(ENABLE_COLUMN_METADATA "Enable additional APIs that provide convenient access to meta-data about tables and queries") +option(ENABLE_DBSTAT_VTAB "Enable the DBSTAT virtual table") +option(ENABLE_EXPLAIN_COMMENTS "Enable SQLite to insert comment text into the output of EXPLAIN") +option(ENABLE_FTS3 "Enable version 3 of the full-text search engine") +option(ENABLE_FTS3_PARENTHESIS "Kodifies the query pattern parser in FTS3 such that it supports operators AND and NOT (in addition to the usual OR and NEAR) and also allows query expressions to contain nested parenthesis") +option(ENABLE_FTS4 "Enable version 3 and 4 of the full-text search engine") +option(ENABLE_FTS5 "Enable version 5 of the full-text search engine") +option(ENABLE_SOUNDEX "Enable the soundex() SQL function") +option(ENABLE_PREUPDATE_HOOK "Enables APIs to handle any change to a rowid table") +option(ENABLE_RTREE "Enable support for the R*Tree index extension") +option(ENABLE_UNLOCK_NOTIFY "Enable support for the unlock notify API") +option(ENABLE_DEFAULT_SECURE_DELETE "Turns on secure deletion by default") +option(USE_ALLOCA "The alloca() memory allocator will be used in a few situations where it is appropriate.") +option(USE_URI "This option causes the URI filename process logic to be enabled by default.") +option(OMIT_LOAD_EXTENSION "Omits the entire extension loading mechanism from SQLite") +option(OMIT_DEPRECATED "Omits deprecated interfaces and features") +if(SQLITE3_VERSION VERSION_GREATER_EQUAL "3.35.0") + option(ENABLE_MATH_FUNCTIONS "Enables the built-in SQL math functions" ON) +else() + set(ENABLE_MATH_FUNCTIONS OFF) +endif() +option(HAVE_FDATASYNC "Use fdatasync() instead of fsync() on unix systems") +option(HAVE_GMTIME_R "Use the threadsafe gmtime_r()") +option(HAVE_LOCALTIME_R "Use the threadsafe localtime_r()") +option(HAVE_POSIX_FALLOCATE "Use posix_fallocate()") +option(HAVE_STRERROR_R "Use strerror_r()") +option(HAVE_USLEEP "Use usleep() system call to implement the xSleep method") +option(DISABLE_GETHOSTUUID "Disable function gethostuuid") +set(MAX_COLUMN CACHE STRING "The maximum number of columns in a table / index / view") +set(MAX_VARIABLE_NUMBER CACHE STRING "The maximum value of a ?nnn wildcard that the parser will accept") +set(MAX_BLOB_SIZE CACHE STRING "Set the maximum number of bytes in a string or BLOB") +option(DISABLE_DEFAULT_VFS "Disable default VFS implementation") +option(ENABLE_DBPAGE_VTAB "The SQLITE_DBPAGE extension implements an eponymous-only virtual table that provides direct access to the underlying database file by interacting with the pager. SQLITE_DBPAGE is capable of both reading and writing any page of the database. Because interaction is through the pager layer, all changes are transactional.") + +add_library(${PROJECT_NAME} ${SQLITE3_SRC_DIR}/sqlite3.c) +set_target_properties(${PROJECT_NAME} PROPERTIES C_VISIBILITY_PRESET hidden) +if(BUILD_SHARED_LIBS) + if(WIN32) + target_compile_definitions(${PROJECT_NAME} + PRIVATE "SQLITE_API=__declspec(dllexport)" + INTERFACE "SQLITE_API=__declspec(dllimport)" + ) + else() + target_compile_definitions(${PROJECT_NAME} + PUBLIC "SQLITE_API=__attribute__((visibility(\"default\")))" + ) + endif() +endif() +if(ENABLE_JSON1) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_ENABLE_JSON1) +endif() +if(ENABLE_COLUMN_METADATA) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_ENABLE_COLUMN_METADATA) +endif() +if(ENABLE_DBSTAT_VTAB) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_ENABLE_DBSTAT_VTAB) +endif() +if(ENABLE_EXPLAIN_COMMENTS) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_ENABLE_EXPLAIN_COMMENTS) +endif() +if(ENABLE_FTS3) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_ENABLE_FTS3) +endif() +if(ENABLE_FTS3_PARENTHESIS) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_ENABLE_FTS3_PARENTHESIS) +endif() +if(ENABLE_FTS4) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_ENABLE_FTS4) +endif() +if(ENABLE_FTS5) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_ENABLE_FTS5) +endif() +if(ENABLE_PREUPDATE_HOOK) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_ENABLE_PREUPDATE_HOOK) +endif() +if(ENABLE_RTREE) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_ENABLE_RTREE) +endif() +if(ENABLE_UNLOCK_NOTIFY) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_ENABLE_UNLOCK_NOTIFY) +endif() +if(ENABLE_DEFAULT_SECURE_DELETE) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_SECURE_DELETE) +endif() +if(ENABLE_SOUNDEX) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_SOUNDEX) +endif() +if(USE_ALLOCA) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_USE_ALLOCA) +endif() +if(USE_URI) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_USE_URI) +endif() +if(OMIT_LOAD_EXTENSION) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_OMIT_LOAD_EXTENSION) +endif() +if (OMIT_DEPRECATED) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_OMIT_DEPRECATED) +endif() +if(ENABLE_MATH_FUNCTIONS) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_ENABLE_MATH_FUNCTIONS) +endif() +if(HAVE_FDATASYNC) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_FDATASYNC) +endif() +if(HAVE_GMTIME_R) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_GMTIME_R) +endif() +if(HAVE_LOCALTIME_R) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_LOCALTIME_R) +endif() +if(HAVE_POSIX_FALLOCATE) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_POSIX_FALLOCATE) +endif() +if(HAVE_STRERROR_R) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_STRERROR_R) +endif() +if(HAVE_USLEEP) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_USLEEP) +endif() +if(DISABLE_GETHOSTUUID) + target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_GETHOSTUUID=0) +endif() +target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_THREADSAFE=${THREADSAFE}) +if(MAX_COLUMN) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_MAX_COLUMN=${MAX_COLUMN}) +endif() +if(MAX_VARIABLE_NUMBER) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_MAX_VARIABLE_NUMBER=${MAX_VARIABLE_NUMBER}) +endif() +if(MAX_BLOB_SIZE) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_MAX_LENGTH=${MAX_BLOB_SIZE}) +endif() +if(DISABLE_DEFAULT_VFS) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_OS_OTHER=1) +endif() +if(ENABLE_DBPAGE_VTAB) + target_compile_definitions(${PROJECT_NAME} PRIVATE SQLITE_ENABLE_DBPAGE_VTAB) +endif() + +if(THREADSAFE) + find_package(Threads REQUIRED) + target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads) +endif() + +if(NOT OMIT_LOAD_EXTENSION) + target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_DL_LIBS}) +endif() + +if(ENABLE_FTS5 OR ENABLE_MATH_FUNCTIONS) + include(CheckLibraryExists) + # Check if math functionality is on the separate 'libm' library, + # otherwise assume that it is already part of the C runtime. + # The `m` library is part of the compiler toolchain, this checks + # if the compiler can successfully link against the library. + check_library_exists(m log "" HAVE_MATH_LIBRARY) + if(HAVE_MATH_LIBRARY) + target_link_libraries(${PROJECT_NAME} PRIVATE m) + endif() +endif() + +include(GNUInstallDirs) +install(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +install(DIRECTORY ${SQLITE3_SRC_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING PATTERN "*.h") + +if(SQLITE3_BUILD_EXECUTABLE) + add_executable(sqlite3-bin ${SQLITE3_SRC_DIR}/shell.c) + target_link_libraries(sqlite3-bin PRIVATE ${PROJECT_NAME}) + if(ENABLE_DBPAGE_VTAB) + target_compile_definitions(sqlite3-bin PRIVATE SQLITE_ENABLE_DBPAGE_VTAB) + endif() + set_target_properties(sqlite3-bin PROPERTIES OUTPUT_NAME "sqlite3" PDB_NAME "sqlite3-bin") + include(CheckSymbolExists) + check_symbol_exists(system "stdlib.h" HAVE_SYSTEM) + if(NOT HAVE_SYSTEM) + target_compile_definitions(sqlite3-bin PRIVATE SQLITE_NOHAVE_SYSTEM) + endif() + install(TARGETS sqlite3-bin DESTINATION ${CMAKE_INSTALL_BINDIR}) +endif() diff --git a/sqlite3/all/conandata.yml b/sqlite3/all/conandata.yml new file mode 100644 index 0000000..5762520 --- /dev/null +++ b/sqlite3/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "3.44.2": + url: "https://sqlite.org/2023/sqlite-amalgamation-3440200.zip" + sha256: "833be89b53b3be8b40a2e3d5fedb635080e3edb204957244f3d6987c2bb2345f" diff --git a/sqlite3/all/conanfile.py b/sqlite3/all/conanfile.py new file mode 100644 index 0000000..8c9aee8 --- /dev/null +++ b/sqlite3/all/conanfile.py @@ -0,0 +1,226 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import get, load, save +from conan.tools.scm import Version +import os +import textwrap + +required_conan_version = ">=1.53.0" + + +class Sqlite3Conan(ConanFile): + name = "sqlite3" + description = "Self-contained, serverless, in-process SQL database engine." + license = "Unlicense" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.sqlite.org" + topics = ("sqlite", "database", "sql", "serverless") + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "threadsafe": [0, 1, 2], + "enable_column_metadata": [True, False], + "enable_dbstat_vtab": [True, False], + "enable_explain_comments": [True, False], + "enable_fts3": [True, False], + "enable_fts3_parenthesis": [True, False], + "enable_fts4": [True, False], + "enable_fts5": [True, False], + "enable_json1": [True, False], + "enable_soundex": [True, False], + "enable_preupdate_hook": [True, False], + "enable_rtree": [True, False], + "use_alloca": [True, False], + "use_uri": [True, False], + "omit_load_extension": [True, False], + "omit_deprecated": [True, False], + "enable_math_functions": [True, False], + "enable_unlock_notify": [True, False], + "enable_default_secure_delete": [True, False], + "disable_gethostuuid": [True, False], + "max_column": [None, "ANY"], + "max_variable_number": [None, "ANY"], + "max_blob_size": [None, "ANY"], + "build_executable": [True, False], + "enable_default_vfs": [True, False], + "enable_dbpage_vtab": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "threadsafe": 1, + "enable_column_metadata": True, + "enable_dbstat_vtab": False, + "enable_explain_comments": False, + "enable_fts3": False, + "enable_fts3_parenthesis": False, + "enable_fts4": False, + "enable_fts5": False, + "enable_json1": False, + "enable_soundex": False, + "enable_preupdate_hook": False, + "enable_rtree": True, + "use_alloca": False, + "use_uri": False, + "omit_load_extension": False, + "omit_deprecated": False, + "enable_math_functions": True, + "enable_unlock_notify": True, + "enable_default_secure_delete": False, + "disable_gethostuuid": False, + "max_column": None, # Uses default value from source + "max_variable_number": None, # Uses default value from source + "max_blob_size": None, # Uses default value from source + "build_executable": True, + "enable_default_vfs": True, + "enable_dbpage_vtab": False, + } + + exports_sources = "CMakeLists.txt" + + @property + def _has_enable_math_function_option(self): + return Version(self.version) >= "3.35.0" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if not self._has_enable_math_function_option: + del self.options.enable_math_functions + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + if self.options.build_executable: + if not self.options.enable_default_vfs: + # Need to provide custom VFS code: https://www.sqlite.org/custombuild.html + raise ConanInvalidConfiguration("build_executable=True cannot be combined with enable_default_vfs=False") + if self.options.omit_load_extension: + raise ConanInvalidConfiguration("build_executable=True requires omit_load_extension=True") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["SQLITE3_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["SQLITE3_VERSION"] = self.version + tc.variables["SQLITE3_BUILD_EXECUTABLE"] = self.options.build_executable + tc.variables["THREADSAFE"] = self.options.threadsafe + tc.variables["ENABLE_COLUMN_METADATA"] = self.options.enable_column_metadata + tc.variables["ENABLE_DBSTAT_VTAB"] = self.options.enable_dbstat_vtab + tc.variables["ENABLE_EXPLAIN_COMMENTS"] = self.options.enable_explain_comments + tc.variables["ENABLE_FTS3"] = self.options.enable_fts3 + tc.variables["ENABLE_FTS3_PARENTHESIS"] = self.options.enable_fts3_parenthesis + tc.variables["ENABLE_FTS4"] = self.options.enable_fts4 + tc.variables["ENABLE_FTS5"] = self.options.enable_fts5 + tc.variables["ENABLE_JSON1"] = self.options.enable_json1 + tc.variables["ENABLE_PREUPDATE_HOOK"] = self.options.enable_preupdate_hook + tc.variables["ENABLE_SOUNDEX"] = self.options.enable_soundex + tc.variables["ENABLE_RTREE"] = self.options.enable_rtree + tc.variables["ENABLE_UNLOCK_NOTIFY"] = self.options.enable_unlock_notify + tc.variables["ENABLE_DEFAULT_SECURE_DELETE"] = self.options.enable_default_secure_delete + tc.variables["USE_ALLOCA"] = self.options.use_alloca + tc.variables["USE_URI"] = self.options.use_uri + tc.variables["OMIT_LOAD_EXTENSION"] = self.options.omit_load_extension + tc.variables["OMIT_DEPRECATED"] = self.options.omit_deprecated + if self._has_enable_math_function_option: + tc.variables["ENABLE_MATH_FUNCTIONS"] = self.options.enable_math_functions + tc.variables["HAVE_FDATASYNC"] = True + tc.variables["HAVE_GMTIME_R"] = True + tc.variables["HAVE_LOCALTIME_R"] = self.settings.os != "Windows" + tc.variables["HAVE_POSIX_FALLOCATE"] = not (self.settings.os in ["Windows", "Android"] or is_apple_os(self)) + tc.variables["HAVE_STRERROR_R"] = True + tc.variables["HAVE_USLEEP"] = True + tc.variables["DISABLE_GETHOSTUUID"] = self.options.disable_gethostuuid + if self.options.max_column: + tc.variables["MAX_COLUMN"] = self.options.max_column + if self.options.max_variable_number: + tc.variables["MAX_VARIABLE_NUMBER"] = self.options.max_variable_number + if self.options.max_blob_size: + tc.variables["MAX_BLOB_SIZE"] = self.options.max_blob_size + tc.variables["DISABLE_DEFAULT_VFS"] = not self.options.enable_default_vfs + tc.variables["ENABLE_DBPAGE_VTAB"] = self.options.enable_dbpage_vtab + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def _extract_license(self): + header = load(self, os.path.join(self.source_folder, "sqlite3.h")) + license_content = header[3:header.find("***", 1)] + return license_content + + def package(self): + save(self, os.path.join(self.package_folder, "licenses", "LICENSE"), self._extract_license()) + cmake = CMake(self) + cmake.install() + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + # Indeed CMakeDeps uses 'cmake_file_name' property to qualify CMake variables + self._create_cmake_module_variables( + os.path.join(self.package_folder, self._module_file_rel_path) + ) + + def _create_cmake_module_variables(self, module_file): + content = textwrap.dedent("""\ + if(DEFINED SQLite_INCLUDE_DIRS) + set(SQLite3_INCLUDE_DIRS ${SQLite_INCLUDE_DIRS}) + endif() + if(DEFINED SQLite_LIBRARIES) + set(SQLite3_LIBRARIES ${SQLite_LIBRARIES}) + endif() + """) + save(self, module_file, content) + + @property + def _module_file_rel_path(self): + return os.path.join("lib", "cmake", f"conan-official-{self.name}-variables.cmake") + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "SQLite3") + self.cpp_info.set_property("cmake_target_name", "SQLite::SQLite3") + self.cpp_info.set_property("pkg_config_name", "sqlite3") + + # TODO: back to global scope in conan v2 once cmake_find_package_* generators removed + self.cpp_info.components["sqlite"].libs = ["sqlite3"] + if self.options.omit_load_extension: + self.cpp_info.components["sqlite"].defines.append("SQLITE_OMIT_LOAD_EXTENSION") + if self.settings.os in ["Linux", "FreeBSD"]: + if self.options.threadsafe: + self.cpp_info.components["sqlite"].system_libs.append("pthread") + if not self.options.omit_load_extension: + self.cpp_info.components["sqlite"].system_libs.append("dl") + if self.options.enable_fts5 or self.options.get_safe("enable_math_functions"): + self.cpp_info.components["sqlite"].system_libs.append("m") + elif self.settings.os == "Windows": + if self.options.shared: + self.cpp_info.components["sqlite"].defines.append("SQLITE_API=__declspec(dllimport)") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "SQLite3" + self.cpp_info.filenames["cmake_find_package_multi"] = "SQLite3" + self.cpp_info.names["cmake_find_package"] = "SQLite" + self.cpp_info.names["cmake_find_package_multi"] = "SQLite" + self.cpp_info.components["sqlite"].names["cmake_find_package"] = "SQLite3" + self.cpp_info.components["sqlite"].names["cmake_find_package_multi"] = "SQLite3" + self.cpp_info.components["sqlite"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["sqlite"].build_modules["cmake_find_package"] = [self._module_file_rel_path] + self.cpp_info.components["sqlite"].set_property("cmake_target_name", "SQLite::SQLite3") + self.cpp_info.components["sqlite"].set_property("pkg_config_name", "sqlite3") + if self.options.build_executable: + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/sqlite3/all/test_package/CMakeLists.txt b/sqlite3/all/test_package/CMakeLists.txt new file mode 100644 index 0000000..3af61b1 --- /dev/null +++ b/sqlite3/all/test_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES C) + +option(USE_EMPTY_VFS "Using empty SQLite OS interface") + +find_package(SQLite3 REQUIRED) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE SQLite::SQLite3) + +if(USE_EMPTY_VFS) + target_compile_definitions(${PROJECT_NAME} PRIVATE USE_EMPTY_VFS) + target_sources(${PROJECT_NAME} PRIVATE empty_vfs.c) +endif() diff --git a/sqlite3/all/test_package/conanfile.py b/sqlite3/all/test_package/conanfile.py new file mode 100644 index 0000000..0a6bc68 --- /dev/null +++ b/sqlite3/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/sqlite3/all/test_package/empty_vfs.c b/sqlite3/all/test_package/empty_vfs.c new file mode 100644 index 0000000..e33137b --- /dev/null +++ b/sqlite3/all/test_package/empty_vfs.c @@ -0,0 +1,90 @@ +#include +#include + +int empty_xOpen(sqlite3_vfs *vfs, const char *zName, sqlite3_file *f, int flags, int *pOutFlags) +{ + // TODO: implement + return SQLITE_OK; +} + +int empty_xDelete(sqlite3_vfs *vfs, const char *zName, int syncDir) +{ + // TODO: implement + return SQLITE_OK; +} + +int empty_xAccess(sqlite3_vfs *vfs, const char *zName, int flags, int *pResOut) +{ + // TODO: implement + return SQLITE_OK; +} + +int empty_xFullPathname(sqlite3_vfs *vfs, const char *zName, int nOut, char *zOut) +{ + // TODO: implement + return SQLITE_OK; +} +int empty_xRandomness(sqlite3_vfs *vfs, int nByte, char *zOut) +{ + // TODO: implement + return SQLITE_OK; +} +int empty_xSleep(sqlite3_vfs *vfs, int microseconds) +{ + // TODO: implement + return SQLITE_OK; +} +int empty_xCurrentTime(sqlite3_vfs *vfs, double *t) +{ + // TODO: implement + return SQLITE_OK; +} +int empty_xGetLastError(sqlite3_vfs *vfs, int code, char *name) +{ + // TODO: implement + return SQLITE_OK; +} +int empty_xCurrentTimeInt64(sqlite3_vfs *vfs, sqlite3_int64 *t) +{ + // TODO: implement + return SQLITE_OK; +} + +// empty VFS will be provided +int sqlite3_os_init(void) +{ + static sqlite3_vfs emptyVFS = + { + 2, /* iVersion */ + 0, /* szOsFile */ + 100, /* mxPathname */ + NULL, /* pNext */ + "empty", /* zName */ + NULL, /* pAppData */ + empty_xOpen, /* xOpen */ + empty_xDelete, /* xDelete */ + empty_xAccess, /* xAccess */ + empty_xFullPathname, /* xFullPathname */ + NULL, /* xDlOpen */ + NULL, /* xDlError */ + NULL, /* xDlSym */ + NULL, /* xDlClose */ + empty_xRandomness, /* xRandomness */ + empty_xSleep, /* xSleep */ + empty_xCurrentTime, /* xCurrentTime */ + empty_xGetLastError, /* xGetLastError */ + empty_xCurrentTimeInt64, /* xCurrentTimeInt64 */ + NULL, /* xSetSystemCall */ + NULL, /* xGetSystemCall */ + NULL, /* xNextSystemCall */ + }; + + sqlite3_vfs_register(&emptyVFS, 1); + + return SQLITE_OK; +} + +int sqlite3_os_end(void) +{ + return SQLITE_OK; +} diff --git a/sqlite3/all/test_package/test_package.c b/sqlite3/all/test_package/test_package.c new file mode 100644 index 0000000..a32b045 --- /dev/null +++ b/sqlite3/all/test_package/test_package.c @@ -0,0 +1,46 @@ +#include +#include +#include + +#ifdef USE_EMPTY_VFS +#define DB_NAME ":memory:" +#else +#define DB_NAME "bincrafters.db" +#endif + +int main() { + sqlite3* db_instance = NULL; + char* errmsg = NULL; + int result = 0; + + printf("SQLite Version: %s\n", sqlite3_libversion()); + + printf("Creating new data base ...\n"); + result = sqlite3_open(DB_NAME, &db_instance); + if (result != SQLITE_OK) { + fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db_instance)); + sqlite3_close(db_instance); + return EXIT_FAILURE; + } + printf("Done!\n"); + + printf("Creating new table...\n"); + result = sqlite3_exec(db_instance, "CREATE TABLE IF NOT EXISTS package(ID INT PRIMARY KEY NOT NULL);", NULL, 0, &errmsg); + if(result != SQLITE_OK) { + fprintf(stderr, "SQL error: %s\n", errmsg); + sqlite3_free(errmsg); + return EXIT_FAILURE; + } + printf("Done!\n"); + + printf("Closing connection ...\n"); + sqlite3_close(db_instance); + if(result != SQLITE_OK) { + fprintf(stderr, "Connection error: %s\n", errmsg); + sqlite3_free(errmsg); + return EXIT_FAILURE; + } + printf("Done!\n"); + + return EXIT_SUCCESS; +} diff --git a/sqlite3/all/test_v1_package/CMakeLists.txt b/sqlite3/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000..0d20897 --- /dev/null +++ b/sqlite3/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package + ${CMAKE_CURRENT_BINARY_DIR}/test_package) diff --git a/sqlite3/all/test_v1_package/conanfile.py b/sqlite3/all/test_v1_package/conanfile.py new file mode 100644 index 0000000..48965a0 --- /dev/null +++ b/sqlite3/all/test_v1_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + + def build(self): + cmake = CMake(self) + cmake.definitions["USE_EMPTY_VFS"] = not self.options["sqlite3"].enable_default_vfs + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/sqlite3/config.yml b/sqlite3/config.yml new file mode 100644 index 0000000..3b82a7d --- /dev/null +++ b/sqlite3/config.yml @@ -0,0 +1,3 @@ +versions: + "3.44.2": + folder: all