Skip to content

Commit

Permalink
libheif: add version 1.19.0 (#25783)
Browse files Browse the repository at this point in the history
Co-authored-by: Abril Rincón Blanco <[email protected]>
  • Loading branch information
toge and AbrilRBS authored Nov 11, 2024
1 parent 89970d5 commit 2ab569b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 27 deletions.
3 changes: 3 additions & 0 deletions recipes/libheif/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"1.19.0":
url: "https://github.com/strukturag/libheif/releases/download/v1.19.0/libheif-1.19.0.tar.gz"
sha256: "c0323638557994791c7bf939ee9752e8a0f3f5ce4f07328daefa0159e3530eb4"
"1.18.2":
url: "https://github.com/strukturag/libheif/releases/download/v1.18.2/libheif-1.18.2.tar.gz"
sha256: "c4002a622bec9f519f29d84bfdc6024e33fd67953a5fb4dc2c2f11f67d5e45bf"
Expand Down
59 changes: 33 additions & 26 deletions recipes/libheif/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir
from conan.tools.scm import Version
from conan.tools.env import VirtualBuildEnv
import os

required_conan_version = ">=1.54.0"
required_conan_version = ">=2.1"


class LibheifConan(ConanFile):
Expand All @@ -28,6 +28,7 @@ class LibheifConan(ConanFile):
"with_jpeg": [True, False],
"with_openjpeg": [True, False],
"with_openjph": [True, False],
"with_openh264": [True, False],
}
default_options = {
"shared": False,
Expand All @@ -39,8 +40,13 @@ class LibheifConan(ConanFile):
"with_jpeg": False,
"with_openjpeg": False,
"with_openjph": False,
"with_openh264": False,
}

@property
def _min_cppstd(self):
return "20" if Version(self.version) >= "1.19.0" else "11"

def export_sources(self):
export_conandata_patches(self)

Expand All @@ -52,6 +58,8 @@ def config_options(self):
del self.options.with_openjpeg
if Version(self.version) < "1.18.0":
del self.options.with_openjph
if Version(self.version) < "1.19.0":
del self.options.with_openh264

def configure(self):
if self.options.shared:
Expand All @@ -75,17 +83,19 @@ def requirements(self):
self.requires("openjpeg/2.5.2")
if self.options.get_safe("with_openjph"):
self.requires("openjph/0.16.0", transitive_headers=False)
if self.options.get_safe("with_openh264"):
self.requires("openh264/2.4.1")

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, 11)
check_min_cppstd(self, self._min_cppstd)

def build_requirements(self):
if Version(self.version) >= "1.18.0":
self.tool_requires("cmake/[>=3.16 <4]")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
apply_conandata_patches(self)

def generate(self):
tc = CMakeToolchain(self)
Expand All @@ -105,21 +115,20 @@ def generate(self):
tc.variables["WITH_OpenJPEG_DECODER"] = self.options.get_safe("with_openjpeg", False)
tc.variables["WITH_OpenJPEG_ENCODER"] = self.options.get_safe("with_openjpeg", False)
tc.variables["WITH_OPENJPH_ENCODER"] = self.options.get_safe("with_openjph", False)
tc.variables["WITH_OPENH264_DECODER"] = self.options.get_safe("with_openh264", False)
# Disable finding possible Doxygen in system, so no docs are built
tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Doxygen"] = True

tc.cache_variables["CMAKE_COMPILE_WARNING_AS_ERROR"] = False
tc.generate()
deps = CMakeDeps(self)
if Version(self.version) >= "1.18.0":
deps.set_property("libde265", "cmake_file_name", "LIBDE265")
deps.set_property("openjph", "cmake_file_name", "OPENJPH")
if Version(self.version) >= "1.19.0":
deps.set_property("openh264", "cmake_file_name", "OpenH264")
deps.generate()
if Version(self.version) >= "1.18.0":
venv = VirtualBuildEnv(self)
venv.generate(scope="build")

def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()
Expand All @@ -135,34 +144,32 @@ def package_info(self):
self.cpp_info.set_property("cmake_file_name", "libheif")
self.cpp_info.set_property("cmake_target_name", "libheif::heif")
self.cpp_info.set_property("pkg_config_name", "libheif")
# TODO: back to global scope in conan v2 once cmake_find_package_* generators removed
self.cpp_info.components["heif"].libs = ["heif"]
self.cpp_info.libs = ["heif"]

if not self.options.shared:
self.cpp_info.components["heif"].defines = ["LIBHEIF_STATIC_BUILD"]
self.cpp_info.defines = ["LIBHEIF_STATIC_BUILD"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["heif"].system_libs.extend(["m", "pthread"])
self.cpp_info.system_libs.extend(["m", "pthread"])
if Version(self.version) >= "1.18.0":
self.cpp_info.components["heif"].system_libs.append("dl")
self.cpp_info.system_libs.append("dl")
if not self.options.shared:
libcxx = stdcpp_library(self)
if libcxx:
self.cpp_info.components["heif"].system_libs.append(libcxx)
self.cpp_info.system_libs.append(libcxx)

# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.components["heif"].set_property("cmake_target_name", "libheif::heif")
self.cpp_info.components["heif"].set_property("pkg_config_name", "libheif")
self.cpp_info.components["heif"].requires = []
if self.options.with_libde265:
self.cpp_info.components["heif"].requires.append("libde265::libde265")
self.cpp_info.requires.append("libde265::libde265")
if self.options.with_x265:
self.cpp_info.components["heif"].requires.append("libx265::libx265")
self.cpp_info.requires.append("libx265::libx265")
if self.options.with_libaomav1:
self.cpp_info.components["heif"].requires.append("libaom-av1::libaom-av1")
self.cpp_info.requires.append("libaom-av1::libaom-av1")
if self.options.with_dav1d:
self.cpp_info.components["heif"].requires.append("dav1d::dav1d")
self.cpp_info.requires.append("dav1d::dav1d")
if self.options.get_safe("with_jpeg"):
self.cpp_info.components["heif"].requires.append("libjpeg::libjpeg")
self.cpp_info.requires.append("libjpeg::libjpeg")
if self.options.get_safe("with_openjpeg"):
self.cpp_info.components["heif"].requires.append("openjpeg::openjpeg")
self.cpp_info.requires.append("openjpeg::openjpeg")
if self.options.get_safe("with_openjph"):
self.cpp_info.components["heif"].requires.append("openjph::openjph")
self.cpp_info.requires.append("openjph::openjph")
if self.options.get_safe("with_openh264"):
self.cpp_info.requires.append("openh264::openh264")
6 changes: 5 additions & 1 deletion recipes/libheif/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ find_package(libheif REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE libheif::heif)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
if(libheif_VERSION VERSION_GREATER_EQUAL "1.19.0")
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
else()
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
endif()
2 changes: 2 additions & 0 deletions recipes/libheif/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"1.19.0":
folder: all
"1.18.2":
folder: all
"1.18.1":
Expand Down

0 comments on commit 2ab569b

Please sign in to comment.