Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kealib: migrate to Conan v2 #18680

Merged
merged 22 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions recipes/kealib/all/CMakeLists.txt

This file was deleted.

16 changes: 6 additions & 10 deletions recipes/kealib/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
sources:
"1.5.2":
url: "https://github.com/ubarsc/kealib/archive/refs/tags/kealib-1.5.2.tar.gz"
sha256: "f16a51007ab7612aa598de6ee2cac0aa4421040894777c8e57cb4a50ea552ab1"
"1.4.15":
url: "https://github.com/ubarsc/kealib/archive/kealib-1.4.15.tar.gz"
sha256: "fc7bd049663985e9528acd894724f0c730c84a3408d5bff3c0c0f01d7c6cd172"
"1.4.14":
url: "https://github.com/ubarsc/kealib/archive/kealib-1.4.14.tar.gz"
sha256: "b3f73104acebe5304ecce5c19c1560def66fd5c448ce251e9486494baeb141bc"
"1.4.13":
url: "https://github.com/ubarsc/kealib/archive/kealib-1.4.13.tar.gz"
sha256: "2a254eb557a4ec20638a5134ed549a16b7f64977f37de3cf3853a206c8d82199"
patches:
"1.4.14":
- patch_file: "patches/fix-cmake-1.4.14.patch"
base_path: "source_subfolder"
"1.4.13":
- patch_file: "patches/fix-export-symbols-and-cmake.patch"
base_path: "source_subfolder"
105 changes: 66 additions & 39 deletions recipes/kealib/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,74 +1,101 @@
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.32.0"
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd, valid_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, rmdir
from conan.tools.microsoft import is_msvc
from conan.tools.scm import Version

required_conan_version = ">=1.53.0"


class KealibConan(ConanFile):
name = "kealib"
description = "C++ library providing complete access to the KEA image format."
license = "MIT"
topics = ("conan", "kealib", "image", "raster")
homepage = "https://github.com/ubarsc/kealib"
url = "https://github.com/conan-io/conan-center-index"
exports_sources = ["CMakeLists.txt", "patches/**"]
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}

_cmake = None
homepage = "https://github.com/ubarsc/kealib"
topics = ("image", "raster")

@property
def _source_subfolder(self):
return "source_subfolder"
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}

@property
def _build_subfolder(self):
return "build_subfolder"
def _min_cppstd(self):
return 11

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
del self.options.fPIC
self.options.rm_safe("fPIC")
self.options["hdf5"].enable_cxx = True
self.options["hdf5"].hl = True

def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
self.requires("hdf5/1.12.0")
self.requires("hdf5/1.14.3", transitive_headers=True, transitive_libs=True)

def validate(self):
if not (self.options["hdf5"].enable_cxx and self.options["hdf5"].hl):
raise ConanInvalidConfiguration("kealib requires hdf5 with cxx and hl enabled.")
if self.settings.compiler.cppstd:
check_min_cppstd(self, self._min_cppstd)
hdf5_opts = self.dependencies["hdf5"].options
if not (hdf5_opts.enable_cxx and hdf5_opts.hl):
raise ConanInvalidConfiguration(f"{self.ref} requires dependencies options -o 'hdf5/*:enable_cxx=True' -o 'hdf5/*:hl=True'")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("{0}-{0}-{1}".format(self.name, self.version), self._source_subfolder)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["HDF5_USE_STATIC_LIBRARIES"] = not self.options["hdf5"].shared
self._cmake.definitions["HDF5_PREFER_PARALLEL"] = False # TODO: rely on self.options["hdf5"].parallel when implemented in hdf5 recipe
self._cmake.definitions["LIBKEA_WITH_GDAL"] = False
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["HDF5_USE_STATIC_LIBRARIES"] = not self.dependencies["hdf5"].options.shared
tc.variables["HDF5_PREFER_PARALLEL"] = self.dependencies["hdf5"].options.parallel
tc.variables["HDF5_THREADSAFE"] = self.dependencies["hdf5"].options.get_safe("threadsafe", False)
tc.variables["LIBKEA_WITH_GDAL"] = False
# INFO: kealib uses C++11 but does not configure in cmake: https://github.com/ubarsc/kealib/pull/48
if not valid_min_cppstd(self, self._min_cppstd):
tc.variables["CMAKE_CXX_STANDARD"] = self._min_cppstd
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
tc.generate()

tc = CMakeDeps(self)
tc.generate()

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
cmake = self._configure_cmake()
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
copy(self, "LICENSE.txt",
dst=os.path.join(self.package_folder, "licenses"),
src=self.source_folder)
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))

def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
if is_msvc(self):
if not self.options.shared and Version(self.version) <= "1.4.14":
self.cpp_info.libs = ["liblibkea"]
else:
self.cpp_info.libs = ["libkea"]
else:
self.cpp_info.libs = ["kea"]

if self.settings.os == "Windows":
self.cpp_info.system_libs.append("shlwapi")
20 changes: 0 additions & 20 deletions recipes/kealib/all/patches/fix-cmake-1.4.14.patch

This file was deleted.

Loading
Loading