[libmupdf] add ocr feature (#32084)

* add libmupdf ocr feature WIP

* Fix compile defs

* Fix ocr feature

* Add version

* increment libmupdf port version

* add libmupdf version

* revert version change
This commit is contained in:
simon987 2023-07-05 14:54:06 -04:00 committed by GitHub
parent dad2e6f2aa
commit d06a922845
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 53 additions and 4 deletions

View File

@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.9)
project(libmupdf C)
project(libmupdf)
option(ENABLE_OCR "Build with OCR" OFF)
set(CMAKE_DEBUG_POSTFIX d)
@ -25,11 +27,20 @@ find_package(ZLIB REQUIRED)
find_package(OpenJPEG CONFIG REQUIRED)
find_library(JBIG2DEC_LIB NAMES jbig2decd jbig2dec)
file(GLOB_RECURSE SOURCES "source/*.c" "generated/*.c")
if (ENABLE_OCR)
find_package(Leptonica CONFIG REQUIRED)
find_package(Tesseract CONFIG REQUIRED)
endif()
file(GLOB_RECURSE SOURCES "source/*.c" "generated/*.c" "source/*.h")
list(FILTER SOURCES EXCLUDE REGEX "source/tools/[a-z]*\\.c$")
list(FILTER SOURCES EXCLUDE REGEX "source/tests/.*.c$")
list(FILTER SOURCES EXCLUDE REGEX "source/fitz/output-docx.c")
if (ENABLE_OCR)
list(APPEND SOURCES "source/fitz/tessocr.cpp")
endif()
add_library(libmupdf ${SOURCES})
if(WIN32)
@ -37,6 +48,14 @@ if(WIN32)
else()
target_compile_definitions(libmupdf PRIVATE -DHAVE_PTHREAD=1 -DSHARE_JPEG -DFZ_ENABLE_JS=0 -DFZ_ENABLE_ICC=0 -DMEMENTO_MUPDF_HACKS -DFZ_ENABLE_DOCX_OUTPUT=0 -DFZ_ENABLE_ODT_OUTPUT=0)
endif()
if (ENABLE_OCR)
target_compile_definitions(libmupdf PRIVATE -DHAVE_TESSERACT=1 -DHAVE_LEPTONICA=1)
else()
target_compile_definitions(libmupdf PRIVATE -DOCR_DISABLED=1)
endif()
target_include_directories(libmupdf
PUBLIC
include
@ -45,6 +64,14 @@ target_include_directories(libmupdf
${JPEG_INCLUDE_DIR}
${HARFBUZZ_INCLUDE}
)
if (ENABLE_OCR)
target_include_directories(libmupdf
PRIVATE
${Leptonica_INCLUDE_DIRS}
)
endif()
target_link_libraries(libmupdf PRIVATE
openjp2
freetype

View File

@ -12,11 +12,18 @@ vcpkg_from_github(
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
vcpkg_check_features(
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
ocr ENABLE_OCR
)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
DISABLE_PARALLEL_CONFIGURE
OPTIONS
-DBUILD_EXAMPLES=OFF
${FEATURE_OPTIONS}
)
vcpkg_cmake_install()

View File

@ -1,6 +1,7 @@
{
"name": "libmupdf",
"version": "1.22.1",
"port-version": 1,
"description": "a lightweight PDF, XPS, and E-book library",
"homepage": "https://github.com/ArtifexSoftware/mupdf",
"license": "AGPL-3.0-only",
@ -19,5 +20,14 @@
"host": true
},
"zlib"
]
],
"features": {
"ocr": {
"description": "Enable OCR support",
"dependencies": [
"leptonica",
"tesseract"
]
}
}
}

View File

@ -4330,7 +4330,7 @@
},
"libmupdf": {
"baseline": "1.22.1",
"port-version": 0
"port-version": 1
},
"libmysql": {
"baseline": "8.0.32",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "06c0e6bccfaf2ab9f729bfc79318da68cb4897dc",
"version": "1.22.1",
"port-version": 1
},
{
"git-tree": "c1684ff15eed2c86ba792de4e92d21b2ea58c188",
"version": "1.22.1",