Skip to content

Commit

Permalink
Options to select system libraries (#14)
Browse files Browse the repository at this point in the history
* Options to select system libraries

* Update CMakeLists.txt

* Update CMakeLists.txt

* Update CMakeLists.txt
  • Loading branch information
umireon authored Feb 6, 2024
1 parent 91751ff commit 53726ca
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 116 deletions.
6 changes: 0 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[submodule "vendor/inja"]
path = vendor/inja
url = https://github.com/pantor/inja.git
[submodule "vendor/obs-ocr-deps"]
path = vendor/obs-ocr-deps
url = https://github.com/occ-ai/obs-ocr-deps.git
[submodule "vendor/obs-backgroundremoval-dep-opencv"]
path = vendor/obs-backgroundremoval-dep-opencv
url = https://github.com/occ-ai/obs-backgroundremoval-dep-opencv.git
44 changes: 20 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,46 +38,42 @@ set(USE_SYSTEM_OPENCV
OFF
CACHE STRING "Use system OpenCV")

set(BUILD_OPENCV_FROM_SOURCE
OFF
CACHE STRING "Build OpenCV from tarball")

if(OS_LINUX)
if(USE_SYSTEM_OPENCV AND BUILD_OPENCV_FROM_SOURCE)
message(FATAL_ERROR "Only one of USE_SYSTEM_OPENCV and BUILD_OPENCV_FROM_SOURCE can be enabled!")
endif()
else()
if(USE_SYSTEM_OPENCV)
message(FATAL_ERROR "System OpenCV is only supported on Linux!")
elseif(BUILD_OPENCV_FROM_SOURCE)
message(FATAL_ERROR "Building OpenCV from source is only supported on Linux!")
endif()
if(NOT OS_LINUX AND USE_SYSTEM_OPENCV)
message(FATAL_ERROR "System OpenCV is only supported on Linux!")
endif()

if(USE_SYSTEM_OPENCV)
find_package(OpenCV REQUIRED COMPONENTS core imgproc)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE "${OpenCV_LIBRARIES}")
target_include_directories(${CMAKE_PROJECT_NAME} SYSTEM PUBLIC "${OpenCV_INCLUDE_DIRS}")
elseif(BUILD_OPENCV_FROM_SOURCE)
include(cmake/BuildOpenCV.cmake)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OpenCV)
else()
include(cmake/FetchOpenCV.cmake)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OpenCV)
endif()

set(BUILD_TESSERACT_FROM_SOURCE
set(USE_SYSTEM_TESSERACT
OFF
CACHE STRING "Build Tessaract from tarball")
if(BUILD_TESSERACT_FROM_SOURCE)
if(NOT OS_LINUX)
message(FATAL_ERROR "Building Tesseract from source is only supported on Linux!")
CACHE STRING "Use system Tesseract")

if(NOT OS_LINUX AND USE_SYSTEM_TESSERACT)
message(FATAL_ERROR "System Tesseract is only supported on Linux!")
endif()

if(USE_SYSTEM_TESSERACT)
find_package(Tesseract)
if(Tesseract_FOUND)
target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE "${Tesseract_LIBRARY_DIRS}")
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE "${Tesseract_LIBRARIES}")
target_include_directories(${CMAKE_PROJECT_NAME} SYSTEM PUBLIC "${Tesseract_INCLUDE_DIRS}")
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(Tesseract REQUIRED IMPORTED_TARGET tesseract lept)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE PkgConfig::Tesseract)
endif()
include(cmake/BuildTesseract.cmake)
else()
include(cmake/FetchTesseract.cmake)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Tesseract)
endif()
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Tesseract)

include(cmake/BuildInja.cmake)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE inja)
Expand Down
36 changes: 0 additions & 36 deletions cmake/BuildOpenCV.cmake

This file was deleted.

48 changes: 0 additions & 48 deletions cmake/BuildTesseract.cmake

This file was deleted.

1 change: 0 additions & 1 deletion vendor/obs-backgroundremoval-dep-opencv
Submodule obs-backgroundremoval-dep-opencv deleted from 1adf5c
1 change: 0 additions & 1 deletion vendor/obs-ocr-deps
Submodule obs-ocr-deps deleted from eedf1a

0 comments on commit 53726ca

Please sign in to comment.