File: init.cmake

package info (click to toggle)
opencv 4.5.1%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 268,248 kB
  • sloc: cpp: 969,170; xml: 682,525; python: 36,732; lisp: 30,170; java: 25,155; ansic: 7,927; javascript: 5,643; objc: 2,041; sh: 935; cs: 601; perl: 494; makefile: 145
file content (59 lines) | stat: -rw-r--r-- 2,046 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
OCV_OPTION(WITH_TESSERACT "Include Tesseract OCR library support" (NOT CMAKE_CROSSCOMPILING)
  VERIFY HAVE_TESSERACT)

if(NOT HAVE_TESSERACT
    AND (WITH_TESSERACT OR OPENCV_FIND_TESSERACT)
)
  if(NOT Tesseract_FOUND)
    find_package(Tesseract QUIET)  # Prefer CMake's standard locations (including Tesseract_DIR)
  endif()
  if(NOT Tesseract_FOUND)
    include("${CMAKE_CURRENT_LIST_DIR}/FindTesseract.cmake")  # OpenCV's fallback
  endif()
  if(Tesseract_FOUND)
    if(Tesseract_VERSION)
      message(STATUS "Tesseract:   YES (ver ${Tesseract_VERSION})")
    else()
      message(STATUS "Tesseract:   YES (ver unknown)")
    endif()
    if(NOT ENABLE_CXX11 AND NOT OPENCV_SKIP_TESSERACT_BUILD_CHECK)
      try_compile(__VALID_TESSERACT
        "${OpenCV_BINARY_DIR}/cmake_check/tesseract"
        "${CMAKE_CURRENT_LIST_DIR}/checks/tesseract_test.cpp"
        CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${Tesseract_INCLUDE_DIRS}"
        LINK_LIBRARIES ${Tesseract_LIBRARIES}
        OUTPUT_VARIABLE TRY_OUT
        )
      if(NOT __VALID_TESSERACT)
        if(OPENCV_DEBUG_TESSERACT_BUILD)
          message(STATUS "${TRY_OUT}")
        endif()
        message(STATUS "Can't use Tesseract (details: https://github.com/opencv/opencv_contrib/pull/2220)")
        return()
      endif()
    endif()
    set(HAVE_TESSERACT 1)
    set(HAVE_TESSERACT 1)

    # TODO use ocv_add_external_target
    set(name "tesseract")
    set(inc "${Tesseract_INCLUDE_DIRS}")
    set(link "${Tesseract_LIBRARIES}")
    set(def "")
    if(BUILD_SHARED_LIBS)
      set(imp IMPORTED)
    endif()
    add_library(ocv.3rdparty.${name} INTERFACE ${imp})
    set_target_properties(ocv.3rdparty.${name} PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${inc}"
      INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${inc}"
      INTERFACE_LINK_LIBRARIES "${link}"
      INTERFACE_COMPILE_DEFINITIONS "${def}")
    if(NOT BUILD_SHARED_LIBS)
      install(TARGETS ocv.3rdparty.${name} EXPORT OpenCVModules)
    endif()

  else()
    message(STATUS "Tesseract:   NO")
  endif()
endif()