Skip to content

Commit b71fbde

Browse files
committed
cmake: update for opencv
1 parent ff2c036 commit b71fbde

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,6 @@ else() # macOS and Linux
347347
target_include_directories(SerialProgramsLib PRIVATE ${HOMEBREW_PREFIX}/include/onnxruntime)
348348
target_link_libraries(SerialProgramsLib PRIVATE ${HOMEBREW_PREFIX}/lib/libonnxruntime.dylib)
349349
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()
356350

357351
else() # Linux
358352
# ONNX RUNTIME LINUX CONFIG
@@ -431,13 +425,13 @@ else() # macOS and Linux
431425
else()
432426
message(FATAL_ERROR "Could not find ONNX Runtime headers or library.")
433427
endif()
434-
# Find OpenCV
435-
find_package(OpenCV REQUIRED HINTS "/usr/local/opt/opencv/lib/cmake/opencv4/")
436428
endif()
437429

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})
441435

442436
#we hope to use our own Tesseract build in future so we can rid that dependency
443437
#but right now to run on Linux and Mac we need to use external Tesseract library
@@ -466,11 +460,10 @@ else() # macOS and Linux
466460
# Add -Wno-c11-extensions to avoid clang gives
467461
# /usr/local/Cellar/opencv/4.5.5_3/include/opencv4/opencv2/core/mat.inl.hpp:2116:9: error: '_Atomic' is a C11 extension
468462
# 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)
471464
else()
472465
# 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)
474467
endif()
475468

476469
# Set OS-specific flags

0 commit comments

Comments
 (0)