From 685aaa339fc0a6c9fd1f9498bf707880ff7db6cd Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 5 Jul 2025 19:11:38 +0200 Subject: [PATCH 1/3] cmake: Fix linker warning (duplicate libraries) Linker warnings on macOS: [274/277] Linking CXX executable bin/lstmeval ld: warning: ignoring duplicate libraries: '-lpthread' [276/277] Linking CXX executable bin/lstmtraining ld: warning: ignoring duplicate libraries: '-lpthread' [277/277] Linking CXX executable bin/text2image Signed-off-by: Stefan Weil --- src/training/CMakeLists.txt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/training/CMakeLists.txt b/src/training/CMakeLists.txt index c764442070..f25e34825c 100644 --- a/src/training/CMakeLists.txt +++ b/src/training/CMakeLists.txt @@ -5,10 +5,6 @@ if(NOT ${CMAKE_VERSION} VERSION_LESS "3.12.0") cmake_policy(SET CMP0074 NEW) endif() -if(UNIX AND NOT ANDROID) - set(LIB_pthread pthread) -endif() - if(SW_BUILD) set(ICU_FOUND 1) else() # NOT SW_BUILD @@ -326,7 +322,7 @@ if(ICU_FOUND) # ############################################################################ add_executable(lstmeval lstmeval.cpp) - target_link_libraries(lstmeval unicharset_training ${LIB_pthread}) + target_link_libraries(lstmeval unicharset_training) project_group(lstmeval "Training Tools") install( TARGETS lstmeval @@ -342,7 +338,7 @@ if(ICU_FOUND) # ############################################################################ add_executable(lstmtraining lstmtraining.cpp) - target_link_libraries(lstmtraining unicharset_training ${LIB_pthread}) + target_link_libraries(lstmtraining unicharset_training) project_group(lstmtraining "Training Tools") install( TARGETS lstmtraining From 7865e225bd2bc9ec4eecb3a984cbbcc486a3da94 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 5 Jul 2025 19:14:16 +0200 Subject: [PATCH 2/3] cmake: Fix include statement for allheaders.h Leptonica include files are included without a leptonica/ prefix. Signed-off-by: Stefan Weil --- cmake/CheckFunctions.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CheckFunctions.cmake b/cmake/CheckFunctions.cmake index 4618eaeb43..a09eabb376 100644 --- a/cmake/CheckFunctions.cmake +++ b/cmake/CheckFunctions.cmake @@ -18,7 +18,7 @@ function(check_leptonica_tiff_support) # check if leptonica was build with tiff support set result to # LEPT_TIFF_RESULT set(TIFF_TEST - "#include \"leptonica/allheaders.h\"\n" + "#include \"allheaders.h\"\n" "int main() {\n" " l_uint8 *data = NULL;\n" " size_t size = 0;\n" From 3483d3a663b5902f97586cfa8c76c396993d622b Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 5 Jul 2025 19:17:28 +0200 Subject: [PATCH 3/3] cmake: Set required PKG_CONFIG_PATH for builds with Homebrew on macOS Signed-off-by: Stefan Weil --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6727af290b..566cc065ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -399,6 +399,13 @@ if(SW_BUILD) sw_execute() else() find_package(PkgConfig) + if(APPLE) + if(DEFINED ENV{HOMEBREW_PREFIX}) + set(HOMEBREW_PREFIX $ENV{HOMEBREW_PREFIX}) + set(PKG_CONFIG_PATH "${HOMEBREW_PREFIX}/opt/icu4c/lib/pkgconfig:${HOMEBREW_PREFIX}/opt/libarchive/lib/pkgconfig") + set(ENV{PKG_CONFIG_PATH} "${PKG_CONFIG_PATH}") + endif() + endif() # Check for required library. option -DLeptonica_DIR=path => cmake hint where # to find leptonica find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} CONFIG)