Skip to content

leptonica: add version 1.83.0 #14864

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

Merged
merged 16 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from 12 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
6 changes: 6 additions & 0 deletions recipes/leptonica/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"1.83.0":
url: "https://github.com/DanBloomberg/leptonica/archive/1.83.0.tar.gz"
sha256: "14cf531c2219a1414e8e3c51a3caa5cf021a52e782c4a6561bf64d0ef2119282"
"1.82.0":
url: "https://github.com/DanBloomberg/leptonica/archive/1.82.0.tar.gz"
sha256: "40fa9ac1e815b91e0fa73f0737e60c9eec433a95fa123f95f2573dd3127dd669"
Expand All @@ -17,3 +20,6 @@ sources:
patches:
"1.78.0":
- patch_file: "patches/fix-find-modules-variables.patch"
patch_description: "CMake: robust handling of dependencies"
patch_type: "portability"
patch_source: "https://github.com/DanBloomberg/leptonica/pull/456"
81 changes: 48 additions & 33 deletions recipes/leptonica/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import textwrap

required_conan_version = ">=1.52.0"
required_conan_version = ">=1.53.0"


class LeptonicaConan(ConanFile):
Expand Down Expand Up @@ -55,18 +55,9 @@ def configure(self):
if self.options.with_tiff:
self.options["libtiff"].jpeg = self.options.with_jpeg
if self.options.shared:
try:
del self.options.fPIC
except Exception:
pass
try:
del self.settings.compiler.libcxx
except Exception:
pass
try:
del self.settings.compiler.cppstd
except Exception:
pass
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")

def layout(self):
cmake_layout(self, src_folder="src")
Expand All @@ -85,7 +76,11 @@ def requirements(self):
if self.options.with_tiff:
self.requires("libtiff/4.4.0")
if self.options.with_openjpeg:
self.requires("openjpeg/2.5.0")
if Version(self.version) >= "1.83.0":
# newer leptonica can autodetect any openjpeg version
self.requires("openjpeg/2.5.0")
else:
self.requires("openjpeg/2.4.0")
if self.options.with_webp:
self.requires("libwebp/1.2.4")

Expand All @@ -108,6 +103,9 @@ def generate(self):
tc.variables["STATIC"] = not self.options.shared
tc.variables["BUILD_PROG"] = False
tc.variables["SW_BUILD"] = False
if Version(self.version) >= "1.83.0":
tc.variables["LIBWEBP_SUPPORT"] = self.options.with_webp
tc.variables["OPENJPEG_SUPPORT"] = self.options.with_openjpeg
tc.generate()
deps = CMakeDeps(self)
deps.generate()
Expand Down Expand Up @@ -139,47 +137,64 @@ def _patch_sources(self):
replace_in_file(self, cmakelists_src, "${GIF_LIBRARIES}", "GIF::GIF")
if not self.options.with_gif:
replace_in_file(self, cmakelists_src, "if (GIF_LIBRARIES)", "if(0)")
replace_in_file(self, cmake_configure, "if (GIF_FOUND)", "if(0)")
if Version(self.version) >= "1.83.0":
replace_in_file(self, cmake_configure, "if(GIF_FOUND)", "if(0)")
Copy link
Contributor

Choose a reason for hiding this comment

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

I would love to see patches for this project in the future 🙏

else:
replace_in_file(self, cmake_configure, "if (GIF_FOUND)", "if(0)")
## libjpeg
replace_in_file(self, cmakelists_src, "${JPEG_LIBRARIES}", "JPEG::JPEG")
if not self.options.with_jpeg:
replace_in_file(self, cmakelists_src, "if (JPEG_LIBRARIES)", "if(0)")
replace_in_file(self, cmake_configure, "if (JPEG_FOUND)", "if(0)")
if Version(self.version) >= "1.83.0":
replace_in_file(self, cmake_configure, "if(JPEG_FOUND)", "if(0)")
else:
replace_in_file(self, cmake_configure, "if (JPEG_FOUND)", "if(0)")
## libpng
replace_in_file(self, cmakelists_src, "${PNG_LIBRARIES}", "PNG::PNG")
if not self.options.with_png:
replace_in_file(self, cmakelists_src, "if (PNG_LIBRARIES)", "if(0)")
replace_in_file(self, cmake_configure, "if (PNG_FOUND)", "if(0)")
if Version(self.version) >= "1.83.0":
replace_in_file(self, cmake_configure, "if(PNG_FOUND)", "if(0)")
else:
replace_in_file(self, cmake_configure, "if (PNG_FOUND)", "if(0)")
## libtiff
replace_in_file(self, cmakelists_src, "${TIFF_LIBRARIES}", "TIFF::TIFF")
if not self.options.with_tiff:
replace_in_file(self, cmakelists_src, "if (TIFF_LIBRARIES)", "if(0)")
replace_in_file(self, cmake_configure, "if (TIFF_FOUND)", "if(0)")
if Version(self.version) >= "1.83.0":
replace_in_file(self, cmake_configure, "if(TIFF_FOUND)", "if(0)")
else:
replace_in_file(self, cmake_configure, "if (TIFF_FOUND)", "if(0)")
## We have to be more aggressive with dependencies found with pkgconfig
## Injection of libdirs is ensured by conan_basic_setup()
## openjpeg
replace_in_file(self, cmakelists, "if(NOT JP2K)", "if(0)")
replace_in_file(self, cmakelists_src,
"if (JP2K_FOUND)",
"if (JP2K_FOUND)\n"
"target_link_directories(leptonica PRIVATE ${JP2K_LIBRARY_DIRS})\n"
"target_compile_definitions(leptonica PRIVATE ${JP2K_CFLAGS_OTHER})")
if not self.options.with_openjpeg:
replace_in_file(self, cmakelists_src, "if (JP2K_FOUND)", "if(0)")
replace_in_file(self, cmake_configure, "if (JP2K_FOUND)", "if(0)")
replace_in_file(self, cmakelists_src, "${JP2K_LIBRARIES}", "openjp2")
if Version(self.version) < "1.83.0":
# versions below 1.83.0 do not have an option toggle
replace_in_file(self, cmakelists, "if(NOT JP2K)", "if(0)")
if not self.options.with_openjpeg:
replace_in_file(self, cmakelists_src, "if (JP2K_FOUND)", "if(0)")
replace_in_file(self, cmake_configure, "if (JP2K_FOUND)", "if(0)")
else:
replace_in_file(self, cmakelists, "set(JP2K_INCLUDE_DIRS ${OPENJPEG_INCLUDE_DIRS})", "set(JP2K_INCLUDE_DIRS ${OpenJPEG_INCLUDE_DIRS})")
if not self.options.with_openjpeg:
replace_in_file(self, cmake_configure, "if(JP2K_FOUND)", "if(0)")

## libwebp
replace_in_file(self, cmakelists, "if(NOT WEBP)", "if(0)")
if Version(self.version) < "1.83.0":
# versions below 1.83.0 do not have an option toggle
replace_in_file(self, cmakelists, "if(NOT WEBP)", "if(0)")
if Version(self.version) >= "1.79.0":
replace_in_file(self, cmakelists, "if(NOT WEBPMUX)", "if(0)")
if not self.options.with_webp:
replace_in_file(self, cmakelists_src, "if (WEBP_FOUND)", "if(0)")
replace_in_file(self, cmake_configure, "if (WEBP_FOUND)", "if(0)")
replace_in_file(self, cmakelists_src,
"if (WEBP_FOUND)",
"if (WEBP_FOUND)\n"
"target_link_directories(leptonica PRIVATE ${WEBP_LIBRARY_DIRS} ${WEBPMUX_LIBRARY_DIRS})\n"
"target_compile_definitions(leptonica PRIVATE ${WEBP_CFLAGS_OTHER} ${WEBPMUX_CFLAGS_OTHER})")
replace_in_file(self, cmakelists_src, "${WEBP_LIBRARIES}", "${WEBP_LIBRARIES} ${WEBPMUX_LIBRARIES}")
if Version(self.version) >= "1.79.0":
replace_in_file(self, cmakelists, "if(NOT WEBPMUX)", "if(0)")
if not self.options.with_webp:
replace_in_file(self, cmakelists_src, "if (WEBP_FOUND)", "if(0)")
replace_in_file(self, cmake_configure, "if (WEBP_FOUND)", "if(0)")

# Remove detection of fmemopen() on macOS < 10.13
# CheckFunctionExists will find it in the link library.
Expand Down
2 changes: 2 additions & 0 deletions recipes/leptonica/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"1.83.0":
folder: all
"1.82.0":
folder: all
"1.81.0":
Expand Down