[leptonica] Update to 1.82.0 and fix link 'openjp2.lib' failed (#23624)

* [leptonica] Fix find openjpeg

* update version

* update patch

* update version

* format portfile.cmake

* update version

* update patch

* update version

* format portfile.cmake

* update version

* update to 1.82.0

* update version

* update patches

* update version

* update patches

* update version

* Revise patching and configuration

* Update versions

* update patch

* update version

* update version

* update patch

* update version

Co-authored-by: Lily Wang <v-lilywang@microsoft.com>
Co-authored-by: Kai Pastor <dg0yt@darc.de>
This commit is contained in:
LilyWangLL 2022-03-28 11:33:04 -07:00 committed by GitHub
parent 9ff4659a07
commit 821d0d20d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 83 additions and 96 deletions

View File

@ -1,20 +0,0 @@
diff --git a/cmake/templates/LeptonicaConfig.cmake.in b/cmake/templates/LeptonicaConfig.cmake.in
index 342c37d..b358b7b 100644
--- a/cmake/templates/LeptonicaConfig.cmake.in
+++ b/cmake/templates/LeptonicaConfig.cmake.in
@@ -20,6 +20,15 @@
#
# ===================================================================================
+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)
# ======================================================

View File

@ -0,0 +1,64 @@
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

@ -1,39 +0,0 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,20 +58,19 @@ if(UNIX)
endif()
if(NOT SW_BUILD)
- find_package(GIF)
- find_package(JPEG)
- find_package(PNG)
- find_package(TIFF)
- find_package(ZLIB)
+ find_package(GIF REQUIRED)
+ find_package(JPEG REQUIRED)
+ find_package(PNG REQUIRED)
+ find_package(TIFF REQUIRED)
+ find_package(ZLIB REQUIRED)
find_package(PkgConfig)
+ find_package(OpenJPEG REQUIRED)
if (PKG_CONFIG_FOUND)
pkg_check_modules(WEBP libwebp QUIET)
pkg_check_modules(WEBPMUX libwebpmux>=${MINIMUM_WEBPMUX_VERSION} QUIET)
- pkg_check_modules(JP2K libopenjp2>=2.0 QUIET)
endif()
if(NOT WEBP)
- find_path(WEBP_INCLUDE_DIR /webp/decode.h)
- find_library(WEBP_LIBRARY NAMES webp)
+ find_package(WebP CONFIG REQUIRED)
if (WEBP_INCLUDE_DIR AND WEBP_LIBRARY)
set(WEBP 1)
set(WEBP_FOUND TRUE)
@@ -213,7 +212,7 @@ include(Configure)
configure_file(${AUTOCONFIG_SRC} ${AUTOCONFIG} @ONLY)
-set(INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include" "${CMAKE_INSTALL_PREFIX}/include/leptonica")
+set(INCLUDE_DIR "\${CMAKE_CURRENT_LIST_DIR}/../../include" "\${CMAKE_CURRENT_LIST_DIR}/../../include/leptonica")
###############################################################################
#

View File

@ -1,19 +0,0 @@
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -14,7 +14,6 @@ if (MSVC)
set_source_files_properties(${src} PROPERTIES LANGUAGE CXX)
endif()
-string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
add_library (leptonica ${src} ${hdr})
set_target_properties (leptonica PROPERTIES VERSION ${VERSION_PLAIN})
@@ -52,7 +52,7 @@ if (TIFF_LIBRARIES)
endif()
if (WEBP_FOUND)
target_include_directories (leptonica PUBLIC ${WEBP_INCLUDE_DIRS})
- target_link_libraries (leptonica ${WEBP_LIBRARIES})
+ target_link_libraries (leptonica WebP::webp WebP::libwebpmux)
endif()
if (ZLIB_LIBRARIES)
target_include_directories (leptonica PUBLIC ${ZLIB_INCLUDE_DIRS})

View File

@ -1,33 +1,29 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO DanBloomberg/leptonica
REF 2ff4313a85427ceb272540c570106b2f893da097 # 1.81.1
SHA512 0e35538f1407e7220e68d635e5fd4c82219b58fb4b6ca8132d72892f52853e13451a2a160644a122c47598f77d2e87046cfb072be261be9a941342f476dc6376
REF f4138265b390f1921b9891d6669674d3157887d8 # 1.82.0
SHA512 cd8c55454fc2cb4d23c2b3f01870e154766fa5a35c07b79d25c2d85dc2675dcb224d9be8a1cdcb7e9a0bd3c17e90141aa4084f67a311a1c327d7ac2439ba196a
HEAD_REF master
PATCHES
fix-cmakelists.patch
fix-src-cmakelists.patch
find-dependency.patch
fix-CMakeDependency.patch
)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" STATIC)
vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DSW_BUILD=OFF
-DCPPAN_BUILD=OFF
-DSTATIC=${STATIC}
-DCMAKE_REQUIRED_INCLUDES=${CURRENT_INSTALLED_DIR}/include # for check_include_file()
MAYBE_UNUSED_VARIABLES
STATIC
-DCMAKE_REQUIRE_FIND_PACKAGE_GIF=TRUE
-DCMAKE_REQUIRE_FIND_PACKAGE_JPEG=TRUE
-DCMAKE_REQUIRE_FIND_PACKAGE_PNG=TRUE
-DCMAKE_REQUIRE_FIND_PACKAGE_TIFF=TRUE
-DCMAKE_REQUIRE_FIND_PACKAGE_ZLIB=TRUE
)
vcpkg_cmake_install()
vcpkg_fixup_pkgconfig()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/leptonica)
vcpkg_copy_pdbs()

View File

@ -1,9 +1,9 @@
{
"name": "leptonica",
"version": "1.81.1",
"port-version": 1,
"version": "1.82.0",
"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,
"dependencies": [
"giflib",
"libjpeg-turbo",

View File

@ -3333,8 +3333,8 @@
"port-version": 1
},
"leptonica": {
"baseline": "1.81.1",
"port-version": 1
"baseline": "1.82.0",
"port-version": 0
},
"lerc": {
"baseline": "2.2",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "d69fc1cdb4cfb42aa1b6e608418f313fbbb3f9ab",
"version": "1.82.0",
"port-version": 0
},
{
"git-tree": "677775654e1914afaf5791361e9de3fac4762edc",
"version": "1.81.1",