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

hdf4: improve dependencies handling + allow macos M1 shared + modernize #6676

Merged
merged 6 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
25 changes: 11 additions & 14 deletions recipes/hdf4/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from conans import ConanFile, CMake, tools
import os

from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
required_conan_version = ">=1.33.0"


class Hdf4Conan(ConanFile):
name = "hdf4"
Expand All @@ -10,24 +11,25 @@ class Hdf4Conan(ConanFile):
topics = ("conan", "hdf4", "hdf", "data")
homepage = "https://portal.hdfgroup.org/display/HDF4/HDF4"
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],
"jpegturbo": [True, False],
"szip_support": [None, "with_libaec", "with_szip"],
"szip_encoding": [True, False]
"szip_encoding": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"jpegturbo": False,
"szip_support": None,
"szip_encoding": False
"szip_encoding": False,
}

exports_sources = ["CMakeLists.txt", "patches/**"]
generators = "cmake", "cmake_find_package"
_cmake = None

@property
Expand All @@ -53,22 +55,17 @@ def configure(self):
def requirements(self):
self.requires("zlib/1.2.11")
if self.options.jpegturbo:
self.requires("libjpeg-turbo/2.0.4")
self.requires("libjpeg-turbo/2.1.0")
else:
self.requires("libjpeg/9d")
if self.options.szip_support == "with_libaec":
self.requires("libaec/1.0.4")
elif self.options.szip_support == "with_szip":
self.requires("szip/2.1.1")

def validate(self):
if self.settings.os == "Macos" and self.settings.arch == "armv8" and self.options.shared:
# FIXME: Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being
raise ConanInvalidConfiguration("shared M1 builds aren't supported right away!")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename("hdf-" + self.version, self._source_subfolder)
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
Expand Down
4 changes: 2 additions & 2 deletions recipes/hdf4/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 3.1)
project(test_package C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
conan_basic_setup(TARGETS)

find_package(hdf4 REQUIRED)

add_executable(${PROJECT_NAME} test_package.c)
if(HDF4_SHARED)
if(TARGET hdf4::hdf-shared)
target_link_libraries(${PROJECT_NAME} hdf4::hdf-shared)
else()
target_link_libraries(${PROJECT_NAME} hdf4::hdf-static)
Expand Down
5 changes: 2 additions & 3 deletions recipes/hdf4/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
from conans import ConanFile, CMake, tools
import os

from conans import ConanFile, CMake, tools

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package"
SSE4 marked this conversation as resolved.
Show resolved Hide resolved

def build(self):
cmake = CMake(self)
cmake.definitions["HDF4_SHARED"] = self.options["hdf4"].shared
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)