[tesseract] Update and fix feature training-tools build (#29225)

Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
This commit is contained in:
autoantwort 2023-02-03 23:10:33 +01:00 committed by GitHub
parent a2f56c4dd6
commit ba588a0615
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 90 additions and 32 deletions

View File

@ -0,0 +1,33 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8c6845cb..27c1f4a2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -812,14 +812,8 @@ set_target_properties(libtesseract
set_target_properties(libtesseract
PROPERTIES SOVERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
-if(WIN32)
- set_target_properties(libtesseract
- PROPERTIES OUTPUT_NAME tesseract${VERSION_MAJOR}${VERSION_MINOR})
- set_target_properties(libtesseract
- PROPERTIES DEBUG_OUTPUT_NAME tesseract${VERSION_MAJOR}${VERSION_MINOR}d)
-else()
- set_target_properties(libtesseract PROPERTIES OUTPUT_NAME tesseract)
-endif()
+set_target_properties(libtesseract
+ PROPERTIES OUTPUT_NAME tesseract$<$<BOOL:${WIN32}>:${VERSION_MAJOR}${VERSION_MINOR}$<$<CONFIG:DEBUG>:d>>)
if(SW_BUILD)
target_link_libraries(libtesseract PUBLIC org.sw.demo.danbloomberg.leptonica
@@ -884,8 +878,10 @@ get_target_property(tesseract_NAME libtesseract NAME)
get_target_property(tesseract_VERSION libtesseract VERSION)
get_target_property(tesseract_OUTPUT_NAME libtesseract OUTPUT_NAME)
-configure_file(tesseract.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/tesseract.pc
+configure_file(tesseract.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/tesseract.pc.in
@ONLY)
+# to resolve generator expression in OUTPUT_NAME
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/tesseract.pc INPUT ${CMAKE_CURRENT_BINARY_DIR}/tesseract.pc.in)
configure_package_config_file(
cmake/templates/TesseractConfig.cmake.in

View File

@ -0,0 +1,31 @@
diff --git a/src/training/CMakeLists.txt b/src/training/CMakeLists.txt
index a05b216c..faab9bc2 100644
--- a/src/training/CMakeLists.txt
+++ b/src/training/CMakeLists.txt
@@ -259,13 +259,8 @@ if(ICU_FOUND)
target_link_libraries(unicharset_training
PUBLIC common_training org.sw.demo.unicode.icu.i18n)
else()
- if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
target_link_libraries(unicharset_training PUBLIC common_training
PkgConfig::ICU)
- else()
- target_link_libraries(unicharset_training PUBLIC common_training
- ${ICU_LIBRARIES})
- endif()
endif()
target_include_directories(unicharset_training
PUBLIC unicharset ${CMAKE_CURRENT_BINARY_DIR})
@@ -388,11 +383,7 @@ if(ICU_FOUND)
target_include_directories(pango_training BEFORE
PUBLIC ${PANGO_INCLUDE_DIRS})
target_compile_definitions(pango_training PUBLIC -DPANGO_ENABLE_ENGINE)
- if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
- target_link_libraries(pango_training PUBLIC PkgConfig::PANGO)
- else()
- target_link_libraries(pango_training PUBLIC ${PANGO_LINK_LIBRARIES})
- endif()
+ target_link_libraries(pango_training PUBLIC PkgConfig::PANGO)
endif()
endif()
target_include_directories(pango_training

View File

@ -5,42 +5,32 @@ endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO tesseract-ocr/tesseract
REF 5ad5325a0aa8effc47ca033625b6a51682f82767 #v5.2.0
SHA512 c6ed442c9deb28772aeb918142dab08d5b55eeeeccb0c1d3f13cf51bb72af227afb7f14c19a5c8db40d6a7b8cfeccb3af08a78adfcd7431e4a06f65372709ceb
PATCHES ${tesseract_patch}
REF 080da83cc51c4ef8b324a7e03146fe0bd7e0944b #5.3.0
SHA512 77f7e69ca220edb51f0d1e21fae67288759bbefb6868203cd095c4457b16d7319d78cd47dd8e72be3da5aabb357f5f649b8da7fc3f2263faedecf10f556eb431
PATCHES
${tesseract_patch}
fix-tools.patch # See https://github.com/tesseract-ocr/tesseract/pull/4006
fix-debug-postfix.patch # See https://github.com/tesseract-ocr/tesseract/pull/4008
)
# The built-in cmake FindICU is better
file(REMOVE "${SOURCE_PATH}/cmake/FindICU.cmake")
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC)
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
training-tools BUILD_TRAINING_TOOLS
)
if("cpu-independed" IN_LIST FEATURES)
set(TARGET_ARCHITECTURE none)
else()
set(TARGET_ARCHITECTURE auto)
endif()
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
-DSTATIC=${BUILD_STATIC}
-DUSE_SYSTEM_ICU=True
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=OFF
-DCMAKE_REQUIRE_FIND_PACKAGE_LibArchive=ON
-DCMAKE_REQUIRE_FIND_PACKAGE_CURL=ON
-DCMAKE_REQUIRE_FIND_PACKAGE_Leptonica=ON
-DCMAKE_DISABLE_FIND_PACKAGE_OpenCL=ON
-DLeptonica_DIR=YES
-DTARGET_ARCHITECTURE=${TARGET_ARCHITECTURE}
-DSW_BUILD=OFF
MAYBE_UNUSED_VARIABLES
CMAKE_DISABLE_FIND_PACKAGE_OpenCL
STATIC
TARGET_ARCHITECTURE
)
vcpkg_cmake_install()
@ -58,10 +48,6 @@ find_dependency(LibArchive)
)
vcpkg_copy_tools(TOOL_NAMES tesseract AUTO_CLEAN)
if(NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/tesseract.pc" "-ltesseract52" "-ltesseract52d")
endif()
vcpkg_fixup_pkgconfig()
if("training-tools" IN_LIST FEATURES)
@ -70,6 +56,7 @@ if("training-tools" IN_LIST FEATURES)
cntraining dawg2wordlist mftraining shapeclustering
wordlist2dawg combine_lang_model lstmeval lstmtraining
set_unicharset_properties unicharset_extractor text2image
merge_unicharsets
)
vcpkg_copy_tools(TOOL_NAMES ${TRAINING_TOOLS} AUTO_CLEAN)
endif()

View File

@ -1,15 +1,20 @@
{
"name": "tesseract",
"version": "5.2.0",
"port-version": 3,
"version": "5.3.0",
"description": "An OCR Engine that was developed at HP Labs between 1985 and 1995... and now at Google.",
"homepage": "https://github.com/tesseract-ocr/tesseract",
"license": "Apache-2.0",
"supports": "!uwp",
"dependencies": [
"curl",
{
"name": "curl",
"default-features": false
},
"leptonica",
"libarchive",
{
"name": "libarchive",
"default-features": false
},
{
"name": "vcpkg-cmake",
"host": true
@ -20,9 +25,6 @@
}
],
"features": {
"cpu-independed": {
"description": "build on any cpu extension commands support"
},
"training-tools": {
"description": "build training tools",
"dependencies": [

View File

@ -7573,8 +7573,8 @@
"port-version": 0
},
"tesseract": {
"baseline": "5.2.0",
"port-version": 3
"baseline": "5.3.0",
"port-version": 0
},
"tfhe": {
"baseline": "1.0.1",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "9536858220896569da2d0e66fa3f6a4b95621186",
"version": "5.3.0",
"port-version": 0
},
{
"git-tree": "106efd2adc79ebdcf63488c2cc930b035f01535d",
"version": "5.2.0",