From 14865b5c4521502ab1049bd00d19cdeff986a719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=86=E2=9C=A0Sa=CD=A5b=CD=A3e=CD=ABr=F0=9F=91=91?= =?UTF-8?q?=E2=B0=80?= Date: Thu, 16 Oct 2025 08:21:14 +0800 Subject: [PATCH 1/3] cmake: update tesseract & lept no longer need to specify `-DUNIX_LINK_TESSERACT:BOOL=true` when invocking cmake --- SerialPrograms/CMakeLists.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index 8b6c4d982a..050cfb9d4c 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -445,16 +445,16 @@ else() # macOS and Linux #we hope to use our own Tesseract build in future so we can rid that dependency #but right now to run on Linux and Mac we need to use external Tesseract library - if (UNIX_LINK_TESSERACT) + pkg_search_module(TESSERACT REQUIRED tesseract) + pkg_search_module(LEPTONICA REQUIRED lept) + if (TESSERACT_FOUND AND LEPTONICA_FOUND) target_compile_definitions(SerialProgramsLib PRIVATE PA_TESSERACT UNIX_LINK_TESSERACT) - pkg_search_module(TESSERACT REQUIRED tesseract) - pkg_search_module(LEPTONICA REQUIRED lept) - include_directories(${TESSERACT_INCLUDE_DIRS}) - include_directories(${LEPTONICA_INCLUDE_DIRS}) - link_directories(${TESSERACT_LIBRARY_DIRS}) - link_directories(${LEPTONICA_LIBRARY_DIRS}) - target_link_libraries(SerialProgramsLib PRIVATE ${TESSERACT_LINK_LIBRARIES}) - target_link_libraries(SerialProgramsLib PRIVATE ${LEPTONICA_LINK_LIBRARIES}) + target_include_directories(SerialProgramsLib SYSTEM PRIVATE ${TESSERACT_INCLUDE_DIRS}) + target_include_directories(SerialProgramsLib SYSTEM PRIVATE ${LEPTONICA_INCLUDE_DIRS}) + target_link_directories(SerialProgramsLib PUBLIC ${TESSERACT_LIBRARY_DIRS}) + target_link_directories(SerialProgramsLib PUBLIC ${LEPTONICA_LIBRARY_DIRS}) + target_link_libraries(SerialProgramsLib PUBLIC ${TESSERACT_LINK_LIBRARIES}) + target_link_libraries(SerialProgramsLib PUBLIC ${LEPTONICA_LINK_LIBRARIES}) endif() pkg_search_module(DPP dpp=10.0.22) From 20af7ef3e84c367fe578c7362f023f1703943456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=86=E2=9C=A0Sa=CD=A5b=CD=A3e=CD=ABr=F0=9F=91=91?= =?UTF-8?q?=E2=B0=80?= Date: Sun, 5 Oct 2025 20:33:35 +0800 Subject: [PATCH 2/3] cmake: tidy up opencv for macOS/Linux --- SerialPrograms/CMakeLists.txt | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index 050cfb9d4c..fe658e9395 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -352,12 +352,6 @@ else() # macOS and Linux target_link_directories(SerialProgramsLib PUBLIC ${ONNXRUNTIME_LIBRARY_DIRS}) target_link_libraries(SerialProgramsLib PUBLIC ${ONNXRUNTIME_LINK_LIBRARIES}) endif() - # Find OpenCV - if(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm64)|(ARM64)") - find_package(OpenCV REQUIRED HINTS "/opt/homebrew/opt/opencv/lib/cmake/opencv4/") - else() - find_package(OpenCV REQUIRED HINTS "/usr/local/opt/opencv/lib/cmake/opencv4/") - endif() else() # Linux # ONNX RUNTIME LINUX CONFIG # NOTE: users can specify their own ONNX_ROOT_PATH (this is the base folder for ONNX) on the command line when evoking cmake. @@ -435,13 +429,13 @@ else() # macOS and Linux else() message(FATAL_ERROR "Could not find ONNX Runtime headers or library.") endif() - # Find OpenCV - find_package(OpenCV REQUIRED HINTS "/usr/local/opt/opencv/lib/cmake/opencv4/") endif() # end Linux - include_directories(${OpenCV_INCLUDE_DIRS}) - link_directories(${OpenCV_LIBRARY_DIRS}) - target_link_libraries(SerialProgramsLib PRIVATE ${OpenCV_LIBS}) + # Find OpenCV + pkg_search_module(OpenCV REQUIRED opencv4 opencv) + target_include_directories(SerialProgramsLib SYSTEM PRIVATE ${OpenCV_INCLUDE_DIRS}) # "SYSTEM" to suppress warnings + target_link_directories(SerialProgramsLib PUBLIC ${OpenCV_LIBRARY_DIRS}) + target_link_libraries(SerialProgramsLib PUBLIC ${OpenCV_LINK_LIBRARIES}) #we hope to use our own Tesseract build in future so we can rid that dependency #but right now to run on Linux and Mac we need to use external Tesseract library @@ -468,10 +462,6 @@ else() # macOS and Linux endif() if (APPLE) - # Add -Wno-c11-extensions to avoid clang gives - # /usr/local/Cellar/opencv/4.5.5_3/include/opencv4/opencv2/core/mat.inl.hpp:2116:9: error: '_Atomic' is a C11 extension - # when compiling OpenCV - # target_compile_options(SerialProgramsLib PRIVATE -Wall -Wextra -Wpedantic -Werror -Wno-c11-extensions) target_compile_options(SerialProgramsLib PRIVATE -Wall -Wextra -Wpedantic -Werror -Wshorten-64-to-32) # on macOS, need this framework to query OS API to control display sleep and system sleep behavior target_link_libraries(SerialProgramsLib PRIVATE "-framework IOKit -framework CoreFoundation") From 7780141b1355d01153917d6139c0753011cc0ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=86=E2=9C=A0Sa=CD=A5b=CD=A3e=CD=ABr=F0=9F=91=91?= =?UTF-8?q?=E2=B0=80?= Date: Tue, 28 Oct 2025 11:48:40 +0800 Subject: [PATCH 3/3] cmake: unmark tesseract&lept as required --- SerialPrograms/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SerialPrograms/CMakeLists.txt b/SerialPrograms/CMakeLists.txt index fe658e9395..43b59c88b9 100644 --- a/SerialPrograms/CMakeLists.txt +++ b/SerialPrograms/CMakeLists.txt @@ -439,8 +439,8 @@ else() # macOS and Linux #we hope to use our own Tesseract build in future so we can rid that dependency #but right now to run on Linux and Mac we need to use external Tesseract library - pkg_search_module(TESSERACT REQUIRED tesseract) - pkg_search_module(LEPTONICA REQUIRED lept) + pkg_search_module(TESSERACT tesseract) + pkg_search_module(LEPTONICA lept) if (TESSERACT_FOUND AND LEPTONICA_FOUND) target_compile_definitions(SerialProgramsLib PRIVATE PA_TESSERACT UNIX_LINK_TESSERACT) target_include_directories(SerialProgramsLib SYSTEM PRIVATE ${TESSERACT_INCLUDE_DIRS})