2015-09-06 05:47:32 +08:00
|
|
|
#
|
|
|
|
# tesseract
|
|
|
|
#
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# cmake settings
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
2019-11-01 16:28:08 +08:00
|
|
|
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
|
2015-09-06 05:47:32 +08:00
|
|
|
|
|
|
|
# In-source builds are disabled.
|
2018-10-31 02:58:50 +08:00
|
|
|
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()
|
|
|
|
|
2018-10-31 02:58:50 +08:00
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
2015-09-06 05:47:32 +08:00
|
|
|
|
2018-10-31 02:27:34 +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")
|
|
|
|
|
2020-06-25 20:17:22 +08:00
|
|
|
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.15.0")
|
|
|
|
if (WIN32)
|
|
|
|
cmake_policy(SET CMP0091 NEW)
|
|
|
|
message(STATUS "Setting policy CMP0091 to NEW")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-09-06 05:47:32 +08:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# project settings
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
project(tesseract C CXX)
|
|
|
|
|
2018-03-28 15:58:25 +08:00
|
|
|
# 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})
|
2019-01-30 03:01:55 +08:00
|
|
|
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
|
2019-01-30 03:01:55 +08:00
|
|
|
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)
|
2019-01-30 03:01:55 +08:00
|
|
|
set(PACKAGE_VERSION ${VERSION_PLAIN})
|
|
|
|
endif()
|
2018-03-28 15:58:25 +08:00
|
|
|
|
|
|
|
# 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
|
|
|
|
2016-12-26 22:28:31 +08:00
|
|
|
set(MINIMUM_LEPTONICA_VERSION 1.74)
|
2015-10-09 23:12:02 +08:00
|
|
|
|
2019-01-25 06:03:47 +08:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# options
|
|
|
|
#
|
|
|
|
###############################################################################
|
2019-10-31 02:37:38 +08:00
|
|
|
|
2019-02-02 01:28:47 +08:00
|
|
|
message( "Configuring tesseract version ${PACKAGE_VERSION}...")
|
2019-01-25 06:03:47 +08:00
|
|
|
|
2020-01-06 04:08:03 +08:00
|
|
|
if (WIN32)
|
|
|
|
option(SW_BUILD "Build with sw" ON)
|
|
|
|
else()
|
|
|
|
option(SW_BUILD "Build with sw" OFF)
|
|
|
|
endif()
|
2019-01-25 06:03:47 +08:00
|
|
|
option(OPENMP_BUILD "Build with openmp support" OFF) # see issue #1662
|
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)
|
2020-06-26 21:38:00 +08:00
|
|
|
option(ENABLE_LTO "Enable link-time optimization" OFF)
|
2021-08-06 03:35:54 +08:00
|
|
|
option(FAST_FLOAT "Enable float for LSTM" OFF)
|
2019-01-25 06:03:47 +08:00
|
|
|
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)
|
2021-09-19 17:13:21 +08:00
|
|
|
option(DISABLE_CURL "Disable build with libcurl (if available)" OFF)
|
|
|
|
|
2020-06-25 20:17:22 +08:00
|
|
|
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.15.0")
|
|
|
|
if(WIN32 AND MSVC)
|
|
|
|
option(WIN32_MT_BUILD "Build with MT flag for MSVC" OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
2019-01-25 06:03:47 +08:00
|
|
|
|
2015-09-06 05:47:32 +08:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# compiler and linker
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
2020-07-01 05:09:36 +08:00
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
|
|
set(CLANG 1)
|
|
|
|
endif()
|
|
|
|
|
2019-09-29 19:53:44 +08:00
|
|
|
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()
|
|
|
|
|
2019-09-28 20:35:44 +08:00
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
|
2020-12-26 21:39:20 +08:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2019-02-16 00:50:45 +08:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
2021-09-19 17:06:19 +08:00
|
|
|
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
# cygwin gnu c++ needs to use -std=gnu++17 instead of -std=c++17
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
endif ()
|
2019-02-16 00:50:45 +08:00
|
|
|
|
2021-01-01 00:32:03 +08:00
|
|
|
if (BUILD_SHARED_LIBS)
|
2020-12-31 23:26:15 +08:00
|
|
|
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
2015-09-06 05:47:32 +08:00
|
|
|
endif()
|
|
|
|
|
2020-06-26 21:38:00 +08:00
|
|
|
# LTO
|
2020-06-30 19:31:49 +08:00
|
|
|
cmake_policy(SET CMP0069 NEW)
|
2020-06-26 21:38:00 +08:00
|
|
|
include(CheckIPOSupported)
|
|
|
|
check_ipo_supported(RESULT LTO_SUPPORTED OUTPUT error)
|
|
|
|
if(LTO_SUPPORTED)
|
|
|
|
message(STATUS "IPO / LTO supported")
|
|
|
|
else()
|
|
|
|
message(STATUS "IPO / LTO not supported: <${error}>")
|
|
|
|
endif()
|
|
|
|
|
2020-07-01 05:09:36 +08:00
|
|
|
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
|
|
|
|
if(COMPILER_SUPPORTS_MARCH_NATIVE)
|
2021-04-13 03:41:09 +08:00
|
|
|
set(MARCH_NATIVE_FLAGS "${MARCH_NATIVE_FLAGS} -march=native")
|
|
|
|
if(NOT CLANG AND MSVC)
|
|
|
|
# clang-cl does not know this argument
|
|
|
|
set(MARCH_NATIVE_FLAGS "${MARCH_NATIVE_FLAGS} -mtune=native")
|
|
|
|
endif()
|
2020-07-01 05:09:36 +08:00
|
|
|
set(MARCH_NATIVE_OPT ON)
|
|
|
|
endif()
|
|
|
|
|
2021-07-02 21:23:58 +08:00
|
|
|
message("CMAKE_SYSTEM_PROCESSOR=<${CMAKE_SYSTEM_PROCESSOR}>")
|
2021-01-31 23:32:24 +08:00
|
|
|
|
2021-07-02 21:23:58 +08:00
|
|
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86|AMD64")
|
2021-01-31 23:32:24 +08:00
|
|
|
|
2021-07-03 21:43:10 +08:00
|
|
|
set(HAVE_NEON FALSE)
|
|
|
|
|
2020-07-01 05:09:36 +08:00
|
|
|
CHECK_CXX_COMPILER_FLAG("-mavx" HAVE_AVX)
|
|
|
|
if(HAVE_AVX)
|
|
|
|
set(AVX_COMPILE_FLAGS "-mavx")
|
|
|
|
add_definitions("-DHAVE_AVX")
|
|
|
|
endif(HAVE_AVX)
|
|
|
|
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-mavx2" HAVE_AVX2)
|
|
|
|
if(HAVE_AVX2)
|
|
|
|
set(AVX2_COMPILE_FLAGS "-mavx2")
|
2020-07-01 14:43:55 +08:00
|
|
|
add_definitions("-DHAVE_AVX2")
|
2020-07-01 05:09:36 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-mfma" HAVE_FMA)
|
|
|
|
if(HAVE_FMA)
|
|
|
|
set(FMA_COMPILE_FLAGS "-mfma")
|
|
|
|
add_definitions("-DHAVE_FMA")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-msse4.1" HAVE_SSE4_1)
|
|
|
|
if(HAVE_SSE4_1)
|
|
|
|
set(SSE4_1_COMPILE_FLAGS "-msse4.1")
|
|
|
|
add_definitions("-DHAVE_SSE4_1")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
if(NOT HAVE_AVX)
|
2020-07-02 03:45:49 +08:00
|
|
|
set(AVX_COMPILE_FLAGS "/arch:AVX")
|
|
|
|
set(HAVE_AVX ON)
|
|
|
|
add_definitions("-DHAVE_AVX")
|
2020-07-01 05:09:36 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT HAVE_AVX2)
|
2020-07-02 03:45:49 +08:00
|
|
|
set(AVX2_COMPILE_FLAGS "/arch:AVX2")
|
|
|
|
set(HAVE_AVX2 ON)
|
|
|
|
add_definitions("-DHAVE_AVX2")
|
|
|
|
set(FMA_COMPILE_FLAGS "-D__FMA__")
|
|
|
|
set(HAVE_FMA ON)
|
|
|
|
add_definitions("-DHAVE_FMA")
|
2020-07-01 05:09:36 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT HAVE_SSE4_1)
|
2020-07-02 03:45:49 +08:00
|
|
|
set(SSE4_1_COMPILE_FLAGS "-D__SSE4_1__")
|
|
|
|
set(HAVE_SSE4_1 ON)
|
|
|
|
add_definitions("-DHAVE_SSE4_1")
|
2020-07-01 05:09:36 +08:00
|
|
|
endif()
|
2021-04-13 03:41:09 +08:00
|
|
|
# clang with MSVC compatibility
|
|
|
|
if(CLANG)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-microsoft-unqualified-friend")
|
|
|
|
if(HAVE_FMA)
|
|
|
|
set(FMA_COMPILE_FLAGS "-mfma ${FMA_COMPILE_FLAGS}")
|
|
|
|
endif(HAVE_FMA)
|
|
|
|
if(HAVE_SSE4_1)
|
|
|
|
set(SSE4_1_COMPILE_FLAGS "-msse4.1 ${SSE4_1_COMPILE_FLAGS}")
|
|
|
|
endif(HAVE_SSE4_1)
|
|
|
|
endif(CLANG)
|
2020-07-01 05:09:36 +08:00
|
|
|
endif(MSVC)
|
|
|
|
|
2021-07-02 21:23:58 +08:00
|
|
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64.*|AARCH64.*")
|
|
|
|
|
|
|
|
set(HAVE_AVX FALSE)
|
|
|
|
set(HAVE_AVX2 FALSE)
|
|
|
|
set(HAVE_FMA FALSE)
|
|
|
|
set(HAVE_SSE4_1 FALSE)
|
|
|
|
|
|
|
|
add_definitions("-DHAVE_NEON")
|
|
|
|
set(HAVE_NEON TRUE)
|
|
|
|
|
|
|
|
else()
|
|
|
|
|
|
|
|
set(HAVE_AVX FALSE)
|
|
|
|
set(HAVE_AVX2 FALSE)
|
|
|
|
set(HAVE_FMA FALSE)
|
|
|
|
set(HAVE_SSE4_1 FALSE)
|
|
|
|
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-mfpu=neon" HAVE_NEON)
|
|
|
|
if(HAVE_NEON)
|
|
|
|
set(NEON_COMPILE_FLAGS "-mfpu=neon")
|
|
|
|
add_definitions("-DHAVE_NEON")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86|AMD64")
|
2021-01-31 23:32:24 +08:00
|
|
|
|
2020-07-01 04:35:05 +08:00
|
|
|
# auto optimize - used only for information about available vectors
|
|
|
|
include(OptimizeForArchitecture)
|
|
|
|
OptimizeForArchitecture()
|
|
|
|
# remove global definition to eliminate effect on build
|
|
|
|
foreach(_flag ${_enable_vector_unit_list})
|
|
|
|
string(TOUPPER "${_flag}" _flag)
|
|
|
|
string(REPLACE "." "_" _flag "__${_flag}__")
|
|
|
|
remove_definitions("-D${_flag}")
|
|
|
|
endforeach(_flag)
|
|
|
|
foreach(flag ${Vc_ARCHITECTURE_FLAGS})
|
|
|
|
set(Vc_CXX_FLAGS "${Vc_CXX_FLAGS} ${flag}")
|
|
|
|
endforeach()
|
2020-07-01 02:57:50 +08:00
|
|
|
|
2019-07-14 02:10:33 +08:00
|
|
|
# Compiler specific environments
|
|
|
|
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)
|
2021-04-13 03:41:09 +08:00
|
|
|
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) # strdup
|
2019-07-14 02:10:33 +08:00
|
|
|
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()
|
2020-05-19 22:06:03 +08:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /wd4244 /wd4305 /wd4267")
|
2019-11-03 01:58:19 +08:00
|
|
|
# Don't use /Wall because it generates too many warnings.
|
2021-01-01 00:32:03 +08:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W0 /bigobj")
|
2020-06-25 20:17:22 +08:00
|
|
|
# MT flag
|
|
|
|
if(WIN32_MT_BUILD)
|
|
|
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
|
|
|
message (STATUS "Building with static CRT.")
|
|
|
|
endif()
|
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()
|
|
|
|
|
2021-06-30 05:16:51 +08:00
|
|
|
if (OPENMP_BUILD AND MSVC AND "${MSVC_VERSION}" LESS 1929)
|
2021-06-30 02:06:38 +08:00
|
|
|
set(OPENMP_BUILD OFF)
|
|
|
|
endif()
|
2019-01-25 06:03:47 +08:00
|
|
|
if (OPENMP_BUILD)
|
2019-11-01 16:28:51 +08:00
|
|
|
find_package(OpenMP QUIET)
|
|
|
|
if (OpenMP_FOUND)
|
|
|
|
message(">> ${OpenMP_FOUND} ${OpenMP_VERSION}")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
2020-01-06 05:33:24 +08:00
|
|
|
if(${CMAKE_VERSION} VERSION_LESS "3.9.0")
|
|
|
|
add_library(OpenMP::OpenMP_CXX IMPORTED INTERFACE)
|
|
|
|
endif()
|
2019-11-01 16:28:51 +08:00
|
|
|
endif()
|
|
|
|
# https://stackoverflow.com/questions/12399422/how-to-set-linker-flags-for-openmp-in-cmakes-try-compile-function
|
|
|
|
if (NOT OpenMP_FOUND AND CLANG AND WIN32)
|
|
|
|
# workaroung because find_package(OpenMP) does not work for clang-cl
|
|
|
|
# https://gitlab.kitware.com/cmake/cmake/issues/19404
|
|
|
|
check_include_file_cxx(omp.h HAVE_OMP_H_INCLUDE)
|
|
|
|
find_library(OpenMP_LIBRARY NAMES omp libomp.lib)
|
|
|
|
message(">> OpenMP_LIBRARY: ${OpenMP_LIBRARY}")
|
|
|
|
if (MSVC)
|
|
|
|
set(OpenMP_CXX_FLAGS "${OpenMP_CXX_FLAGS} /openmp")
|
|
|
|
else()
|
|
|
|
set(OpenMP_CXX_FLAGS "${OpenMP_CXX_FLAGS} -fopenmp")
|
|
|
|
endif()
|
|
|
|
set(OpenMP_FOUND 1)
|
|
|
|
add_definitions(-D_OPENMP=201107) # 3.1 version is supported from Clang 3.8.0
|
2019-01-25 06:03:47 +08:00
|
|
|
endif()
|
2021-06-30 02:06:38 +08:00
|
|
|
if (MSVC)
|
|
|
|
string(REPLACE "/openmp" "/openmp:llvm" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
|
|
|
string(REPLACE "-openmp" "/openmp:llvm" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
|
|
|
endif()
|
2019-01-25 06:03:47 +08:00
|
|
|
endif()
|
|
|
|
|
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()
|
|
|
|
|
2021-01-01 00:32:03 +08:00
|
|
|
add_definitions("-DCMAKE_BUILD")
|
|
|
|
|
2018-04-11 05:16:31 +08:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# packages
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
2019-10-31 02:37:38 +08:00
|
|
|
if (SW_BUILD)
|
2019-07-08 23:50:30 +08:00
|
|
|
find_package(SW REQUIRED)
|
2021-01-11 18:47:55 +08:00
|
|
|
if (BUILD_SHARED_LIBS)
|
2019-07-08 23:50:30 +08:00
|
|
|
set(SW_BUILD_SHARED_LIBS 1)
|
2021-01-11 18:47:55 +08:00
|
|
|
else()
|
|
|
|
set(SW_BUILD_SHARED_LIBS 0)
|
2019-07-08 23:50:30 +08:00
|
|
|
endif()
|
|
|
|
sw_add_package(
|
2019-10-31 02:37:38 +08:00
|
|
|
org.sw.demo.danbloomberg.leptonica
|
2019-07-08 23:50:30 +08:00
|
|
|
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
|
|
|
|
2021-02-01 00:21:43 +08:00
|
|
|
# Check for optional libarchive.
|
|
|
|
if(PKG_CONFIG_EXECUTABLE)
|
|
|
|
pkg_check_modules(LibArchive libarchive)
|
|
|
|
else()
|
|
|
|
find_package(LibArchive)
|
|
|
|
endif()
|
2019-07-09 01:59:23 +08:00
|
|
|
if(LibArchive_FOUND)
|
|
|
|
set(HAVE_LIBARCHIVE ON)
|
|
|
|
endif()
|
2021-09-19 17:13:21 +08:00
|
|
|
if (DISABLE_CURL)
|
|
|
|
set(HAVE_LIBCURL OFF)
|
|
|
|
else(DISABLE_CURL)
|
|
|
|
find_package(CURL)
|
|
|
|
if(NOT CURL_FOUND AND PKG_CONFIG_EXECUTABLE)
|
|
|
|
# try PKG_CONFIG to find libcurl if cmake failed
|
|
|
|
pkg_check_modules(CURL libcurl)
|
|
|
|
endif()
|
|
|
|
if(CURL_FOUND)
|
|
|
|
set(HAVE_LIBCURL ON)
|
|
|
|
include_directories(${CURL_INCLUDE_DIRS})
|
|
|
|
endif(CURL_FOUND)
|
|
|
|
endif(DISABLE_CURL)
|
2018-04-11 05:16:31 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
find_package(OpenCL QUIET)
|
2019-03-11 03:08:19 +08:00
|
|
|
|
2018-04-11 05:16:31 +08:00
|
|
|
|
2015-09-06 05:47:32 +08:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# configure
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
2019-09-28 20:35:44 +08:00
|
|
|
if (NOT MSVC)
|
|
|
|
set(MARCH_NATIVE_FLAGS "${MARCH_NATIVE_FLAGS} -O3 -ffast-math")
|
|
|
|
endif()
|
2020-07-01 04:35:05 +08:00
|
|
|
|
2018-10-31 02:58:50 +08:00
|
|
|
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()
|
2019-04-22 03:58:41 +08:00
|
|
|
set (CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${CMAKE_PREFIX_PATH}/include" "${CMAKE_INSTALL_PREFIX}/include")
|
2018-10-31 02:49:14 +08:00
|
|
|
include(Configure)
|
2015-09-06 05:47:32 +08:00
|
|
|
|
|
|
|
configure_file(${AUTOCONFIG_SRC} ${AUTOCONFIG} @ONLY)
|
|
|
|
|
2021-01-31 04:06:40 +08:00
|
|
|
set(INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include")
|
2015-09-06 05:47:32 +08:00
|
|
|
|
2018-03-28 15:58:25 +08:00
|
|
|
configure_file(
|
2019-10-29 18:40:17 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include/tesseract/version.h.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/include/tesseract/version.h @ONLY)
|
2020-10-08 05:47:48 +08:00
|
|
|
|
|
|
|
include(CMakePackageConfigHelpers)
|
2021-01-01 00:32:03 +08:00
|
|
|
include(GenerateExportHeader)
|
2020-10-08 05:47:48 +08:00
|
|
|
configure_package_config_file(
|
|
|
|
cmake/templates/TesseractConfig.cmake.in
|
2020-12-12 00:24:51 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/cmake/tesseract/TesseractConfig.cmake
|
|
|
|
INSTALL_DESTINATION lib/cmake/tesseract
|
2020-10-08 05:47:48 +08:00
|
|
|
PATH_VARS INCLUDE_DIR)
|
|
|
|
write_basic_package_version_file(
|
2020-12-12 00:24:51 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/cmake/tesseract/TesseractConfigVersion.cmake
|
2020-10-08 05:47:48 +08:00
|
|
|
VERSION ${PACKAGE_VERSION}
|
|
|
|
COMPATIBILITY SameMajorVersion)
|
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}")
|
2020-06-26 21:38:00 +08:00
|
|
|
if (LTO_SUPPORTED AND ENABLE_LTO)
|
|
|
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
|
|
|
else()
|
|
|
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE)
|
|
|
|
endif() # LTO_SUPPORTED
|
2019-09-28 05:56:36 +08:00
|
|
|
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}")
|
2019-04-24 05:05:26 +08:00
|
|
|
message( STATUS "Used standard: C++${CMAKE_CXX_STANDARD}")
|
2019-09-28 05:56:36 +08:00
|
|
|
message( STATUS "CXX compiler options: ${COMPILER_FLAGS}")
|
2020-05-16 18:30:20 +08:00
|
|
|
get_directory_property( DirCompDefs COMPILE_DEFINITIONS)
|
|
|
|
message( STATUS "Compile definitions = ${DirCompDefs}")
|
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}")
|
Replace AVX_OPT, ..., AVX macros by HAVE_AVX, ... and clean related code
- Replace AVX_OPT, AVX2_OPT, FMA_OPT, SSE41_OPT
- Replace AVX, AVX2, FMA, SSE4_1
- Write new HAVE_AVX, HAVE_AVX2, HAVE_FMA, HAVE_SSE4_1 into config_auto.h
- Put related conditionals in Makefile.am in one place
This makes the code clearer and fixes a log message in
IntSimdMatrixTest.AVX2.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-11-29 00:28:06 +08:00
|
|
|
message( STATUS "HAVE_AVX: ${HAVE_AVX}")
|
|
|
|
message( STATUS "HAVE_AVX2: ${HAVE_AVX2}")
|
|
|
|
message( STATUS "HAVE_FMA: ${HAVE_FMA}")
|
|
|
|
message( STATUS "HAVE_SSE4_1: ${HAVE_SSE4_1}")
|
2019-04-22 15:06:22 +08:00
|
|
|
message( STATUS "MARCH_NATIVE_OPT: ${MARCH_NATIVE_OPT}")
|
2020-07-01 05:09:36 +08:00
|
|
|
message( STATUS "HAVE_NEON: ${HAVE_NEON}")
|
2020-06-26 21:38:00 +08:00
|
|
|
message( STATUS "Link-time optimization: ${CMAKE_INTERPROCEDURAL_OPTIMIZATION}")
|
2019-07-08 23:50:30 +08:00
|
|
|
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}")
|
2021-09-19 17:13:21 +08:00
|
|
|
message( STATUS "Build with libcurl support [HAVE_LIBCURL]: ${HAVE_LIBCURL}")
|
2021-08-06 03:35:54 +08:00
|
|
|
message( STATUS "Enable float for LSTM [FAST_FLOAT]: ${FAST_FLOAT}")
|
2019-04-22 15:06:22 +08:00
|
|
|
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
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
2018-10-31 02:49:14 +08:00
|
|
|
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})
|
2019-07-25 15:13:31 +08:00
|
|
|
include_directories(${LibArchive_INCLUDE_DIRS})
|
2015-09-06 05:47:32 +08:00
|
|
|
|
2018-10-31 02:58:50 +08:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
2019-10-29 05:40:25 +08:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
|
2019-04-25 03:42:58 +08:00
|
|
|
if(ANDROID_TOOLCHAIN)
|
|
|
|
include_directories(${ANDROID_TOOLCHAIN}/sysroot/usr/include)
|
|
|
|
add_compile_definitions(__ANDROID_API_FUTURE__)
|
2019-03-31 22:10:35 +08:00
|
|
|
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
|
2018-04-25 16:02:54 +08:00
|
|
|
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
|
|
|
)
|
2019-04-22 15:00:17 +08:00
|
|
|
|
2020-06-17 23:14:11 +08:00
|
|
|
if (DISABLED_LEGACY_ENGINE)
|
|
|
|
function(prepend_path srcs path)
|
|
|
|
set(tmp, "")
|
|
|
|
foreach(src IN LISTS ${srcs})
|
|
|
|
list(APPEND tmp ${path}/${src})
|
|
|
|
endforeach(src ${srcs})
|
|
|
|
set(${srcs} ${tmp} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
SET(tesseract_src_legacy
|
|
|
|
src/ccmain/adaptions.cpp
|
|
|
|
src/ccmain/docqual.cpp
|
|
|
|
src/ccmain/equationdetect.cpp
|
|
|
|
src/ccmain/fixspace.cpp
|
|
|
|
src/ccmain/fixxht.cpp
|
|
|
|
src/ccmain/osdetect.cpp
|
|
|
|
src/ccmain/par_control.cpp
|
|
|
|
src/ccmain/recogtraining.cpp
|
|
|
|
src/ccmain/superscript.cpp
|
|
|
|
src/ccmain/tessbox.cpp
|
|
|
|
src/ccmain/tfacepp.cpp
|
|
|
|
src/ccstruct/fontinfo.cpp
|
|
|
|
src/ccstruct/params_training_featdef.cpp
|
|
|
|
src/ccutil/ambigs.cpp
|
|
|
|
src/ccutil/bitvector.cpp
|
|
|
|
src/ccutil/indexmapbidi.cpp
|
|
|
|
src/classify/adaptive.cpp
|
|
|
|
src/classify/adaptmatch.cpp
|
|
|
|
src/classify/blobclass.cpp
|
|
|
|
src/classify/cluster.cpp
|
|
|
|
src/classify/clusttool.cpp
|
|
|
|
src/classify/cutoffs.cpp
|
|
|
|
src/classify/featdefs.cpp
|
|
|
|
src/classify/float2int.cpp
|
|
|
|
src/classify/fpoint.cpp
|
|
|
|
src/classify/intfeaturespace.cpp
|
|
|
|
src/classify/intfx.cpp
|
|
|
|
src/classify/intmatcher.cpp
|
|
|
|
src/classify/intproto.cpp
|
|
|
|
src/classify/kdtree.cpp
|
|
|
|
src/classify/mf.cpp
|
|
|
|
src/classify/mfoutline.cpp
|
|
|
|
src/classify/mfx.cpp
|
|
|
|
src/classify/normfeat.cpp
|
|
|
|
src/classify/normmatch.cpp
|
|
|
|
src/classify/ocrfeatures.cpp
|
|
|
|
src/classify/outfeat.cpp
|
|
|
|
src/classify/picofeat.cpp
|
|
|
|
src/classify/protos.cpp
|
|
|
|
src/classify/shapeclassifier.cpp
|
|
|
|
src/classify/shapetable.cpp
|
|
|
|
src/classify/tessclassifier.cpp
|
|
|
|
src/classify/trainingsample.cpp
|
2020-06-18 23:24:17 +08:00
|
|
|
src/dict/permdawg.cpp
|
2020-06-17 23:14:11 +08:00
|
|
|
src/dict/hyphen.cpp
|
|
|
|
src/wordrec/associate.cpp
|
|
|
|
src/wordrec/chop.cpp
|
|
|
|
src/wordrec/chopper.cpp
|
|
|
|
src/wordrec/drawfx.cpp
|
|
|
|
src/wordrec/findseam.cpp
|
|
|
|
src/wordrec/gradechop.cpp
|
|
|
|
src/wordrec/language_model.cpp
|
|
|
|
src/wordrec/lm_consistency.cpp
|
|
|
|
src/wordrec/lm_pain_points.cpp
|
|
|
|
src/wordrec/lm_state.cpp
|
|
|
|
src/wordrec/outlines.cpp
|
|
|
|
src/wordrec/params_model.cpp
|
|
|
|
src/wordrec/pieces.cpp
|
|
|
|
src/wordrec/plotedges.cpp
|
|
|
|
src/wordrec/render.cpp
|
|
|
|
src/wordrec/segsearch.cpp
|
|
|
|
src/wordrec/wordclass.cpp
|
|
|
|
)
|
|
|
|
prepend_path(tesseract_src_legacy "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
list(REMOVE_ITEM tesseract_src ${tesseract_src_legacy})
|
|
|
|
endif(DISABLED_LEGACY_ENGINE)
|
|
|
|
|
2019-09-28 20:35:44 +08:00
|
|
|
list(APPEND arch_files
|
|
|
|
src/arch/dotproduct.cpp
|
|
|
|
src/arch/simddetect.cpp
|
|
|
|
src/arch/intsimdmatrix.cpp
|
|
|
|
)
|
2020-07-01 05:09:36 +08:00
|
|
|
|
2020-07-01 04:35:05 +08:00
|
|
|
if(MARCH_NATIVE_FLAGS)
|
2020-07-01 05:09:36 +08:00
|
|
|
set_source_files_properties(src/arch/dotproduct.cpp
|
|
|
|
PROPERTIES COMPILE_FLAGS ${MARCH_NATIVE_FLAGS})
|
2020-07-01 04:35:05 +08:00
|
|
|
endif(MARCH_NATIVE_FLAGS)
|
Replace AVX_OPT, ..., AVX macros by HAVE_AVX, ... and clean related code
- Replace AVX_OPT, AVX2_OPT, FMA_OPT, SSE41_OPT
- Replace AVX, AVX2, FMA, SSE4_1
- Write new HAVE_AVX, HAVE_AVX2, HAVE_FMA, HAVE_SSE4_1 into config_auto.h
- Put related conditionals in Makefile.am in one place
This makes the code clearer and fixes a log message in
IntSimdMatrixTest.AVX2.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-11-29 00:28:06 +08:00
|
|
|
if(HAVE_AVX)
|
2020-07-01 05:09:36 +08:00
|
|
|
list(APPEND arch_files_opt src/arch/dotproductavx.cpp)
|
|
|
|
set_source_files_properties(src/arch/dotproductavx.cpp
|
|
|
|
PROPERTIES COMPILE_FLAGS ${AVX_COMPILE_FLAGS})
|
Replace AVX_OPT, ..., AVX macros by HAVE_AVX, ... and clean related code
- Replace AVX_OPT, AVX2_OPT, FMA_OPT, SSE41_OPT
- Replace AVX, AVX2, FMA, SSE4_1
- Write new HAVE_AVX, HAVE_AVX2, HAVE_FMA, HAVE_SSE4_1 into config_auto.h
- Put related conditionals in Makefile.am in one place
This makes the code clearer and fixes a log message in
IntSimdMatrixTest.AVX2.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-11-29 00:28:06 +08:00
|
|
|
endif(HAVE_AVX)
|
|
|
|
if(HAVE_AVX2)
|
2020-07-01 05:09:36 +08:00
|
|
|
list(APPEND arch_files_opt src/arch/intsimdmatrixavx2.cpp src/arch/dotproductavx.cpp)
|
|
|
|
set_source_files_properties(src/arch/intsimdmatrixavx2.cpp
|
|
|
|
PROPERTIES COMPILE_FLAGS ${AVX2_COMPILE_FLAGS})
|
Replace AVX_OPT, ..., AVX macros by HAVE_AVX, ... and clean related code
- Replace AVX_OPT, AVX2_OPT, FMA_OPT, SSE41_OPT
- Replace AVX, AVX2, FMA, SSE4_1
- Write new HAVE_AVX, HAVE_AVX2, HAVE_FMA, HAVE_SSE4_1 into config_auto.h
- Put related conditionals in Makefile.am in one place
This makes the code clearer and fixes a log message in
IntSimdMatrixTest.AVX2.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-11-29 00:28:06 +08:00
|
|
|
endif(HAVE_AVX2)
|
|
|
|
if(HAVE_FMA)
|
2020-07-01 05:09:36 +08:00
|
|
|
list(APPEND arch_files_opt src/arch/dotproductfma.cpp)
|
|
|
|
set_source_files_properties(src/arch/dotproductfma.cpp
|
|
|
|
PROPERTIES COMPILE_FLAGS ${FMA_COMPILE_FLAGS})
|
Replace AVX_OPT, ..., AVX macros by HAVE_AVX, ... and clean related code
- Replace AVX_OPT, AVX2_OPT, FMA_OPT, SSE41_OPT
- Replace AVX, AVX2, FMA, SSE4_1
- Write new HAVE_AVX, HAVE_AVX2, HAVE_FMA, HAVE_SSE4_1 into config_auto.h
- Put related conditionals in Makefile.am in one place
This makes the code clearer and fixes a log message in
IntSimdMatrixTest.AVX2.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-11-29 00:28:06 +08:00
|
|
|
endif(HAVE_FMA)
|
|
|
|
if(HAVE_SSE4_1)
|
2020-07-01 05:09:36 +08:00
|
|
|
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 ${SSE4_1_COMPILE_FLAGS})
|
Replace AVX_OPT, ..., AVX macros by HAVE_AVX, ... and clean related code
- Replace AVX_OPT, AVX2_OPT, FMA_OPT, SSE41_OPT
- Replace AVX, AVX2, FMA, SSE4_1
- Write new HAVE_AVX, HAVE_AVX2, HAVE_FMA, HAVE_SSE4_1 into config_auto.h
- Put related conditionals in Makefile.am in one place
This makes the code clearer and fixes a log message in
IntSimdMatrixTest.AVX2.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2019-11-29 00:28:06 +08:00
|
|
|
endif(HAVE_SSE4_1)
|
2020-07-01 02:57:50 +08:00
|
|
|
if(HAVE_NEON)
|
2021-08-07 02:55:40 +08:00
|
|
|
list(APPEND arch_files_opt src/arch/dotproductneon.cpp src/arch/intsimdmatrixneon.cpp)
|
2021-01-31 23:54:17 +08:00
|
|
|
if(NEON_COMPILE_FLAGS)
|
2021-08-07 02:55:40 +08:00
|
|
|
set_source_files_properties(src/arch/dotproductneon.cpp src/arch/intsimdmatrixneon.cpp
|
2021-01-31 23:54:17 +08:00
|
|
|
PROPERTIES COMPILE_FLAGS ${NEON_COMPILE_FLAGS})
|
|
|
|
endif()
|
2020-07-01 02:57:50 +08:00
|
|
|
endif(HAVE_NEON)
|
2019-04-22 15:00:17 +08:00
|
|
|
|
2020-12-20 19:20:59 +08:00
|
|
|
file(GLOB_RECURSE tesseract_hdr
|
|
|
|
include/*
|
2018-04-25 16:02:54 +08:00
|
|
|
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}
|
2018-04-25 16:02:54 +08:00
|
|
|
src/api/baseapi.cpp
|
|
|
|
src/api/capi.cpp
|
|
|
|
src/api/renderer.cpp
|
2018-11-30 13:09:36 +08:00
|
|
|
src/api/altorenderer.cpp
|
2018-12-16 05:58:51 +08:00
|
|
|
src/api/hocrrenderer.cpp
|
2019-02-01 01:30:59 +08:00
|
|
|
src/api/lstmboxrenderer.cpp
|
2018-12-16 05:58:51 +08:00
|
|
|
src/api/pdfrenderer.cpp
|
2019-02-11 02:31:31 +08:00
|
|
|
src/api/wordstrboxrenderer.cpp
|
2015-09-06 05:47:32 +08:00
|
|
|
)
|
|
|
|
|
2020-12-25 22:57:57 +08:00
|
|
|
set(libtessfiles ${tesseract_src} ${arch_files} ${arch_files_opt} ${tesseract_hdr})
|
2020-12-25 22:43:26 +08:00
|
|
|
|
|
|
|
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${libtessfiles})
|
|
|
|
|
2021-01-01 00:32:03 +08:00
|
|
|
add_library (libtesseract ${libtessfiles})
|
2020-12-25 23:06:45 +08:00
|
|
|
target_include_directories (libtesseract
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
|
|
PRIVATE src
|
|
|
|
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/arch>
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/ccmain>
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/ccstruct>
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/ccutil>
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/classify>
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/cutil>
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/dict>
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/lstm>
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/opencl>
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/textord>
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/viewer>
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/wordrec>
|
|
|
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/training>
|
|
|
|
)
|
2021-01-11 18:47:55 +08:00
|
|
|
if (BUILD_SHARED_LIBS)
|
2017-02-23 20:39:58 +08:00
|
|
|
target_compile_definitions (libtesseract
|
2016-12-17 21:19:35 +08:00
|
|
|
PRIVATE -DTESS_EXPORTS
|
|
|
|
INTERFACE -DTESS_IMPORTS
|
|
|
|
)
|
2021-01-11 18:47:55 +08:00
|
|
|
#generate_export_header (libtesseract EXPORT_MACRO_NAME TESS_API)
|
2015-09-07 06:46:33 +08:00
|
|
|
endif()
|
2019-03-11 05:11:25 +08:00
|
|
|
target_link_libraries (libtesseract PRIVATE ${LIB_Ws2_32} ${LIB_pthread})
|
2020-01-06 05:33:24 +08:00
|
|
|
if(OpenMP_CXX_FOUND)
|
|
|
|
target_link_libraries(libtesseract PUBLIC OpenMP::OpenMP_CXX)
|
|
|
|
endif()
|
2021-09-19 17:13:21 +08:00
|
|
|
if(CURL_FOUND)
|
|
|
|
target_link_libraries(libtesseract PUBLIC ${CURL_LIBRARIES})
|
|
|
|
endif(CURL_FOUND)
|
2018-03-28 16:00:18 +08:00
|
|
|
set_target_properties (libtesseract PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
|
|
|
|
set_target_properties (libtesseract PROPERTIES SOVERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
|
2015-10-09 23:12:02 +08:00
|
|
|
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)
|
2017-08-30 05:14:13 +08:00
|
|
|
else()
|
|
|
|
set_target_properties (libtesseract PROPERTIES OUTPUT_NAME tesseract)
|
2015-10-09 23:12:02 +08:00
|
|
|
endif()
|
2015-09-06 05:47:32 +08:00
|
|
|
|
2019-10-31 02:37:38 +08:00
|
|
|
if (SW_BUILD)
|
2019-07-08 23:50:30 +08:00
|
|
|
target_link_libraries (libtesseract PUBLIC
|
2019-10-31 02:37:38 +08:00
|
|
|
org.sw.demo.danbloomberg.leptonica
|
2019-07-08 23:50:30 +08:00
|
|
|
org.sw.demo.libarchive.libarchive
|
|
|
|
)
|
|
|
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake "include(${CMAKE_CURRENT_BINARY_DIR}/cppan.cmake)\n")
|
2020-10-08 06:16:01 +08:00
|
|
|
export(TARGETS libtesseract APPEND FILE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake NAMESPACE Tesseract::)
|
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}
|
|
|
|
)
|
2020-10-08 06:16:01 +08:00
|
|
|
export(TARGETS libtesseract FILE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake NAMESPACE Tesseract::)
|
2016-06-30 05:29:55 +08:00
|
|
|
endif()
|
2015-09-06 05:47:32 +08:00
|
|
|
|
2019-01-25 06:03:47 +08:00
|
|
|
if (WIN32 AND CLANG AND OPENMP_BUILD)
|
2018-12-29 17:43:13 +08:00
|
|
|
# Workaround for "libomp.lib is not automatically added on Windows"
|
|
|
|
# see: http://lists.llvm.org/pipermail/openmp-dev/2015-August/000857.html
|
2019-11-01 16:28:51 +08:00
|
|
|
target_link_libraries (libtesseract PRIVATE ${OpenMP_LIBRARY})
|
2018-12-29 17:43:13 +08:00
|
|
|
endif()
|
|
|
|
|
2015-09-06 05:47:32 +08:00
|
|
|
########################################
|
|
|
|
# EXECUTABLE tesseractmain
|
|
|
|
########################################
|
|
|
|
|
2020-12-26 05:47:51 +08:00
|
|
|
add_executable (tesseract src/api/tesseractmain.cpp)
|
2017-02-23 20:39:58 +08:00
|
|
|
target_link_libraries (tesseract libtesseract)
|
2021-08-07 03:44:58 +08:00
|
|
|
if (WIN32 AND HAVE_TIFFIO_H)
|
2019-05-24 17:12:39 +08:00
|
|
|
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
|
|
|
########################################
|
|
|
|
|
2018-10-31 02:58:50 +08:00
|
|
|
if (BUILD_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/googletest/CMakeLists.txt)
|
2017-07-24 23:59:12 +08:00
|
|
|
add_subdirectory(googletest)
|
|
|
|
endif()
|
|
|
|
|
2016-12-17 23:33:41 +08:00
|
|
|
if (BUILD_TRAINING_TOOLS)
|
2018-04-25 16:35:26 +08:00
|
|
|
add_subdirectory(src/training)
|
2016-12-17 23:33:41 +08:00
|
|
|
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)
|
2021-07-17 07:45:32 +08:00
|
|
|
install(TARGETS tesseract DESTINATION bin)
|
2017-04-20 19:50:53 +08:00
|
|
|
install(TARGETS libtesseract EXPORT TesseractTargets RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
|
2020-10-08 06:16:01 +08:00
|
|
|
install(EXPORT TesseractTargets NAMESPACE Tesseract:: DESTINATION lib/cmake/tesseract)
|
2020-10-06 01:52:20 +08:00
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cmake DESTINATION lib)
|
2017-04-20 19:50:53 +08:00
|
|
|
|
|
|
|
install(FILES
|
2019-10-29 05:40:25 +08:00
|
|
|
include/tesseract/baseapi.h
|
|
|
|
include/tesseract/capi.h
|
|
|
|
include/tesseract/renderer.h
|
2019-10-29 18:40:17 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/include/tesseract/version.h
|
2017-04-20 19:50:53 +08:00
|
|
|
|
2019-10-29 05:40:25 +08:00
|
|
|
include/tesseract/ltrresultiterator.h
|
|
|
|
include/tesseract/pageiterator.h
|
|
|
|
include/tesseract/resultiterator.h
|
|
|
|
include/tesseract/osdetect.h
|
2017-04-20 19:50:53 +08:00
|
|
|
|
2019-10-29 05:40:25 +08:00
|
|
|
include/tesseract/publictypes.h
|
2017-04-20 19:50:53 +08:00
|
|
|
|
2019-10-29 05:40:25 +08:00
|
|
|
include/tesseract/ocrclass.h
|
2021-01-01 08:00:15 +08:00
|
|
|
include/tesseract/export.h
|
2019-10-29 05:40:25 +08:00
|
|
|
include/tesseract/unichar.h
|
2017-04-20 19:50:53 +08:00
|
|
|
|
2018-10-31 02:58:50 +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
|
|
|
###############################################################################
|