Skip to content

Commit

Permalink
(#24592) libheif: add version 1.18.1
Browse files Browse the repository at this point in the history
* libheif: add version 1.18.0

* update 1.18.1

* require cmake
  • Loading branch information
toge authored Aug 1, 2024
1 parent 364bac5 commit f774dcb
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
5 changes: 5 additions & 0 deletions recipes/libheif/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"1.18.1":
url: "https://github.com/strukturag/libheif/releases/download/v1.18.1/libheif-1.18.1.tar.gz"
sha256: "8702564b0f288707ea72b260b3bf4ba9bf7abfa7dac01353def3a86acd6bbb76"
"1.16.2":
url: "https://github.com/strukturag/libheif/releases/download/v1.16.2/libheif-1.16.2.tar.gz"
sha256: "7f97e4205c0bd9f9b8560536c8bd2e841d1c9a6d610401eb3eb87ed9cdfe78ea"
Expand All @@ -15,6 +18,8 @@ sources:
url: "https://github.com/strukturag/libheif/releases/download/v1.9.1/libheif-1.9.1.tar.gz"
sha256: "5f65ca2bd2510eed4e13bdca123131c64067e9dd809213d7aef4dc5e37948bca"
patches:
"1.18.1":
- patch_file: "patches/0001-cmake_1.18.1.patch"
"1.16.2":
- patch_file: "patches/0001-cmake_1.16.2.patch"
- patch_file: "patches/0002-plugins_cmake_1.16.2.patch"
Expand Down
41 changes: 38 additions & 3 deletions recipes/libheif/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
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"
Expand All @@ -10,11 +12,10 @@
class LibheifConan(ConanFile):
name = "libheif"
description = "libheif is an HEIF and AVIF file format decoder and encoder."
topics = ("heif", "codec", "video")
license = ("LGPL-3.0-only", "GPL-3.0-or-later", "MIT")
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/strukturag/libheif"
license = ("LGPL-3.0-only", "GPL-3.0-or-later", "MIT")

topics = ("heif", "codec", "video")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
Expand All @@ -24,6 +25,8 @@ class LibheifConan(ConanFile):
"with_x265": [True, False],
"with_libaomav1": [True, False],
"with_dav1d": [True, False],
"with_jpeg": [True, False],
"with_openjpeg": [True, False],
}
default_options = {
"shared": False,
Expand All @@ -32,6 +35,8 @@ class LibheifConan(ConanFile):
"with_x265": False,
"with_libaomav1": False,
"with_dav1d": False,
"with_jpeg": False,
"with_openjpeg": False,
}

def export_sources(self):
Expand All @@ -40,6 +45,9 @@ def export_sources(self):
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if Version(self.version) < "1.17.0":
del self.options.with_jpeg
del self.options.with_openjpeg

def configure(self):
if self.options.shared:
Expand All @@ -57,26 +65,47 @@ def requirements(self):
self.requires("libaom-av1/3.6.1")
if self.options.with_dav1d:
self.requires("dav1d/1.2.1")
if self.options.get_safe("with_jpeg"):
self.requires("libjpeg/9f")
if self.options.get_safe("with_openjpeg"):
self.requires("openjpeg/2.5.2")

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

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)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["WITH_LIBSHARPYUV"] = False
tc.variables["WITH_LIBDE265"] = self.options.with_libde265
tc.variables["WITH_X265"] = self.options.with_x265
tc.variables["WITH_AOM"] = self.options.with_libaomav1
tc.variables["WITH_AOM_DECODER"] = self.options.with_libaomav1
tc.variables["WITH_AOM_ENCODER"] = self.options.with_libaomav1
tc.variables["WITH_RAV1E"] = False
tc.variables["WITH_DAV1D"] = self.options.with_dav1d
tc.variables["WITH_EXAMPLES"] = False
tc.variables["WITH_GDK_PIXBUF"] = False
tc.variables["BUILD_TESTING"] = False
tc.variables["WITH_JPEG_DECODER"] = self.options.get_safe("with_jpeg", False)
tc.variables["WITH_JPEG_ENCODER"] = self.options.get_safe("with_jpeg", False)
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.generate()
deps = CMakeDeps(self)
if Version(self.version) >= "1.18.0":
deps.set_property("libde265", "cmake_file_name", "LIBDE265")
deps.generate()
if Version(self.version) >= "1.18.0":
venv = VirtualBuildEnv(self)
venv.generate(scope="build")

def build(self):
apply_conandata_patches(self)
Expand All @@ -101,6 +130,8 @@ def package_info(self):
self.cpp_info.components["heif"].defines = ["LIBHEIF_STATIC_BUILD"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["heif"].system_libs.extend(["m", "pthread"])
if Version(self.version) >= "1.18.0":
self.cpp_info.components["heif"].system_libs.append("dl")
if not self.options.shared:
libcxx = stdcpp_library(self)
if libcxx:
Expand All @@ -118,3 +149,7 @@ def package_info(self):
self.cpp_info.components["heif"].requires.append("libaom-av1::libaom-av1")
if self.options.with_dav1d:
self.cpp_info.components["heif"].requires.append("dav1d::dav1d")
if self.options.get_safe("with_jpeg"):
self.cpp_info.components["heif"].requires.append("libjpeg::libjpeg")
if self.options.get_safe("with_openjpeg"):
self.cpp_info.components["heif"].requires.append("openjpeg::openjpeg")
13 changes: 13 additions & 0 deletions recipes/libheif/all/patches/0001-cmake_1.18.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 12c4039..2ea1805 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,7 +47,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)

-set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+# set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Create the compile command database for clang by default
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
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.18.1":
folder: all
"1.16.2":
folder: all
"1.13.0":
Expand Down

0 comments on commit f774dcb

Please sign in to comment.