From d4c44894af070382b70862dd07b56e2dfc5c7a5a Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 30 Apr 2024 14:11:03 +0300 Subject: [PATCH 1/2] gdalcpp: new recipe --- recipes/gdalcpp/all/conandata.yml | 4 ++ recipes/gdalcpp/all/conanfile.py | 45 +++++++++++++++++++ .../gdalcpp/all/test_package/CMakeLists.txt | 8 ++++ recipes/gdalcpp/all/test_package/conanfile.py | 26 +++++++++++ .../gdalcpp/all/test_package/test_package.cpp | 5 +++ recipes/gdalcpp/config.yml | 3 ++ 6 files changed, 91 insertions(+) create mode 100644 recipes/gdalcpp/all/conandata.yml create mode 100644 recipes/gdalcpp/all/conanfile.py create mode 100644 recipes/gdalcpp/all/test_package/CMakeLists.txt create mode 100644 recipes/gdalcpp/all/test_package/conanfile.py create mode 100644 recipes/gdalcpp/all/test_package/test_package.cpp create mode 100644 recipes/gdalcpp/config.yml diff --git a/recipes/gdalcpp/all/conandata.yml b/recipes/gdalcpp/all/conandata.yml new file mode 100644 index 0000000000000..2d8f384ce2218 --- /dev/null +++ b/recipes/gdalcpp/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.3.0": + url: "https://github.com/joto/gdalcpp/archive/7e23085e7da80c8805fff54cc18e2705ac332074.zip" + sha256: "2240bbd376d91a3ea00fdef8261a1fb46f090798734422fbba0e716ea672031e" diff --git a/recipes/gdalcpp/all/conanfile.py b/recipes/gdalcpp/all/conanfile.py new file mode 100644 index 0000000000000..70b8d697a1fa1 --- /dev/null +++ b/recipes/gdalcpp/all/conanfile.py @@ -0,0 +1,45 @@ +import os + +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout + +required_conan_version = ">=1.52.0" + +class GdalcppConan(ConanFile): + name = "gdalcpp" + description = "C++11 wrapper classes for GDAL/OGR" + license = "BSL-1.0" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/joto/gdalcpp" + topics = ("gdal", "osgeo", "geospatial", "raster", "vector", "gis", "header-only") + package_type = "header-library" + + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("gdal/3.8.3") + + def package_id(self): + self.info.clear() + + def validate(self): + if self.settings.compiler.cppstd: + check_min_cppstd(self, 11) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + + def package(self): + copy(self, "LICENSE.txt", self.source_folder, os.path.join(self.package_folder, "licenses")) + copy(self, "gdalcpp.hpp", self.source_folder, os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/gdalcpp/all/test_package/CMakeLists.txt b/recipes/gdalcpp/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2acf2bd8a8682 --- /dev/null +++ b/recipes/gdalcpp/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(gdalcpp REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE gdalcpp::gdalcpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/gdalcpp/all/test_package/conanfile.py b/recipes/gdalcpp/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a91c9439218e --- /dev/null +++ b/recipes/gdalcpp/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_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "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.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/gdalcpp/all/test_package/test_package.cpp b/recipes/gdalcpp/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..edca0405e53d1 --- /dev/null +++ b/recipes/gdalcpp/all/test_package/test_package.cpp @@ -0,0 +1,5 @@ +#include + +int main() { + gdalcpp::SRS wgs84{4326}; +} diff --git a/recipes/gdalcpp/config.yml b/recipes/gdalcpp/config.yml new file mode 100644 index 0000000000000..426a0e4c79e9b --- /dev/null +++ b/recipes/gdalcpp/config.yml @@ -0,0 +1,3 @@ +versions: + "1.3.0": + folder: all From 849e91cfb1c159da278dddfb3890948facea6231 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 30 Apr 2024 14:28:26 +0300 Subject: [PATCH 2/2] gdalcpp: tidy --- recipes/gdalcpp/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/gdalcpp/all/conanfile.py b/recipes/gdalcpp/all/conanfile.py index 70b8d697a1fa1..8424f1e00af76 100644 --- a/recipes/gdalcpp/all/conanfile.py +++ b/recipes/gdalcpp/all/conanfile.py @@ -14,8 +14,8 @@ class GdalcppConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/joto/gdalcpp" topics = ("gdal", "osgeo", "geospatial", "raster", "vector", "gis", "header-only") - package_type = "header-library" + package_type = "header-library" settings = "os", "arch", "compiler", "build_type" no_copy_source = True