init.cmake 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. OCV_OPTION(WITH_TESSERACT "Include Tesseract OCR library support" (NOT CMAKE_CROSSCOMPILING)
  2. VERIFY HAVE_TESSERACT)
  3. if(NOT HAVE_TESSERACT
  4. AND (WITH_TESSERACT OR OPENCV_FIND_TESSERACT)
  5. )
  6. if(NOT Tesseract_FOUND)
  7. find_package(Tesseract QUIET) # Prefer CMake's standard locations (including Tesseract_DIR)
  8. endif()
  9. if(NOT Tesseract_FOUND)
  10. include("${CMAKE_CURRENT_LIST_DIR}/FindTesseract.cmake") # OpenCV's fallback
  11. endif()
  12. if(Tesseract_FOUND)
  13. if(Tesseract_VERSION)
  14. message(STATUS "Tesseract: YES (ver ${Tesseract_VERSION})")
  15. else()
  16. message(STATUS "Tesseract: YES (ver unknown)")
  17. endif()
  18. if(NOT ENABLE_CXX11 AND NOT OPENCV_SKIP_TESSERACT_BUILD_CHECK)
  19. try_compile(__VALID_TESSERACT
  20. "${OpenCV_BINARY_DIR}/cmake_check/tesseract"
  21. "${CMAKE_CURRENT_LIST_DIR}/checks/tesseract_test.cpp"
  22. CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${Tesseract_INCLUDE_DIRS}"
  23. LINK_LIBRARIES ${Tesseract_LIBRARIES}
  24. OUTPUT_VARIABLE TRY_OUT
  25. )
  26. if(NOT __VALID_TESSERACT)
  27. if(OPENCV_DEBUG_TESSERACT_BUILD)
  28. message(STATUS "${TRY_OUT}")
  29. endif()
  30. message(STATUS "Can't use Tesseract (details: https://github.com/opencv/opencv_contrib/pull/2220)")
  31. return()
  32. endif()
  33. endif()
  34. set(HAVE_TESSERACT 1)
  35. set(HAVE_TESSERACT 1)
  36. # TODO use ocv_add_external_target
  37. set(name "tesseract")
  38. set(inc "${Tesseract_INCLUDE_DIRS}")
  39. set(link "${Tesseract_LIBRARIES}")
  40. set(def "")
  41. if(BUILD_SHARED_LIBS)
  42. set(imp IMPORTED)
  43. endif()
  44. add_library(ocv.3rdparty.${name} INTERFACE ${imp})
  45. set_target_properties(ocv.3rdparty.${name} PROPERTIES
  46. INTERFACE_INCLUDE_DIRECTORIES "${inc}"
  47. INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${inc}"
  48. INTERFACE_LINK_LIBRARIES "${link}"
  49. INTERFACE_COMPILE_DEFINITIONS "${def}")
  50. if(NOT BUILD_SHARED_LIBS)
  51. install(TARGETS ocv.3rdparty.${name} EXPORT OpenCVModules)
  52. endif()
  53. else()
  54. message(STATUS "Tesseract: NO")
  55. endif()
  56. endif()