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

libjxl: add versoin 0.9.1 and support conan v2 #13898

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0b2f7bb
libjxl: add versoin 0.7.0 and support conan v2
toge Oct 10, 2022
38c4ba0
support 0.7.0
toge Oct 26, 2022
8b51942
apply patches for conan v2 to version 0.5 and 0.6
toge Oct 31, 2022
ed532ee
link brotli in encoder
toge Nov 2, 2022
59a92e7
use cmake_find_package_multi
toge Nov 2, 2022
3b2be58
use self.build_folder, self.package_folder
toge Nov 2, 2022
a6d38c3
support shared build
toge Nov 6, 2022
ee3840b
disable jxl_dec on build shared
toge Nov 7, 2022
4ec9605
add LERC_STATIC
toge Nov 7, 2022
d1e578c
Revert "add LERC_STATIC"
toge Nov 7, 2022
831c39b
link dependant libraries to shared lib
toge Nov 7, 2022
43e8d2d
set FORCE_SYSTEM_xxx TRue
toge Nov 9, 2022
d537622
add validation check for highway shared
toge Nov 10, 2022
d63a47e
enable validatation only when highway has shared option
toge Nov 10, 2022
65f582a
fix lint errors
toge Jan 12, 2023
32da4c8
update 0.8.1
toge Feb 7, 2023
12e129c
Merge branch 'libjxl-0.7.0' of /~https://github.com/toge/conan-center-i…
toge Feb 7, 2023
b1b3cef
improve recipe to follow comments
toge May 24, 2023
91f959d
rename highway target names in jpegli
toge May 25, 2023
0dbb7ec
remove brotli static lib
toge May 26, 2023
d051d81
fix msvc installation error
toge May 28, 2023
4e91e30
support shared build in 0.5.0
toge May 30, 2023
97ab07f
drop support msvc shared build
toge Jul 6, 2023
c998531
Merge branch 'master' into libjxl-0.7.0
toge Aug 16, 2023
9e5869b
update 0.8.2
toge Aug 19, 2023
6d72dd7
apply RubenRBS's patch
toge Sep 7, 2023
50a0110
update validate
toge Nov 3, 2023
d66b040
Merge branch 'master' into libjxl-0.7.0
toge Nov 4, 2023
aec1ef2
update 0.9.0
toge Jan 8, 2024
c7550ee
Merge branch 'libjxl-0.7.0' of /~https://github.com/toge/conan-center-i…
toge Jan 8, 2024
4426ecc
update 0.9.1
toge Jan 12, 2024
69ae6b0
fix cci error
toge Jan 13, 2024
108e18e
drop support clang with libc++
toge Jan 13, 2024
fea2ec0
fix package name for ConanInvalidConfiguration
toge Jan 13, 2024
148f58c
don't require lcms since 0.9.0
toge Jan 14, 2024
92f77eb
(trial) don't support cross building on apple-clang in 0.9.1
toge Jan 14, 2024
963848c
revert lcms
toge Jan 14, 2024
518dcff
update brotli/1.1.0
toge Jan 21, 2024
e57695e
fix shared build
toge Jan 21, 2024
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/libjxl/all/CMakeLists.txt

This file was deleted.

38 changes: 26 additions & 12 deletions recipes/libjxl/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
sources:
"0.5.0":
url: "/~https://github.com/libjxl/libjxl/archive/v0.5.zip"
sha256: "a208be41542c6f81f10a82c6bb4bc75d3eceb9d4f7ecb6ea0ad2f2d236694c4b"
"0.7.0":
url: "/~https://github.com/libjxl/libjxl/archive/v0.7.0.tar.gz"
sha256: "3114bba1fabb36f6f4adc2632717209aa6f84077bc4e93b420e0d63fa0455c5e"
"0.6.1":
url: "/~https://github.com/libjxl/libjxl/archive/v0.6.1.zip"
sha256: "3e4877daef07724aa6f490bf80c45ada804f35fe3cce59c27e89c5ae3099535a"
patches:
url: "/~https://github.com/libjxl/libjxl/archive/v0.6.1.tar.gz"
sha256: "ccbd5a729d730152303be399f033b905e608309d5802d77a61a95faa092592c5"
"0.5.0":
- patch_file: "patches/0001-clean-targets-v0.5.patch"
base_path: "source_subfolder"
- patch_file: "patches/0002-fix-dependencies-v0.5.patch"
base_path: "source_subfolder"
url: "/~https://github.com/libjxl/libjxl/archive/v0.5.tar.gz"
sha256: "911cb4b50eb621131ca22382166f40d4914a4ff4453dd299ade1e3292f311f89"
patches:
"0.7.0":
- patch_file: "patches/0001-clean-targets-v0.7.patch"
patch_description: "remove several targets not used in conan recipe"
patch_type: "conan"
- patch_file: "patches/0002-fix-dependencies-v0.7.patch"
patch_description: "use find_package for third party libraries"
patch_type: "conan"
"0.6.1":
- patch_file: "patches/0001-clean-targets-v0.6.patch"
base_path: "source_subfolder"
patch_description: "remove several targets not used in conan recipe"
patch_type: "conan"
- patch_file: "patches/0002-fix-dependencies-v0.6.patch"
base_path: "source_subfolder"
patch_description: "use find_package for third party libraries"
patch_type: "conan"
"0.5.0":
- patch_file: "patches/0001-clean-targets-v0.5.patch"
patch_description: "remove several targets not used in conan recipe"
patch_type: "conan"
- patch_file: "patches/0002-fix-dependencies-v0.5.patch"
patch_description: "use find_package for third party libraries"
patch_type: "conan"
162 changes: 96 additions & 66 deletions recipes/libjxl/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from conans import ConanFile, CMake, tools
import os
import shutil
import glob
from conan import ConanFile
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, rmdir
from conan.tools.build import check_min_cppstd, cross_building
from conan.tools.scm import Version
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout

required_conan_version = ">=1.33.0"
import os

required_conan_version = ">=1.52.0"

class LibjxlConan(ConanFile):
name = "libjxl"
Expand All @@ -13,90 +15,115 @@ class LibjxlConan(ConanFile):
url = "/~https://github.com/conan-io/conan-center-index"
homepage = "/~https://github.com/libjxl/libjxl"
topics = ("image", "jpeg-xl", "jxl", "jpeg")

settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}

exports_sources = "CMakeLists.txt", "patches/**"
generators = "cmake"
_cmake = None
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}

@property
def _source_subfolder(self):
return "source_subfolder"
def _minimum_cpp_standard(self):
return 11

def export_sources(self):
export_conandata_patches(self)

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

def configure(self):
if self.options.shared:
del self.options.fPIC
try:
del self.options.fPIC
except Exception:
pass
# prevent hidden symbols of highway which are referenced by DSO
self.options["highway"].shared = True

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

def requirements(self):
self.requires("brotli/1.0.9")
self.requires("highway/0.12.2")
self.requires("lcms/2.11")
if Version(self.version) < "0.7.0":
self.requires("highway/0.12.2")
else:
self.requires("highway/1.0.2")
self.requires("lcms/2.14")

def validate(self):
if self.info.settings.compiler.cppstd:
check_min_cppstd(self, self._minimum_cpp_standard)
highway = self.dependencies["highway"]
if not highway.options.shared and self.options.shared:
raise ConanInvalidConfigution(f"{self.ref}:shared=True requires -o highway:shared=True")

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

def _patch_sources(self):
for patch in self.conan_data["patches"][self.version]:
tools.patch(**patch)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["BUILD_TESTING"] = False
self._cmake.definitions["JPEGXL_STATIC"] = not self.options.shared
self._cmake.definitions["JPEGXL_ENABLE_BENCHMARK"] = False
self._cmake.definitions["JPEGXL_ENABLE_EXAMPLES"] = False
self._cmake.definitions["JPEGXL_ENABLE_MANPAGES"] = False
self._cmake.definitions["JPEGXL_ENABLE_SJPEG"] = False
self._cmake.definitions["JPEGXL_ENABLE_OPENEXR"] = False
self._cmake.definitions["JPEGXL_ENABLE_SKCMS"] = False
self._cmake.definitions["JPEGXL_ENABLE_TCMALLOC"] = False
if tools.cross_building(self):
self._cmake.definitions["CMAKE_SYSTEM_PROCESSOR"] = \
get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_TESTING"] = False
tc.variables["JPEGXL_STATIC"] = not self.options.shared
tc.variables["JPEGXL_ENABLE_BENCHMARK"] = False
tc.variables["JPEGXL_ENABLE_EXAMPLES"] = False
tc.variables["JPEGXL_ENABLE_MANPAGES"] = False
tc.variables["JPEGXL_ENABLE_SJPEG"] = False
tc.variables["JPEGXL_ENABLE_OPENEXR"] = False
tc.variables["JPEGXL_ENABLE_SKCMS"] = False
tc.variables["JPEGXL_ENABLE_TCMALLOC"] = False
tc.variables["JPEGXL_FORCE_SYSTEM_BROTLI"] = True
tc.variables["JPEGXL_FORCE_SYSTEM_HWY"] = True
tc.variables["JPEGXL_FORCE_SYSTEM_LCMS2"] = True
if cross_building(self):
tc.variables["CMAKE_SYSTEM_PROCESSOR"] = \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless with CMakeToolchain

str(self.settings.arch)
self._cmake.configure()
return self._cmake
tc.variables["JPEGXL_ENABLE_TOOLS"] = False
tc.generate()

deps = CMakeDeps(self)
deps.generate()

def build(self):
self._patch_sources()
cmake = self._configure_cmake()
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
cmake = self._configure_cmake()
cmake = CMake(self)
cmake.install()

self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))

if self.options.shared:
libs_dir = os.path.join(self.package_folder, "lib")
tools.remove_files_by_mask(libs_dir, "*.a")
tools.remove_files_by_mask(libs_dir, "*-static.lib")

if self.settings.os == "Windows":
self.copy("jxl_dec.dll", src="bin", dst="bin")
self.copy("jxl_dec.lib", src="lib", dst="lib")
for dll_path in glob.glob(os.path.join(libs_dir, "*.dll")):
shutil.move(dll_path, os.path.join(self.package_folder,
"bin", os.path.basename(dll_path)))
else:
self.copy("libjxl_dec.*", src="lib", dst="lib")
rm(self, pattern="*.a", folder=libs_dir)
rm(self, pattern="*-static.lib", folder=libs_dir)

def _lib_name(self, name):
if not self.options.shared and self.settings.os == "Windows":
return name + "-static"
return name

def _stdcpp_library(self):
libcxx = self.settings.get_safe("compiler.libcxx")
if libcxx in ["libstdc++", "libstdc++11"]:
return "stdc++"
elif libcxx in ["libc++"]:
return "c++"
elif libcxx in ["c++_shared"]:
return "c++_shared"
elif libcxx in ["c++_static"]:
return "c++_static"
return None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is stdcpp_library in conan.tools.build

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SpaceIm
Sorry for my late response.
I'm going to improve this PR with your comments.


def package_info(self):
# jxl
self.cpp_info.components["jxl"].names["pkg_config"] = "libjxl"
Expand All @@ -105,11 +132,14 @@ def package_info(self):
"highway::highway",
"lcms::lcms"]
# jxl_dec
self.cpp_info.components["jxl_dec"].names["pkg_config"] = "libjxl_dec"
self.cpp_info.components["jxl_dec"].libs = [self._lib_name("jxl_dec")]
self.cpp_info.components["jxl_dec"].requires = ["brotli::brotli",
"highway::highway",
"lcms::lcms"]
# in shared build, install jxl only.
# /~https://github.com/libjxl/libjxl/blob/v0.5.0/lib/jxl.cmake#L544-L546
if not self.options.shared:
self.cpp_info.components["jxl_dec"].names["pkg_config"] = "libjxl_dec"
self.cpp_info.components["jxl_dec"].libs = [self._lib_name("jxl_dec")]
self.cpp_info.components["jxl_dec"].requires = ["brotli::brotli",
"highway::highway",
"lcms::lcms"]
# jxl_threads
self.cpp_info.components["jxl_threads"].names["pkg_config"] = \
"libjxl_threads"
Expand All @@ -118,10 +148,10 @@ def package_info(self):
if self.settings.os == "Linux":
self.cpp_info.components["jxl_threads"].system_libs = ["pthread"]

if not self.options.shared and tools.stdcpp_library(self):
if not self.options.shared and self._stdcpp_library():
self.cpp_info.components["jxl"].system_libs.append(
tools.stdcpp_library(self))
self._stdcpp_library())
self.cpp_info.components["jxl_dec"].system_libs.append(
tools.stdcpp_library(self))
self._stdcpp_library())
self.cpp_info.components["jxl_threads"].system_libs.append(
tools.stdcpp_library(self))
self._stdcpp_library())
27 changes: 27 additions & 0 deletions recipes/libjxl/all/patches/0001-clean-targets-v0.7.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 533815d..debc90e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -191,8 +191,6 @@ if(JPEGXL_STATIC)
# so just linking all other libraries is fine.
if (NOT MSVC AND NOT APPLE)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
- set(CMAKE_EXE_LINKER_FLAGS
- "${CMAKE_EXE_LINKER_FLAGS} -static -static-libgcc -static-libstdc++")
endif()
endif() # JPEGXL_STATIC

@@ -331,7 +329,6 @@ include(GNUInstallDirs)
# Separately build/configure testing frameworks and other third_party libraries
# to allow disabling tests in those libraries.
include(third_party/testing.cmake)
-add_subdirectory(third_party)
# Copy the JXL license file to the output build directory.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
${PROJECT_BINARY_DIR}/LICENSE.jpeg-xl COPYONLY)
@@ -468,5 +465,3 @@ if (JPEGXL_ENABLE_PLUGINS)
add_subdirectory(plugins)
endif ()

-# Binary tools
-add_subdirectory(tools)
Loading