tesseract/CMakeLists.txt

552 lines
19 KiB
CMake
Raw Normal View History

2015-09-06 05:47:32 +08:00
#
# tesseract
#
###############################################################################
#
# cmake settings
#
###############################################################################
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
2015-09-06 05:47:32 +08:00
# In-source builds are disabled.
if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
2015-09-06 05:47:32 +08:00
message(FATAL_ERROR
"CMake generation is not possible within the source directory!"
"\n Remove the CMakeCache.txt file and try again from another folder, e.g.:"
"\n "
"\n rm CMakeCache.txt"
"\n mkdir build"
"\n cd build"
"\n cmake .."
)
endif()
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2015-09-06 05:47:32 +08:00
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
2015-09-06 05:47:32 +08:00
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}")
# Use solution folders.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake Targets")
###############################################################################
#
# project settings
#
###############################################################################
project(tesseract C CXX)
# Get version with components from VERSION file.
file(STRINGS "VERSION" VERSION_PLAIN)
string(REGEX REPLACE "^([^.]*)\\..*" "\\1" VERSION_MAJOR ${VERSION_PLAIN})
string(REGEX REPLACE "^[^.]*\\.([^.]*)\\..*" "\\1" VERSION_MINOR ${VERSION_PLAIN})
string(REGEX REPLACE "^[^.]*\\.[^.]*\\.([0-9]*).*" "\\1" VERSION_PATCH ${VERSION_PLAIN})
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
2019-05-17 05:18:13 +08:00
execute_process(COMMAND git --git-dir ${CMAKE_CURRENT_SOURCE_DIR}/.git describe --abbrev=4
OUTPUT_VARIABLE GIT_REV)
2019-02-02 03:01:33 +08:00
string(REGEX REPLACE "\n$" "" PACKAGE_VERSION "${GIT_REV}")
endif()
2019-02-18 03:52:40 +08:00
if(NOT PACKAGE_VERSION)
set(PACKAGE_VERSION ${VERSION_PLAIN})
endif()
# Provide also same macro names as autoconf (see configure.ac).
set(GENERIC_MAJOR_VERSION ${VERSION_MAJOR})
set(GENERIC_MINOR_VERSION ${VERSION_MINOR})
set(GENERIC_MICRO_VERSION ${VERSION_PATCH})
2015-09-06 05:47:32 +08:00
set(MINIMUM_LEPTONICA_VERSION 1.74)
###############################################################################
#
# options
#
###############################################################################
2019-10-31 02:37:38 +08:00
2019-02-02 01:28:47 +08:00
message( "Configuring tesseract version ${PACKAGE_VERSION}...")
2019-10-31 02:37:38 +08:00
option(SW_BUILD "Build with sw" ON)
option(OPENMP_BUILD "Build with openmp support" OFF) # see issue #1662
option(AUTO_OPTIMIZE "Usage of cmake auto optimize macros (not suitable for portable build)" ON)
2019-03-17 03:26:15 +08:00
option(GRAPHICS_DISABLED "Disable disable graphics (ScrollView)" OFF)
option(DISABLED_LEGACY_ENGINE "Disable the legacy OCR engine" OFF)
option(BUILD_TRAINING_TOOLS "Build training tools" ON)
option(BUILD_TESTS "Build tests" OFF)
2019-07-03 10:29:15 +08:00
option(USE_SYSTEM_ICU "Use system ICU" OFF)
2015-09-06 05:47:32 +08:00
###############################################################################
#
# compiler and linker
#
###############################################################################
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
endif()
include(CheckCXXCompilerFlag)
# Check for C++ standard to use
get_property(known_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
2019-06-02 01:59:45 +08:00
if (cxx_std_17 IN_LIST known_features)
set(CMAKE_CXX_STANDARD 17)
2019-06-02 01:59:45 +08:00
elseif (cxx_std_14 IN_LIST known_features)
set(CMAKE_CXX_STANDARD 14)
else() # minimum required standard
set(CMAKE_CXX_STANDARD 11)
endif()
2019-06-02 01:59:45 +08:00
# Avoid using experimental c++1y (c++1z) standard even if the compiler announces cxx14 (cxx17)
# in CMAKE_CXX_KNOWN_FEATURES and CMAKE_CXX_COMPILE_FEATURES
# It is the case of clang 3.9, 4.0 (announces c++1z) and gcc 4.8 (announces c++1y)
if ("${CMAKE_CXX17_STANDARD_COMPILE_OPTION}" STREQUAL "-std=c++1z")
set(CMAKE_CXX_STANDARD 14)
endif()
if ("${CMAKE_CXX14_STANDARD_COMPILE_OPTION}" STREQUAL "-std=c++1y")
set(CMAKE_CXX_STANDARD 11)
2019-06-02 01:59:45 +08:00
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
2015-09-06 05:47:32 +08:00
set(LIBRARY_TYPE SHARED)
if (STATIC)
set(LIBRARY_TYPE)
endif()
# auto optimize
if (AUTO_OPTIMIZE)
include(OptimizeForArchitecture)
AutodetectHostArchitecture()
OptimizeForArchitecture()
endif()
2019-07-14 02:10:33 +08:00
# Compiler specific environments
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CLANG 1)
endif()
2019-07-14 02:10:33 +08:00
if(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -DDEBUG -pedantic -Og")
elseif(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
if (NOT CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
2015-09-06 05:47:32 +08:00
endif()
2019-07-14 02:10:33 +08:00
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Wall /bigobj")
2019-09-28 05:56:36 +08:00
endif()
if(CLANG) # clang all platforms
2019-07-14 02:10:33 +08:00
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-unused-command-line-argument")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -DDEBUG -pedantic -O0")
2015-09-07 01:43:28 +08:00
endif()
if (OPENMP_BUILD)
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
endif()
endif()
2019-07-14 02:10:33 +08:00
2015-09-07 07:49:18 +08:00
if (CYGWIN)
add_definitions(-D__CYGWIN__)
2019-07-14 02:10:33 +08:00
elseif(UNIX)
2019-01-04 06:53:38 +08:00
if (NOT ANDROID)
set(LIB_pthread pthread)
endif()
2019-07-14 02:10:33 +08:00
elseif(WIN32)
set(LIB_Ws2_32 Ws2_32)
2015-09-06 05:47:32 +08:00
endif()
###############################################################################
#
# packages
#
###############################################################################
2019-10-31 02:37:38 +08:00
if (SW_BUILD)
find_package(SW REQUIRED)
if (STATIC)
set(SW_BUILD_SHARED_LIBS 0)
else()
set(SW_BUILD_SHARED_LIBS 1)
endif()
sw_add_package(
2019-10-31 02:37:38 +08:00
org.sw.demo.danbloomberg.leptonica
org.sw.demo.libarchive.libarchive
)
if (BUILD_TRAINING_TOOLS)
sw_add_package(
org.sw.demo.gnome.pango.pangocairo
org.sw.demo.unicode.icu.i18n
)
endif()
sw_execute()
2019-05-17 05:18:13 +08:00
else()
2019-05-17 16:51:06 +08:00
find_package(PkgConfig)
2019-05-17 17:19:07 +08:00
if(PKG_CONFIG_EXECUTABLE AND NOT Leptonica_DIR)
2019-05-17 16:51:06 +08:00
pkg_check_modules(Leptonica REQUIRED lept>=${MINIMUM_LEPTONICA_VERSION})
link_directories(${Leptonica_LIBRARY_DIRS})
2019-05-17 05:18:13 +08:00
else()
2019-05-17 16:51:06 +08:00
find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED CONFIG)
2019-05-24 16:59:59 +08:00
endif()
2019-05-17 16:51:06 +08:00
if (NOT Leptonica_FOUND)
message(FATAL_ERROR "Cannot find required library Leptonica. Quitting!")
endif(NOT Leptonica_FOUND)
2019-07-09 01:59:23 +08:00
find_package(LibArchive)
if(LibArchive_FOUND)
set(HAVE_LIBARCHIVE ON)
endif()
endif()
find_package(OpenCL QUIET)
2015-09-06 05:47:32 +08:00
###############################################################################
#
# configure
#
###############################################################################
foreach(flag ${Vc_ARCHITECTURE_FLAGS})
set(Vc_CXX_FLAGS "${Vc_CXX_FLAGS} ${flag}")
endforeach()
# add definition as expected in src/arch/simddetect.cpp
2019-04-22 15:06:22 +08:00
set(AVX_OPT OFF)
set(AVX2_OPT OFF)
set(FMA_OPT OFF)
2019-04-22 15:06:22 +08:00
set(SSE41_OPT OFF)
set(MARCH_NATIVE_OPT OFF)
foreach(flag ${_enable_vector_unit_list}) # from OptimizeForArchitecture()
string(TOUPPER "${flag}" flag)
string(REPLACE "\." "_" flag "${flag}")
set(sim_flags "${sim_flags} -D${flag}")
string(REPLACE "_" "" flag "${flag}")
if("${flag}" MATCHES "AVX|AVX2|FMA|SSE41")
2019-04-22 15:06:22 +08:00
set("${flag}_OPT" ON)
endif()
endforeach(flag)
if (NOT MSVC)
set(MARCH_NATIVE_FLAGS "${MARCH_NATIVE_FLAGS} -O3 -ffast-math")
endif()
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
set(MARCH_NATIVE_FLAGS "${MARCH_NATIVE_FLAGS} -march=native -mtune=native")
2019-04-22 15:06:22 +08:00
set(MARCH_NATIVE_OPT ON)
endif()
set(AUTOCONFIG_SRC ${CMAKE_CURRENT_BINARY_DIR}/config_auto.h.in)
set(AUTOCONFIG ${CMAKE_CURRENT_BINARY_DIR}/config_auto.h)
2019-02-02 01:02:28 +08:00
add_definitions(-DHAVE_CONFIG_H)
2015-09-06 05:47:32 +08:00
2019-03-17 03:26:15 +08:00
if(GRAPHICS_DISABLED)
message("ScrollView debugging disabled.")
endif()
set (CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${CMAKE_PREFIX_PATH}/include" "${CMAKE_INSTALL_PREFIX}/include")
include(Configure)
2015-09-06 05:47:32 +08:00
configure_file(${AUTOCONFIG_SRC} ${AUTOCONFIG} @ONLY)
set(INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include" "${CMAKE_INSTALL_PREFIX}/include/tesseract")
2015-09-06 05:47:32 +08:00
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/include/tesseract/version.h.in
${CMAKE_CURRENT_BINARY_DIR}/include/tesseract/version.h @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/vs2010/tesseract/tesseract.rc.in
${CMAKE_CURRENT_BINARY_DIR}/vs2010/tesseract/tesseract.rc @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/vs2010/tesseract/libtesseract.rc.in
${CMAKE_CURRENT_BINARY_DIR}/vs2010/tesseract/libtesseract.rc @ONLY)
2015-09-06 05:47:32 +08:00
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/TesseractConfig-version.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/TesseractConfig-version.cmake @ONLY)
2015-09-06 05:47:32 +08:00
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/TesseractConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/TesseractConfig.cmake @ONLY)
2015-09-06 05:47:32 +08:00
2019-04-22 15:06:22 +08:00
# show summary of configuration
2019-09-28 05:56:36 +08:00
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
set(COMPILER_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
elseif(${CMAKE_BUILD_TYPE} MATCHES Release)
set(COMPILER_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
endif()
2019-04-22 15:06:22 +08:00
message( STATUS )
message( STATUS "General configuration for Tesseract ${PACKAGE_VERSION}")
message( STATUS "--------------------------------------------------------")
message( STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message( STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID}")
message( STATUS "Used standard: C++${CMAKE_CXX_STANDARD}")
2019-09-28 05:56:36 +08:00
message( STATUS "CXX compiler options: ${COMPILER_FLAGS}")
2019-04-22 15:06:22 +08:00
message( STATUS "Linker options: ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UP}}")
message( STATUS "Install directory: ${CMAKE_INSTALL_PREFIX}")
message( STATUS "Architecture flags: ${Vc_ARCHITECTURE_FLAGS}")
message( STATUS "Vector unit list: ${_enable_vector_unit_list}")
message( STATUS "AVX_OPT: ${AVX_OPT}")
message( STATUS "AVX2_OPT: ${AVX2_OPT}")
message( STATUS "FMA_OPT: ${FMA_OPT}")
2019-04-22 15:06:22 +08:00
message( STATUS "SSE41_OPT: ${SSE41_OPT}")
message( STATUS "MARCH_NATIVE_OPT: ${MARCH_NATIVE_OPT}")
message( STATUS "sim_flags: ${sim_flags}")
message( STATUS "--------------------------------------------------------")
message( STATUS "Build with sw [SW_BUILD]: ${SW_BUILD}")
2019-04-22 15:06:22 +08:00
message( STATUS "Build with openmp support [OPENMP_BUILD]: ${OPENMP_BUILD}")
message( STATUS "Disable disable graphics (ScrollView) [GRAPHICS_DISABLED]: ${GRAPHICS_DISABLED}")
message( STATUS "Disable the legacy OCR engine [DISABLED_LEGACY_ENGINE]: ${DISABLED_LEGACY_ENGINE}")
message( STATUS "Build training tools [BUILD_TRAINING_TOOLS]: ${BUILD_TRAINING_TOOLS}")
message( STATUS "Build tests [BUILD_TESTS]: ${BUILD_TESTS}")
2019-07-03 10:29:15 +08:00
message( STATUS "Use system ICU Library [USE_SYSTEM_ICU]: ${USE_SYSTEM_ICU}")
2019-04-22 15:06:22 +08:00
message( STATUS "--------------------------------------------------------")
message( STATUS )
2015-09-06 05:47:32 +08:00
###############################################################################
#
# build
#
###############################################################################
include(BuildFunctions)
include(SourceGroups)
2015-09-06 05:47:32 +08:00
add_definitions(-D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1)
include_directories(${Leptonica_INCLUDE_DIRS})
include_directories(${LibArchive_INCLUDE_DIRS})
2015-09-06 05:47:32 +08:00
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
include_directories(include)
include_directories(src/arch)
include_directories(src/ccmain)
include_directories(src/ccstruct)
include_directories(src/ccutil)
include_directories(src/classify)
include_directories(src/cutil)
include_directories(src/dict)
include_directories(src/lstm)
include_directories(src/opencl)
include_directories(src/textord)
include_directories(src/viewer)
include_directories(src/wordrec)
include_directories(src/training)
2019-04-25 03:42:58 +08:00
if(ANDROID_TOOLCHAIN)
include_directories(${ANDROID_TOOLCHAIN}/sysroot/usr/include)
add_compile_definitions(__ANDROID_API_FUTURE__)
endif()
2015-09-06 05:47:32 +08:00
########################################
2015-09-06 18:47:30 +08:00
# LIBRARY tesseract
2015-09-06 05:47:32 +08:00
########################################
2015-09-06 18:47:30 +08:00
file(GLOB tesseract_src
src/ccmain/*.cpp
src/ccstruct/*.cpp
src/ccutil/*.cpp
src/classify/*.cpp
src/cutil/*.cpp
src/dict/*.cpp
src/lstm/*.cpp
src/opencl/*.cpp
src/textord/*.cpp
src/viewer/*.cpp
src/wordrec/*.cpp
2015-09-06 18:47:30 +08:00
)
list(APPEND arch_files
src/arch/dotproduct.cpp
src/arch/simddetect.cpp
src/arch/intsimdmatrix.cpp
)
set_source_files_properties(${arch_files} PROPERTIES COMPILE_FLAGS "${sim_flags}")
set_source_files_properties(src/arch/dotproduct.cpp PROPERTIES COMPILE_FLAGS "${MARCH_NATIVE_FLAGS} ${Vc_CXX_FLAGS}")
if(AVX_OPT)
list(APPEND arch_files_opt src/arch/dotproductavx.cpp)
set_source_files_properties(src/arch/dotproductavx.cpp PROPERTIES COMPILE_FLAGS "-DAVX")
endif(AVX_OPT)
if(AVX2_OPT)
list(APPEND arch_files_opt src/arch/intsimdmatrixavx2.cpp)
set_source_files_properties(src/arch/intsimdmatrixavx2.cpp PROPERTIES COMPILE_FLAGS "-DAVX2")
endif(AVX2_OPT)
if(FMA_OPT)
list(APPEND arch_files_opt src/arch/dotproductfma.cpp)
set_source_files_properties(src/arch/dotproductfma.cpp PROPERTIES COMPILE_FLAGS "-mfma")
2019-07-16 11:03:14 +08:00
endif(FMA_OPT)
if(SSE41_OPT)
list(APPEND arch_files_opt src/arch/dotproductsse.cpp src/arch/intsimdmatrixsse.cpp)
set_source_files_properties(src/arch/dotproductsse.cpp src/arch/intsimdmatrixsse.cpp PROPERTIES COMPILE_FLAGS "-DSSE4_1 -msse4.1")
endif(SSE41_OPT)
set_source_files_properties(${arch_files_opt} PROPERTIES COMPILE_FLAGS "${Vc_CXX_FLAGS}")
2015-09-06 18:47:30 +08:00
file(GLOB tesseract_hdr
src/arch/*.h
src/ccmain/*.h
src/ccstruct/*.h
src/ccutil/*.h
src/classify/*.h
src/cutil/*.h
src/dict/*.h
src/lstm/*.h
src/opencl/*.h
src/textord/*.h
src/viewer/*.h
src/wordrec/*.h
2015-09-06 18:47:30 +08:00
)
set(tesseract_src ${tesseract_src}
src/api/baseapi.cpp
src/api/capi.cpp
src/api/renderer.cpp
2018-11-30 13:09:36 +08:00
src/api/altorenderer.cpp
src/api/hocrrenderer.cpp
src/api/lstmboxrenderer.cpp
src/api/pdfrenderer.cpp
src/api/wordstrboxrenderer.cpp
2015-09-06 05:47:32 +08:00
)
2017-02-24 00:29:48 +08:00
if (WIN32)
if (MSVC)
include_directories(src/vs2010/tesseract)
set(tesseract_hdr
${tesseract_hdr}
${CMAKE_CURRENT_SOURCE_DIR}/src/vs2010/tesseract/resource.h)
set(tesseract_rsc ${CMAKE_CURRENT_BINARY_DIR}/vs2010/tesseract/libtesseract.rc)
endif() # MSVC
2017-02-24 00:29:48 +08:00
endif()
add_library (libtesseract ${LIBRARY_TYPE} ${tesseract_src} ${arch_files}
${arch_files_opt} ${tesseract_hdr} ${tesseract_rsc}
)
if (NOT STATIC)
2017-02-23 20:39:58 +08:00
target_compile_definitions (libtesseract
PRIVATE -DTESS_EXPORTS
INTERFACE -DTESS_IMPORTS
)
2017-02-23 20:39:58 +08:00
set_target_properties (libtesseract PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS True)
endif()
target_link_libraries (libtesseract PRIVATE ${LIB_Ws2_32} ${LIB_pthread})
set_target_properties (libtesseract PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
set_target_properties (libtesseract PROPERTIES SOVERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
if (WIN32)
2017-02-23 20:39:58 +08:00
set_target_properties (libtesseract PROPERTIES OUTPUT_NAME tesseract${VERSION_MAJOR}${VERSION_MINOR})
set_target_properties (libtesseract PROPERTIES DEBUG_OUTPUT_NAME tesseract${VERSION_MAJOR}${VERSION_MINOR}d)
else()
set_target_properties (libtesseract PROPERTIES OUTPUT_NAME tesseract)
endif()
2015-09-06 05:47:32 +08:00
2019-10-31 02:37:38 +08:00
if (SW_BUILD)
target_link_libraries (libtesseract PUBLIC
2019-10-31 02:37:38 +08:00
org.sw.demo.danbloomberg.leptonica
org.sw.demo.libarchive.libarchive
)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake "include(${CMAKE_CURRENT_BINARY_DIR}/cppan.cmake)\n")
export(TARGETS libtesseract APPEND FILE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake)
2019-02-02 01:02:28 +08:00
else()
2019-03-11 05:06:46 +08:00
target_link_libraries (libtesseract PUBLIC
${Leptonica_LIBRARIES}
${LibArchive_LIBRARIES}
)
2019-02-02 01:02:28 +08:00
export(TARGETS libtesseract FILE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake)
endif()
2015-09-06 05:47:32 +08:00
if (WIN32 AND CLANG AND OPENMP_BUILD)
# Workaround for "libomp.lib is not automatically added on Windows"
# see: http://lists.llvm.org/pipermail/openmp-dev/2015-August/000857.html
# TODO: Find better way how to set Clang OpenMP library for linking on Windows
target_link_libraries (libtesseract PRIVATE "c:\\Program Files\\LLVM\\lib\\libomp.lib")
endif()
2015-09-06 05:47:32 +08:00
########################################
# EXECUTABLE tesseractmain
########################################
set(tesseractmain_src src/api/tesseractmain.cpp)
if (MSVC)
set(tesseractmain_rsc ${CMAKE_CURRENT_BINARY_DIR}/vs2010/tesseract/tesseract.rc)
endif()
add_executable (tesseract ${tesseractmain_src} ${tesseractmain_rsc})
2017-02-23 20:39:58 +08:00
target_link_libraries (tesseract libtesseract)
if (HAVE_TIFFIO_H)
target_link_libraries(tesseract tiff)
endif()
2015-09-06 05:47:32 +08:00
2019-05-31 20:18:26 +08:00
if (OPENMP_BUILD AND UNIX)
target_link_libraries (tesseract pthread)
endif()
2015-09-06 18:47:30 +08:00
########################################
if (BUILD_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/googletest/CMakeLists.txt)
add_subdirectory(googletest)
endif()
if (BUILD_TRAINING_TOOLS)
2018-04-25 16:35:26 +08:00
add_subdirectory(src/training)
endif()
2015-09-06 18:47:30 +08:00
2017-04-20 19:50:53 +08:00
get_target_property(tesseract_NAME libtesseract NAME)
get_target_property(tesseract_VERSION libtesseract VERSION)
get_target_property(tesseract_OUTPUT_NAME libtesseract OUTPUT_NAME)
configure_file(tesseract.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/tesseract.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tesseract.pc DESTINATION lib/pkgconfig)
install(TARGETS tesseract RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(TARGETS libtesseract EXPORT TesseractTargets RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(EXPORT TesseractTargets DESTINATION cmake)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/TesseractConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/TesseractConfig-version.cmake
2017-04-20 19:50:53 +08:00
DESTINATION cmake)
install(FILES
# from api/makefile.am
include/tesseract/apitypes.h
include/tesseract/baseapi.h
include/tesseract/capi.h
include/tesseract/renderer.h
${CMAKE_CURRENT_BINARY_DIR}/include/tesseract/version.h
2017-04-20 19:50:53 +08:00
#from ccmain/makefile.am
include/tesseract/thresholder.h
include/tesseract/ltrresultiterator.h
include/tesseract/pageiterator.h
include/tesseract/resultiterator.h
include/tesseract/osdetect.h
2017-04-20 19:50:53 +08:00
#from ccstruct/makefile.am
include/tesseract/publictypes.h
2017-04-20 19:50:53 +08:00
#from ccutil/makefile.am
include/tesseract/genericvector.h
include/tesseract/helpers.h
include/tesseract/ocrclass.h
include/tesseract/platform.h
include/tesseract/serialis.h
include/tesseract/strngs.h
include/tesseract/unichar.h
2017-04-20 19:50:53 +08:00
#${CMAKE_CURRENT_BINARY_DIR}/src/endianness.h
2017-04-20 19:50:53 +08:00
DESTINATION include/tesseract)
2019-05-09 01:17:43 +08:00
########################################
# uninstall target
########################################
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
2017-04-20 19:50:53 +08:00
2015-09-06 05:47:32 +08:00
###############################################################################