Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 14 additions & 24 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -435,26 +429,26 @@ 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
if (UNIX_LINK_TESSERACT)
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)
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)
Expand All @@ -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")
Expand Down