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

sail: Fix compilation with shared=True #26150

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
21 changes: 21 additions & 0 deletions recipes/sail/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,24 @@ sources:
"0.9.0":
url: "https://github.com/HappySeaFox/sail/archive/v0.9.0.tar.gz"
sha256: "892738e0f56fed8c6387e1045bba2bfbf1b095024a495845d4879edb310cd1a7"
patches:
"0.9.6":
- patch_file: "patches/0.9.1-fix-libjxl-find.patch"
patch_description: "Fix find_package on libjxl dependency"
patch_type: "conan"
"0.9.5":
- patch_file: "patches/0.9.1-fix-libjxl-find.patch"
patch_description: "Fix find_package on libjxl dependency"
patch_type: "conan"
"0.9.4":
- patch_file: "patches/0.9.1-fix-libjxl-find.patch"
patch_description: "Fix find_package on libjxl dependency"
patch_type: "conan"
"0.9.1":
- patch_file: "patches/0.9.1-fix-libjxl-find.patch"
patch_description: "Fix find_package on libjxl dependency"
patch_type: "conan"
"0.9.0":
- patch_file: "patches/0.9.0-fix-libjxl-find.patch"
patch_description: "Fix find_package on libjxl dependency"
patch_type: "conan"
33 changes: 7 additions & 26 deletions recipes/sail/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, rename, rmdir
from conan.tools.microsoft import is_msvc
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, rename
from conan.tools.scm import Version
import os

required_conan_version = ">=1.53.0"
required_conan_version = ">=2.0.9"

class SAILConan(ConanFile):
name = "sail"
Expand Down Expand Up @@ -43,14 +42,10 @@ class SAILConan(ConanFile):
"with_low_priority_codecs": "Enable codecs: ICO, PCX, PNM, PSD, QOI, TGA",
"with_lowest_priority_codecs": "Enable codecs: WAL, XBM",
}
implements = ["auto_shared_fpic"]

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

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
def export_sources(self):
export_conandata_patches(self)

def requirements(self):
if self.options.with_highest_priority_codecs:
Expand All @@ -62,7 +57,7 @@ def requirements(self):
if Version(self.version) >= "0.9.1":
self.requires("nanosvg/cci.20231025")
if self.options.with_medium_priority_codecs:
self.requires("libavif/1.0.4")
self.requires("libavif/1.1.1")
self.requires("jasper/4.2.0")
self.requires("libjxl/0.8.2")
self.requires("libwebp/1.3.2")
Expand All @@ -73,6 +68,7 @@ def layout(self):
def source(self):
get(self, **self.conan_data["sources"][self.version],
strip_root=True, destination=self.source_folder)
apply_conandata_patches(self)

def generate(self):
only_codecs = []
Expand Down Expand Up @@ -130,21 +126,12 @@ def package(self):
def package_info(self):
self.cpp_info.set_property("cmake_file_name", "Sail")

self.cpp_info.filenames["cmake_find_package"] = "Sail"
self.cpp_info.filenames["cmake_find_package_multi"] = "Sail"
self.cpp_info.names["cmake_find_package"] = "SAIL"
self.cpp_info.names["cmake_find_package_multi"] = "SAIL"

self.cpp_info.components["sail-common"].set_property("cmake_target_name", "SAIL::SailCommon")
self.cpp_info.components["sail-common"].set_property("pkg_config_name", "libsail-common")
self.cpp_info.components["sail-common"].names["cmake_find_package"] = "SailCommon"
self.cpp_info.components["sail-common"].names["cmake_find_package_multi"] = "SailCommon"
self.cpp_info.components["sail-common"].includedirs = ["include/sail"]
self.cpp_info.components["sail-common"].libs = ["sail-common"]

self.cpp_info.components["sail-codecs"].set_property("cmake_target_name", "SAIL::SailCodecs")
self.cpp_info.components["sail-codecs"].names["cmake_find_package"] = "SailCodecs"
self.cpp_info.components["sail-codecs"].names["cmake_find_package_multi"] = "SailCodecs"
self.cpp_info.components["sail-codecs"].libs = ["sail-codecs"]
self.cpp_info.components["sail-codecs"].requires = ["sail-common"]

Expand All @@ -163,8 +150,6 @@ def package_info(self):

self.cpp_info.components["libsail"].set_property("cmake_target_name", "SAIL::Sail")
self.cpp_info.components["libsail"].set_property("pkg_config_name", "libsail")
self.cpp_info.components["libsail"].names["cmake_find_package"] = "Sail"
self.cpp_info.components["libsail"].names["cmake_find_package_multi"] = "Sail"
self.cpp_info.components["libsail"].libs = ["sail"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["libsail"].system_libs.append("dl")
Expand All @@ -174,14 +159,10 @@ def package_info(self):

self.cpp_info.components["sail-manip"].set_property("cmake_target_name", "SAIL::SailManip")
self.cpp_info.components["sail-manip"].set_property("pkg_config_name", "libsail-manip")
self.cpp_info.components["sail-manip"].names["cmake_find_package"] = "SailManip"
self.cpp_info.components["sail-manip"].names["cmake_find_package_multi"] = "SailManip"
self.cpp_info.components["sail-manip"].libs = ["sail-manip"]
self.cpp_info.components["sail-manip"].requires = ["sail-common"]

self.cpp_info.components["sail-c++"].set_property("cmake_target_name", "SAIL::SailC++")
self.cpp_info.components["sail-c++"].set_property("pkg_config_name", "libsail-c++")
self.cpp_info.components["sail-c++"].names["cmake_find_package"] = "SailC++"
self.cpp_info.components["sail-c++"].names["cmake_find_package_multi"] = "SailC++"
self.cpp_info.components["sail-c++"].libs = ["sail-c++"]
self.cpp_info.components["sail-c++"].requires = ["libsail", "sail-manip"]
28 changes: 28 additions & 0 deletions recipes/sail/all/patches/0.9.0-fix-libjxl-find.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/src/sail-codecs/jpegxl/CMakeLists.txt b/src/sail-codecs/jpegxl/CMakeLists.txt
index 54441fa6..7c290456 100644
--- a/src/sail-codecs/jpegxl/CMakeLists.txt
+++ b/src/sail-codecs/jpegxl/CMakeLists.txt
@@ -1,3 +1,4 @@
+if(0)
find_library(JPEGXL_LIBRARY jxl NAMES jxl jxl-static ${SAIL_CODEC_JPEGXL_REQUIRED_OPTION})
find_library(JPEGXL_THREADS_LIBRARY jxl_threads NAMES jxl_threads jxl_threads-static ${SAIL_CODEC_JPEGXL_REQUIRED_OPTION})
find_path(JPEGXL_INCLUDE_DIRS jxl/decode.h ${SAIL_CODEC_JPEGXL_REQUIRED_OPTION})
@@ -50,3 +51,18 @@ sail_codec(NAME jpegxl
DEPENDENCY_INCLUDE_DIRS ${JPEGXL_INCLUDE_DIRS}
DEPENDENCY_LIBS ${BROTLI_COMMON_LIBRARY} ${BROTLI_DEC_LIBRARY} ${HWY_LIBRARY}
${JPEGXL_LIBRARY} ${JPEGXL_THREADS_LIBRARY})
+endif()
+# Find libjxl package
+find_package(libjxl REQUIRED CONFIG)
+
+# Common codec configuration
+sail_codec(NAME jpegxl
+ SOURCES helpers.h helpers.c jpegxl.c memory.h memory.c
+ ICON jpegxl.png)
+
+# For static builds, define JXL_STATIC_DEFINE
+if(NOT BUILD_SHARED_LIBS)
+ target_compile_definitions(sail-codec-jpegxl PRIVATE JXL_STATIC_DEFINE)
perseoGI marked this conversation as resolved.
Show resolved Hide resolved
+endif()
+
+target_link_libraries(${SAIL_CODEC_TARGET} PRIVATE libjxl::libjxl)
28 changes: 28 additions & 0 deletions recipes/sail/all/patches/0.9.1-fix-libjxl-find.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/src/sail-codecs/jpegxl/CMakeLists.txt b/src/sail-codecs/jpegxl/CMakeLists.txt
index 16971a48..2bfc3930 100644
--- a/src/sail-codecs/jpegxl/CMakeLists.txt
+++ b/src/sail-codecs/jpegxl/CMakeLists.txt
@@ -1,3 +1,4 @@
+if(0)
# Don't use SAIL_CODEC_JPEGXL_REQUIRED_OPTION as it requires CMake 3.18
#
find_library(JPEGXL_LIBRARY jxl NAMES jxl jxl-static)
@@ -56,3 +57,18 @@ sail_codec(NAME jpegxl
DEPENDENCY_INCLUDE_DIRS ${JPEGXL_INCLUDE_DIRS}
DEPENDENCY_LIBS ${BROTLI_COMMON_LIBRARY} ${BROTLI_DEC_LIBRARY} ${HWY_LIBRARY}
${JPEGXL_LIBRARY} ${JPEGXL_THREADS_LIBRARY})
+endif()
+# Find libjxl package
+find_package(libjxl REQUIRED CONFIG)
+
+# Common codec configuration
+sail_codec(NAME jpegxl
+ SOURCES helpers.h helpers.c jpegxl.c memory.h memory.c
+ ICON jpegxl.png)
+
+# For static builds, define JXL_STATIC_DEFINE
+if(NOT BUILD_SHARED_LIBS)
+ target_compile_definitions(sail-codec-jpegxl PRIVATE JXL_STATIC_DEFINE)
+endif()
+
+target_link_libraries(${SAIL_CODEC_TARGET} PRIVATE libjxl::libjxl)
2 changes: 1 addition & 1 deletion recipes/sail/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.15)
project(test_package C CXX)

# Enable strict C++11
Expand Down