@@ -347,12 +347,6 @@ else() # macOS and Linux
347
347
target_include_directories (SerialProgramsLib PRIVATE ${HOMEBREW_PREFIX} /include /onnxruntime)
348
348
target_link_libraries (SerialProgramsLib PRIVATE ${HOMEBREW_PREFIX} /lib/libonnxruntime.dylib)
349
349
endif ()
350
- # Find OpenCV
351
- if (CMAKE_SYSTEM_PROCESSOR MATCHES "(arm64)|(ARM64)" )
352
- find_package (OpenCV REQUIRED HINTS "/opt/homebrew/opt/opencv/lib/cmake/opencv4/" )
353
- else ()
354
- find_package (OpenCV REQUIRED HINTS "/usr/local/opt/opencv/lib/cmake/opencv4/" )
355
- endif ()
356
350
357
351
else () # Linux
358
352
# ONNX RUNTIME LINUX CONFIG
@@ -431,13 +425,13 @@ else() # macOS and Linux
431
425
else ()
432
426
message (FATAL_ERROR "Could not find ONNX Runtime headers or library." )
433
427
endif ()
434
- # Find OpenCV
435
- find_package (OpenCV REQUIRED HINTS "/usr/local/opt/opencv/lib/cmake/opencv4/" )
436
428
endif ()
437
429
438
- include_directories (${OpenCV_INCLUDE_DIRS} )
439
- link_directories (${OpenCV_LIBRARY_DIRS} )
440
- target_link_libraries (SerialProgramsLib PRIVATE ${OpenCV_LIBS} )
430
+ # Find OpenCV
431
+ pkg_search_module(OpenCV REQUIRED opencv4 opencv)
432
+ target_include_directories (SerialProgramsLib PRIVATE ${OpenCV_INCLUDE_DIRS} )
433
+ target_link_directories (SerialProgramsLib PUBLIC ${OpenCV_LIBRARY_DIRS} )
434
+ target_link_libraries (SerialProgramsLib PUBLIC ${OpenCV_LINK_LIBRARIES} )
441
435
442
436
#we hope to use our own Tesseract build in future so we can rid that dependency
443
437
#but right now to run on Linux and Mac we need to use external Tesseract library
@@ -466,11 +460,10 @@ else() # macOS and Linux
466
460
# Add -Wno-c11-extensions to avoid clang gives
467
461
# /usr/local/Cellar/opencv/4.5.5_3/include/opencv4/opencv2/core/mat.inl.hpp:2116:9: error: '_Atomic' is a C11 extension
468
462
# when compiling OpenCV
469
- # target_compile_options(SerialProgramsLib PRIVATE -Wall -Wextra -Wpedantic -Werror -Wno-c11-extensions)
470
- target_compile_options (SerialProgramsLib PRIVATE -Wall -Wextra -Wpedantic -Werror -Wshorten-64-to-32)
463
+ target_compile_options (SerialProgramsLib PRIVATE -Wall -Wextra -Wpedantic -Werror -Wno-c11-extensions -Wshorten-64-to-32)
471
464
else ()
472
465
# Assume GCC
473
- target_compile_options (SerialProgramsLib PRIVATE -Wall -Wextra -Wpedantic -Werror -fno-strict-aliasing)
466
+ target_compile_options (SerialProgramsLib PRIVATE -Wall -Wextra -Wpedantic -Werror -Wno-c11-extensions - fno-strict-aliasing)
474
467
endif ()
475
468
476
469
# Set OS-specific flags
0 commit comments