@@ -352,12 +352,6 @@ else() # macOS and Linux
352352 target_link_directories (SerialProgramsLib PUBLIC ${ONNXRUNTIME_LIBRARY_DIRS} )
353353 target_link_libraries (SerialProgramsLib PUBLIC ${ONNXRUNTIME_LINK_LIBRARIES} )
354354 endif ()
355- # Find OpenCV
356- if (CMAKE_SYSTEM_PROCESSOR MATCHES "(arm64)|(ARM64)" )
357- find_package (OpenCV REQUIRED HINTS "/opt/homebrew/opt/opencv/lib/cmake/opencv4/" )
358- else ()
359- find_package (OpenCV REQUIRED HINTS "/usr/local/opt/opencv/lib/cmake/opencv4/" )
360- endif ()
361355 else () # Linux
362356 # ONNX RUNTIME LINUX CONFIG
363357 # NOTE: users can specify their own ONNX_ROOT_PATH (this is the base folder for ONNX) on the command line when evoking cmake.
@@ -435,26 +429,26 @@ else() # macOS and Linux
435429 else ()
436430 message (FATAL_ERROR "Could not find ONNX Runtime headers or library." )
437431 endif ()
438- # Find OpenCV
439- find_package (OpenCV REQUIRED HINTS "/usr/local/opt/opencv/lib/cmake/opencv4/" )
440432 endif () # end Linux
441433
442- include_directories (${OpenCV_INCLUDE_DIRS} )
443- link_directories (${OpenCV_LIBRARY_DIRS} )
444- target_link_libraries (SerialProgramsLib PRIVATE ${OpenCV_LIBS} )
434+ # Find OpenCV
435+ pkg_search_module(OpenCV REQUIRED opencv4 opencv)
436+ target_include_directories (SerialProgramsLib SYSTEM PRIVATE ${OpenCV_INCLUDE_DIRS} ) # "SYSTEM" to suppress warnings
437+ target_link_directories (SerialProgramsLib PUBLIC ${OpenCV_LIBRARY_DIRS} )
438+ target_link_libraries (SerialProgramsLib PUBLIC ${OpenCV_LINK_LIBRARIES} )
445439
446440 #we hope to use our own Tesseract build in future so we can rid that dependency
447441 #but right now to run on Linux and Mac we need to use external Tesseract library
448- if (UNIX_LINK_TESSERACT)
442+ pkg_search_module(TESSERACT tesseract)
443+ pkg_search_module(LEPTONICA lept)
444+ if (TESSERACT_FOUND AND LEPTONICA_FOUND)
449445 target_compile_definitions (SerialProgramsLib PRIVATE PA_TESSERACT UNIX_LINK_TESSERACT)
450- pkg_search_module(TESSERACT REQUIRED tesseract)
451- pkg_search_module(LEPTONICA REQUIRED lept)
452- include_directories (${TESSERACT_INCLUDE_DIRS} )
453- include_directories (${LEPTONICA_INCLUDE_DIRS} )
454- link_directories (${TESSERACT_LIBRARY_DIRS} )
455- link_directories (${LEPTONICA_LIBRARY_DIRS} )
456- target_link_libraries (SerialProgramsLib PRIVATE ${TESSERACT_LINK_LIBRARIES} )
457- target_link_libraries (SerialProgramsLib PRIVATE ${LEPTONICA_LINK_LIBRARIES} )
446+ target_include_directories (SerialProgramsLib SYSTEM PRIVATE ${TESSERACT_INCLUDE_DIRS} )
447+ target_include_directories (SerialProgramsLib SYSTEM PRIVATE ${LEPTONICA_INCLUDE_DIRS} )
448+ target_link_directories (SerialProgramsLib PUBLIC ${TESSERACT_LIBRARY_DIRS} )
449+ target_link_directories (SerialProgramsLib PUBLIC ${LEPTONICA_LIBRARY_DIRS} )
450+ target_link_libraries (SerialProgramsLib PUBLIC ${TESSERACT_LINK_LIBRARIES} )
451+ target_link_libraries (SerialProgramsLib PUBLIC ${LEPTONICA_LINK_LIBRARIES} )
458452 endif ()
459453
460454 pkg_search_module(DPP dpp=10.0.22)
@@ -468,10 +462,6 @@ else() # macOS and Linux
468462 endif ()
469463
470464 if (APPLE )
471- # Add -Wno-c11-extensions to avoid clang gives
472- # /usr/local/Cellar/opencv/4.5.5_3/include/opencv4/opencv2/core/mat.inl.hpp:2116:9: error: '_Atomic' is a C11 extension
473- # when compiling OpenCV
474- # target_compile_options(SerialProgramsLib PRIVATE -Wall -Wextra -Wpedantic -Werror -Wno-c11-extensions)
475465 target_compile_options (SerialProgramsLib PRIVATE -Wall -Wextra -Wpedantic -Werror -Wshorten-64-to-32)
476466 # on macOS, need this framework to query OS API to control display sleep and system sleep behavior
477467 target_link_libraries (SerialProgramsLib PRIVATE "-framework IOKit -framework CoreFoundation" )
0 commit comments