[leptonica] Update (#29266)

This commit is contained in:
autoantwort 2023-02-01 03:04:06 +01:00 committed by GitHub
parent b63f61ebe8
commit ddea2bb30b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 305 additions and 71 deletions

View File

@ -1,64 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6d300da..fae4ca7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,8 +66,28 @@ if(NOT SW_BUILD)
find_package(PNG)
find_package(TIFF)
find_package(ZLIB)
- find_package(PkgConfig)
- if (PKG_CONFIG_FOUND)
+ find_package(WEBP NAMES WebP REQUIRED)
+ find_package(JP2K NAMES OpenJPEG REQUIRED)
+
+ set(GIF_LIBRARIES GIF::GIF)
+ set(JPEG_LIBRARIES JPEG::JPEG)
+ set(PNG_LIBRARIES PNG::PNG)
+ set(TIFF_LIBRARIES TIFF::TIFF)
+ set(ZLIB_LIBRARIES ZLIB::ZLIB)
+
+ set(JP2K "${JP2K_FOUND}")
+ set(JP2K_INCLUDE_DIRS "")
+ set(HAVE_LIBJP2K 1)
+ set(JP2K_LIBRARIES openjp2) # imported target
+
+ set(WEBP "${WEBP_FOUND}")
+ set(WEBP_INCLUDE_DIRS "")
+ set(WEBPMUX 1)
+ set(HAVE_LIBWEBP_ANIM 1)
+ set(WEBPMUX_FOUND TRUE)
+ set(WEBP_LIBRARIES WebP::libwebpmux WebP::webp)
+
+ if (0)
pkg_check_modules(WEBP libwebp QUIET)
pkg_check_modules(WEBPMUX libwebpmux>=${MINIMUM_WEBPMUX_VERSION} QUIET)
pkg_check_modules(JP2K libopenjp2>=2.0 QUIET)
diff --git a/cmake/templates/LeptonicaConfig.cmake.in b/cmake/templates/LeptonicaConfig.cmake.in
index 342c37d..506fb2a 100644
--- a/cmake/templates/LeptonicaConfig.cmake.in
+++ b/cmake/templates/LeptonicaConfig.cmake.in
@@ -19,6 +19,14 @@
# - Leptonica_VERSION_PATCH : Patch version part of Leptonica_VERSION: "@VERSION_PATCH@"
#
# ===================================================================================
+include(CMakeFindDependencyMacro)
+find_dependency(JPEG)
+find_dependency(ZLIB)
+find_dependency(PNG)
+find_dependency(TIFF)
+find_dependency(GIF)
+find_dependency(WebP)
+find_dependency(OpenJPEG)
include(${CMAKE_CURRENT_LIST_DIR}/LeptonicaTargets.cmake)
@@ -36,7 +44,8 @@ SET(Leptonica_VERSION_PATCH @VERSION_PATCH@)
# ======================================================
# Provide the include directories to the caller
-set(Leptonica_INCLUDE_DIRS "@INCLUDE_DIR@")
+get_filename_component(Leptonica_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/../../include" ABSOLUTE)
+list(APPEND Leptonica_INCLUDE_DIRS "${Leptonica_INCLUDE_DIRS}/leptonica")
# ====================================================================
# Link libraries:

View File

@ -0,0 +1,147 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3e09f53..61ce7b4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -70,19 +70,19 @@ if(NOT SW_BUILD)
endif()
find_package(JPEG)
if(JPEG_FOUND)
- set(libs_private "${libs_private} -ljpeg")
+ set(pkgs_private "${pkgs_private} libjpeg")
endif()
find_package(PNG)
if(PNG_FOUND)
- set(libs_private "${libs_private} -lpng")
+ set(pkgs_private "${pkgs_private} libpng")
endif()
find_package(TIFF)
if(TIFF_FOUND)
- set(libs_private "${libs_private} -ltiff")
+ set(pkgs_private "${pkgs_private} libtiff-4")
endif()
find_package(ZLIB)
if(ZLIB_FOUND)
- set(libs_private "${libs_private} -lz")
+ set(pkgs_private "${pkgs_private} zlib")
endif()
find_package(PkgConfig QUIET)
if(LIBWEBP_SUPPORT)
@@ -118,30 +118,16 @@ if(NOT SW_BUILD)
endif()
endif()
if(WEBP)
- set(libs_private "${libs_private} -lwebp")
+ set(pkgs_private "${pkgs_private} libwebp")
endif(WEBP)
if(WEBPMUX)
- set(libs_private "${libs_private} -lwebpmux")
+ set(pkgs_private "${pkgs_private} libwebpmux")
endif(WEBPMUX)
endif(LIBWEBP_SUPPORT)
if(OPENJPEG_SUPPORT)
- find_package(OpenJPEG)
- # we need absolute path in some cases on Windows
- find_library(JP2K_LIBRARY NAMES openjp2)
- if(OpenJPEG_FOUND AND JP2K_LIBRARY)
- set(JP2K_FOUND TRUE)
- set(JP2K_INCLUDE_DIRS ${OPENJPEG_INCLUDE_DIRS})
- get_filename_component(JP2K_HEADER_DIR "${JP2K_INCLUDE_DIRS}" NAME)
- else()
- if(PKG_CONFIG_FOUND)
- pkg_check_modules(JP2K libopenjp2>=2.0 QUIET)
- endif(PKG_CONFIG_FOUND)
- endif()
- if(JP2K_FOUND)
- set(JP2K_LIBRARIES ${JP2K_LIBRARY})
- set(libs_private "${libs_private} -lopenjp2")
- message(STATUS "FOUND OpenJPEG: ${JP2K_LIBRARIES}")
- endif()
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(JP2K libopenjp2>=2.0 REQUIRED)
+ set(pkgs_private "${pkgs_private} libopenjp2")
endif(OPENJPEG_SUPPORT)
else() # SW_BUILD=ON
find_package(SW REQUIRED)
@@ -158,8 +144,7 @@ else() # SW_BUILD=ON
-DHAVE_LIBWEBP=1
-DHAVE_LIBWEBP_ANIM=1
-DHAVE_LIBZ=1
- -DHAVE_LIBJP2K=1
- -DLIBJP2K_HEADER="openjpeg.h")
+ -DHAVE_LIBJP2K=1)
endif()
set(libs_private "${libs_private} -lm")
@@ -299,7 +284,10 @@ get_target_property(leptonica_NAME leptonica NAME)
set(leptonica_VERSION ${VERSION_PLAIN})
get_target_property(leptonica_OUTPUT_NAME leptonica OUTPUT_NAME)
-configure_file(lept.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/lept.pc @ONLY)
+configure_file(lept.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/lept.pc.in @ONLY)
+# to resolve generator expression in OUTPUT_NAME
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lept.pc INPUT ${CMAKE_CURRENT_BINARY_DIR}/lept.pc.in)
+
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/LeptonicaConfig-version.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/LeptonicaConfig-version.cmake @ONLY)
diff --git a/cmake/Configure.cmake b/cmake/Configure.cmake
index b75cf19..4941187 100644
--- a/cmake/Configure.cmake
+++ b/cmake/Configure.cmake
@@ -96,7 +96,6 @@ endif()
if (JP2K_FOUND)
set(HAVE_LIBJP2K 1)
- set(LIBJP2K_HEADER <${JP2K_HEADER_DIR}/openjpeg.h>)
endif()
if (PNG_FOUND)
@@ -122,7 +121,6 @@ file(APPEND ${AUTOCONFIG_SRC} "
/* Define to 1 if you have libopenjp2. */
#cmakedefine HAVE_LIBJP2K 1
-#cmakedefine LIBJP2K_HEADER <${JP2K_HEADER_DIR}/openjpeg.h>
/* Define to 1 if you have jpeg. */
#cmakedefine HAVE_LIBJPEG 1
diff --git a/lept.pc.cmake b/lept.pc.cmake
index 9140d50..3e19307 100644
--- a/lept.pc.cmake
+++ b/lept.pc.cmake
@@ -6,6 +6,7 @@ includedir=${prefix}/include
Name: @leptonica_NAME@
Description: An open source C library for efficient image processing and image analysis operations
Version: @leptonica_VERSION@
+Requires.private: @pkgs_private@
Libs: -L${libdir} -l@leptonica_OUTPUT_NAME@
Libs.private: @libs_private@
Cflags: -I${includedir} -I${includedir}/leptonica
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e2c2f15..3d7e852 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -19,13 +19,8 @@ string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
add_library (leptonica ${src} ${hdr})
set_target_properties (leptonica PROPERTIES VERSION 6.0.0)
set_target_properties (leptonica PROPERTIES SOVERSION 6)
-if (WIN32)
-set_target_properties (leptonica PROPERTIES OUTPUT_NAME leptonica-${VERSION_PLAIN})
-set_target_properties (leptonica PROPERTIES DEBUG_OUTPUT_NAME leptonica-${VERSION_PLAIN}d)
-else()
-set_target_properties (leptonica PROPERTIES OUTPUT_NAME leptonica)
-set_target_properties (leptonica PROPERTIES DEBUG_OUTPUT_NAME leptonica)
-endif()
+
+set_target_properties (leptonica PROPERTIES OUTPUT_NAME leptonica$<$<BOOL:${WIN32}>:-${VERSION_PLAIN}$<$<CONFIG:DEBUG>:d>>)
if (BUILD_SHARED_LIBS)
target_compile_definitions (leptonica PRIVATE -DLIBLEPT_EXPORTS)
@@ -41,7 +36,7 @@ if (JPEG_LIBRARIES)
endif()
if (JP2K_FOUND)
target_include_directories (leptonica PUBLIC ${JP2K_INCLUDE_DIRS})
- target_link_libraries (leptonica ${JP2K_LIBRARIES})
+ target_link_libraries (leptonica ${JP2K_LINK_LIBRARIES})
endif()
if (PNG_LIBRARIES)
target_include_directories (leptonica PUBLIC ${PNG_INCLUDE_DIRS})

View File

@ -1,17 +1,22 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO DanBloomberg/leptonica
REF f4138265b390f1921b9891d6669674d3157887d8 # 1.82.0
SHA512 cd8c55454fc2cb4d23c2b3f01870e154766fa5a35c07b79d25c2d85dc2675dcb224d9be8a1cdcb7e9a0bd3c17e90141aa4084f67a311a1c327d7ac2439ba196a
REF b667978e86c4bf74f7fdd75f833127d2de327550 # 1.83.1
SHA512 fe4ea74aea024a4e522a5f985e51c5b110b5b4a3b3086e6fa7204129caf09b842f85041c386ee9bf2e878034ac2ebd2506396063771b677e931296ec6d76490b
HEAD_REF master
PATCHES
fix-CMakeDependency.patch
fix-build-and-pkgconfig.patch # See https://github.com/DanBloomberg/leptonica/pull/664 and https://github.com/DanBloomberg/leptonica/pull/662
private.patch # See https://github.com/DanBloomberg/leptonica/pull/666
webp.patch # See https://github.com/DanBloomberg/leptonica/pull/667
)
vcpkg_find_acquire_program(PKGCONFIG)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DSW_BUILD=OFF
-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}
-DCMAKE_REQUIRE_FIND_PACKAGE_GIF=TRUE
-DCMAKE_REQUIRE_FIND_PACKAGE_JPEG=TRUE
-DCMAKE_REQUIRE_FIND_PACKAGE_PNG=TRUE

View File

@ -0,0 +1,65 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3d7e852..1fab56c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -27,36 +27,36 @@ if (BUILD_SHARED_LIBS)
endif()
if (GIF_LIBRARIES)
- target_include_directories (leptonica PUBLIC ${GIF_INCLUDE_DIR})
- target_link_libraries (leptonica ${GIF_LIBRARIES})
+ target_include_directories (leptonica PRIVATE ${GIF_INCLUDE_DIR})
+ target_link_libraries (leptonica PRIVATE ${GIF_LIBRARIES})
endif()
if (JPEG_LIBRARIES)
- target_include_directories (leptonica PUBLIC ${JPEG_INCLUDE_DIR})
- target_link_libraries (leptonica ${JPEG_LIBRARIES})
+ target_include_directories (leptonica PRIVATE ${JPEG_INCLUDE_DIR})
+ target_link_libraries (leptonica PRIVATE ${JPEG_LIBRARIES})
endif()
if (JP2K_FOUND)
- target_include_directories (leptonica PUBLIC ${JP2K_INCLUDE_DIRS})
- target_link_libraries (leptonica ${JP2K_LINK_LIBRARIES})
+ target_include_directories (leptonica PRIVATE ${JP2K_INCLUDE_DIRS})
+ target_link_libraries (leptonica PRIVATE ${JP2K_LINK_LIBRARIES})
endif()
if (PNG_LIBRARIES)
- target_include_directories (leptonica PUBLIC ${PNG_INCLUDE_DIRS})
- target_link_libraries (leptonica ${PNG_LIBRARIES})
+ target_include_directories (leptonica PRIVATE ${PNG_INCLUDE_DIRS})
+ target_link_libraries (leptonica PRIVATE ${PNG_LIBRARIES})
endif()
if (TIFF_LIBRARIES)
- target_include_directories (leptonica PUBLIC ${TIFF_INCLUDE_DIR})
- target_link_libraries (leptonica ${TIFF_LIBRARIES})
+ target_include_directories (leptonica PRIVATE ${TIFF_INCLUDE_DIR})
+ target_link_libraries (leptonica PRIVATE ${TIFF_LIBRARIES})
endif()
if (WEBP_FOUND)
- target_include_directories (leptonica PUBLIC ${WEBP_INCLUDE_DIRS})
- target_link_libraries (leptonica ${WEBP_LIBRARIES})
+ target_include_directories (leptonica PRIVATE ${WEBP_INCLUDE_DIRS})
+ target_link_libraries (leptonica PRIVATE ${WEBP_LIBRARIES})
endif()
if (ZLIB_LIBRARIES)
- target_include_directories (leptonica PUBLIC ${ZLIB_INCLUDE_DIRS})
- target_link_libraries (leptonica ${ZLIB_LIBRARIES})
+ target_include_directories (leptonica PRIVATE ${ZLIB_INCLUDE_DIRS})
+ target_link_libraries (leptonica PRIVATE ${ZLIB_LIBRARIES})
endif()
if (UNIX)
- target_link_libraries (leptonica m)
+ target_link_libraries (leptonica PRIVATE m)
set(lib ${CMAKE_SHARED_LIBRARY_PREFIX})
set(dll ${CMAKE_SHARED_LIBRARY_SUFFIX})
set(old_target ${lib}lept${dll})
@@ -72,7 +72,7 @@ endif()
if (NOT SW_BUILD)
export(TARGETS leptonica FILE ${CMAKE_BINARY_DIR}/LeptonicaTargets.cmake)
else()
- target_link_libraries (leptonica
+ target_link_libraries (leptonica PRIVATE
org.sw.demo.gif
org.sw.demo.jpeg
org.sw.demo.glennrp.png

View File

@ -1,6 +1,6 @@
{
"name": "leptonica",
"version": "1.82.0",
"version": "1.83.1",
"description": "An open source library containing software that is broadly useful for image processing and image analysis applications",
"homepage": "https://github.com/DanBloomberg/leptonica",
"license": null,
@ -8,9 +8,15 @@
"giflib",
"libjpeg-turbo",
"libpng",
"libwebp",
{
"name": "libwebp",
"default-features": false
},
"openjpeg",
"tiff",
{
"name": "tiff",
"default-features": false
},
{
"name": "vcpkg-cmake",
"host": true

View File

@ -0,0 +1,70 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7330046..464e0fe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -84,45 +84,12 @@ if(NOT SW_BUILD)
if(ZLIB_FOUND)
set(pkgs_private "${pkgs_private} zlib")
endif()
- find_package(PkgConfig QUIET)
if(LIBWEBP_SUPPORT)
- if(PKG_CONFIG_FOUND)
- pkg_check_modules(WEBP libwebp QUIET)
- pkg_check_modules(WEBPMUX libwebpmux>=${MINIMUM_WEBPMUX_VERSION} QUIET)
- endif(PKG_CONFIG_FOUND)
- if(NOT WEBP)
- find_path(WEBP_INCLUDE_DIR /webp/decode.h)
- find_library(WEBP_LIBRARY NAMES webp)
- if(WEBP_INCLUDE_DIR AND WEBP_LIBRARY)
- set(WEBP 1)
- set(WEBP_FOUND TRUE)
- set(WEBP_LIBRARIES ${WEBP_LIBRARY})
- set(WEBP_INCLUDE_DIRS ${WEBP_INCLUDE_DIR})
- endif()
- endif()
- if(NOT WEBPMUX)
- find_path(WEBPMUX_INCLUDE_DIR /webp/mux.h)
- # TODO: check minimal required version
- if(NOT WEBPMUX_INCLUDE_DIR)
- message(STATUS "Can not find: /webp/mux.h")
- endif()
- if(NOT "${WEBPMUX_INCLUDE_DIR}" STREQUAL "${WEBP_INCLUDE_DIR}")
- set(WEBP_INCLUDE_DIRS ${WEBP_INCLUDE_DIRS} ${WEBPMUX_INCLUDE_DIR})
- endif()
- find_library(WEBPMUX_LIBRARY NAMES webpmux)
- if(WEBPMUX_INCLUDE_DIR AND WEBPMUX_LIBRARY)
- set(WEBPMUX 1)
- set(HAVE_LIBWEBP_ANIM 1)
- set(WEBPMUX_FOUND TRUE)
- set(WEBP_LIBRARIES ${WEBP_LIBRARIES} ${WEBPMUX_LIBRARY})
- endif()
- endif()
- if(WEBP)
- set(pkgs_private "${pkgs_private} libwebp")
- endif(WEBP)
- if(WEBPMUX)
- set(pkgs_private "${pkgs_private} libwebpmux")
- endif(WEBPMUX)
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(WEBP libwebp REQUIRED)
+ pkg_check_modules(WEBPMUX libwebpmux>=${MINIMUM_WEBPMUX_VERSION} REQUIRED)
+ set(pkgs_private "${pkgs_private} libwebp")
+ set(pkgs_private "${pkgs_private} libwebpmux")
endif(LIBWEBP_SUPPORT)
if(OPENJPEG_SUPPORT)
find_package(PkgConfig REQUIRED)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1fab56c..790ca2a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -48,7 +48,9 @@ if (TIFF_LIBRARIES)
endif()
if (WEBP_FOUND)
target_include_directories (leptonica PRIVATE ${WEBP_INCLUDE_DIRS})
- target_link_libraries (leptonica PRIVATE ${WEBP_LIBRARIES})
+ target_link_libraries (leptonica PRIVATE ${WEBP_LINK_LIBRARIES})
+ target_include_directories (leptonica PRIVATE ${WEBPMUX_INCLUDE_DIRS})
+ target_link_libraries (leptonica PRIVATE ${WEBPMUX_LINK_LIBRARIES})
endif()
if (ZLIB_LIBRARIES)
target_include_directories (leptonica PRIVATE ${ZLIB_INCLUDE_DIRS})

View File

@ -3605,7 +3605,7 @@
"port-version": 0
},
"leptonica": {
"baseline": "1.82.0",
"baseline": "1.83.1",
"port-version": 0
},
"lerc": {

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "90d009f9febb130cbecc48c89cdc309563f85621",
"version": "1.83.1",
"port-version": 0
},
{
"git-tree": "d69fc1cdb4cfb42aa1b6e608418f313fbbb3f9ab",
"version": "1.82.0",