From 56a51952935025d6e7fc77fa0067a07bde48f954 Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Sun, 6 Sep 2015 00:47:32 +0300 Subject: [PATCH 01/26] Initial CMake implementation. --- .gitignore | 3 + CMakeLists.txt | 211 ++++++++++++++++++ cmake/Configure.cmake | 134 +++++++++++ .../TesseractConfig-version.cmake.in | 14 ++ cmake/templates/TesseractConfig.cmake.in | 43 ++++ 5 files changed, 405 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 cmake/Configure.cmake create mode 100644 cmake/templates/TesseractConfig-version.cmake.in create mode 100644 cmake/templates/TesseractConfig.cmake.in diff --git a/.gitignore b/.gitignore index e92fdeddb..9081efccc 100644 --- a/.gitignore +++ b/.gitignore @@ -69,3 +69,6 @@ training/wordlist2dawg tesseract_opencl_profile_devices.dat kernel*.bin +# build dirs +/build* +/win* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..d28cacacd --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,211 @@ +# +# tesseract +# + +############################################################################### +# +# cmake settings +# +############################################################################### + +cmake_minimum_required(VERSION 2.8.12) + +# In-source builds are disabled. +if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + 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_SOURCE_DIR}/cmake") + +set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin") +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) + +set(VERSION_MAJOR 3) +set(VERSION_MINOR 05) +set(VERSION_PLAIN ${VERSION_MAJOR}.${VERSION_MINOR}) + +find_package(Leptonica 1.72 REQUIRED) + +############################################################################### +# +# compiler and linker +# +############################################################################### + +set(LIBRARY_TYPE SHARED) +if (STATIC) + set(LIBRARY_TYPE) +endif() + +if (WIN32) + if (MSVC) + add_definitions(-D_SCL_SECURE_NO_WARNINGS) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0") + endif() +endif() + +############################################################################### +# +# configure +# +############################################################################### + +set(AUTOCONFIG_SRC ${CMAKE_BINARY_DIR}/config_auto.h.in) +set(AUTOCONFIG ${CMAKE_BINARY_DIR}/src/config_auto.h) + +include(Configure) + +configure_file(${AUTOCONFIG_SRC} ${AUTOCONFIG} @ONLY) + +set(INCLUDE_DIR ${CMAKE_SOURCE_DIR}/api) + +configure_file( + ${CMAKE_SOURCE_DIR}/cmake/templates/TesseractConfig-version.cmake.in + ${CMAKE_BINARY_DIR}/TesseractConfig-version.cmake @ONLY) +configure_file( + ${CMAKE_SOURCE_DIR}/cmake/templates/TesseractConfig.cmake.in + ${CMAKE_BINARY_DIR}/TesseractConfig.cmake @ONLY) + +############################################################################### +# +# build +# +############################################################################### + +######################################## +# FUNCTION build_dir +######################################## +function(build_dir target_name) + if (${ARGC} GREATER 1) + set(dir ${ARGV1}) + else() + set(dir ${target_name}) + endif() + file(GLOB ${dir}_src "${dir}/*.cpp") + file(GLOB ${dir}_hdr "${dir}/*.h") + add_library(${target_name} ${${dir}_src} ${${dir}_hdr}) +endfunction(build_dir) +######################################## + +add_definitions(-D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1) +add_definitions(-DUSE_STD_NAMESPACE=1) +add_definitions(-DWINDLLNAME="libtesseract${VERSION_MAJOR}${VERSION_MINOR}.dll") +add_definitions(-DTESS_EXPORTS) + +include_directories(${Leptonica_INCLUDE_DIRS}) + +include_directories(ccmain) +include_directories(ccstruct) +include_directories(ccutil) +include_directories(classify) +include_directories(cube) +include_directories(cutil) +include_directories(dict) +include_directories(neural_networks/runtime) +include_directories(opencl) +include_directories(textord) +include_directories(vs2010/port) +include_directories(viewer) +include_directories(wordrec) + +######################################## +# LIBRARY api +######################################## + +set(api_src + api/baseapi.cpp + api/capi.cpp + api/renderer.cpp + api/pdfrenderer.cpp +) +file(GLOB api_hdr "api/*.h") +add_library(api ${api_src} ${api_hdr}) + + +######################################## + +######################################## +# LIBRARIES tesseract +######################################## + +build_dir(main ccmain) +build_dir(struct ccstruct) +build_dir(ccutil) +build_dir(classify) +build_dir(cube) +build_dir(cutil) +build_dir(dict) +build_dir(neural neural_networks/runtime) +build_dir(opencl) +build_dir(textord) +build_dir(viewer) +build_dir(port vs2010/port) +build_dir(wordrec) + + +######################################## +# LIBRARY tesseract +######################################## + +add_library (tesseract ${LIBRARY_TYPE} ${tesseract_src} ${tesseract_hdr}) +target_link_libraries (tesseract + PRIVATE + main + struct + ccutil + classify + cube + cutil + dict + neural + opencl + textord + viewer + port + wordrec + + PUBLIC + ${Leptonica_LIBRARIES} + Ws2_32 +) +set_target_properties (tesseract PROPERTIES OUTPUT_NAME libtesseract${VERSION_MAJOR}${VERSION_MINOR}) +set_target_properties (tesseract PROPERTIES DEBUG_OUTPUT_NAME libtesseract${VERSION_MAJOR}${VERSION_MINOR}d) +export(TARGETS tesseract FILE ${CMAKE_BINARY_DIR}/TesseractTargets.cmake) + + +######################################## +# EXECUTABLE tesseractmain +######################################## + +set(tesseractmain_src + api/tesseractmain.cpp + vs2010/tesseract/resource.h + vs2010/tesseract/tesseract.rc +) +add_executable (tesseractmain ${tesseractmain_src}) +target_link_libraries (tesseractmain tesseract) + +############################################################################### diff --git a/cmake/Configure.cmake b/cmake/Configure.cmake new file mode 100644 index 000000000..54a4ec293 --- /dev/null +++ b/cmake/Configure.cmake @@ -0,0 +1,134 @@ +################################################################################ +# +# configure +# +################################################################################ + +######################################## +# FUNCTION check_includes +######################################## +function(check_includes files) + foreach(F ${${files}}) + set(name ${F}) + string(REPLACE "-" "_" name ${name}) + string(REPLACE "." "_" name ${name}) + string(REPLACE "/" "_" name ${name}) + string(TOUPPER ${name} name) + check_include_files(${F} HAVE_${name}) + file(APPEND ${AUTOCONFIG_SRC} "/* Define to 1 if you have the <${F}> header file. */\n") + file(APPEND ${AUTOCONFIG_SRC} "#cmakedefine HAVE_${name} 1\n") + file(APPEND ${AUTOCONFIG_SRC} "\n") + endforeach() +endfunction(check_includes) + +######################################## +# FUNCTION check_functions +######################################## +function(check_functions functions) + foreach(F ${${functions}}) + set(name ${F}) + string(TOUPPER ${name} name) + check_function_exists(${F} HAVE_${name}) + file(APPEND ${AUTOCONFIG_SRC} "/* Define to 1 if you have the `${F}' function. */\n") + file(APPEND ${AUTOCONFIG_SRC} "#cmakedefine HAVE_${name} 1\n") + file(APPEND ${AUTOCONFIG_SRC} "\n") + endforeach() +endfunction(check_functions) + +######################################## + +file(WRITE ${AUTOCONFIG_SRC}) + +include(CheckCSourceCompiles) +include(CheckCSourceRuns) +include(CheckCXXSourceCompiles) +include(CheckCXXSourceRuns) +include(CheckFunctionExists) +include(CheckIncludeFiles) +include(CheckLibraryExists) +include(CheckPrototypeDefinition) +include(CheckStructHasMember) +include(CheckSymbolExists) +include(CheckTypeSize) +include(TestBigEndian) + +set(include_files_list + dlfcn.h + inttypes.h + memory.h + stdint.h + stdlib.h + strings.h + string.h + sys/stat.h + sys/types.h + unistd.h + + openjpeg-2.0/openjpeg.h + openjpeg-2.1/openjpeg.h + openjpeg-2.2/openjpeg.h +) +check_includes(include_files_list) + +set(functions_list + fmemopen +) +check_functions(functions_list) + +test_big_endian(WORDS_BIGENDIAN) + +set(STDC_HEADERS 1) + +if (GIF_FOUND) + set(HAVE_LIBGIF 1) +endif() + +if (JPEG_FOUND) + set(HAVE_LIBJPEG 1) +endif() + +if (PNG_FOUND) + set(HAVE_LIBPNG 1) +endif() + +if (TIFF_FOUND) + set(HAVE_LIBTIFF 1) +endif() + +if (ZLIB_FOUND) + set(HAVE_LIBZ 1) +endif() + +file(APPEND ${AUTOCONFIG_SRC} " +/* Define to 1 if you have the ANSI C header files. */ +#cmakedefine STDC_HEADERS 1 + +/* Define to 1 if you have giflib. */ +#cmakedefine HAVE_LIBGIF 1 + +/* Define to 1 if you have libopenjp2. */ +#cmakedefine HAVE_LIBJP2K 1 + +/* Define to 1 if you have jpeg. */ +#cmakedefine HAVE_LIBJPEG 1 + +/* Define to 1 if you have libpng. */ +#cmakedefine HAVE_LIBPNG 1 + +/* Define to 1 if you have libtiff. */ +#cmakedefine HAVE_LIBTIFF 1 + +/* Define to 1 if you have libwebp. */ +#cmakedefine HAVE_LIBWEBP 1 + +/* Define to 1 if you have zlib. */ +#cmakedefine HAVE_LIBZ 1 + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#cmakedefine WORDS_BIGENDIAN 1 +") + +######################################## + +################################################################################ diff --git a/cmake/templates/TesseractConfig-version.cmake.in b/cmake/templates/TesseractConfig-version.cmake.in new file mode 100644 index 000000000..d3f85dffc --- /dev/null +++ b/cmake/templates/TesseractConfig-version.cmake.in @@ -0,0 +1,14 @@ +set(Tesseract_VERSION @VERSION_PLAIN@) +set(PACKAGE_VERSION ${Tesseract_VERSION}) + +set(PACKAGE_VERSION_EXACT False) +set(PACKAGE_VERSION_COMPATIBLE False) + +if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT True) + set(PACKAGE_VERSION_COMPATIBLE True) +endif() + +if(PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION) + set(PACKAGE_VERSION_COMPATIBLE True) +endif() diff --git a/cmake/templates/TesseractConfig.cmake.in b/cmake/templates/TesseractConfig.cmake.in new file mode 100644 index 000000000..f760c13f1 --- /dev/null +++ b/cmake/templates/TesseractConfig.cmake.in @@ -0,0 +1,43 @@ +# =================================================================================== +# The Tesseract CMake configuration file +# +# ** File generated automatically, do not modify ** +# +# Usage from an external project: +# In your CMakeLists.txt, add these lines: +# +# find_package(Tesseract REQUIRED) +# include_directories(${Tesseract_INCLUDE_DIRS}) +# target_link_libraries(MY_TARGET_NAME ${Tesseract_LIBRARIES}) +# +# This file will define the following variables: +# - Tesseract_LIBRARIES : The list of all imported targets for OpenCV modules. +# - Tesseract_INCLUDE_DIRS : The Tesseract include directories. +# - Tesseract_VERSION : The version of this Tesseract build: "@VERSION_PLAIN@" +# - Tesseract_VERSION_MAJOR : Major version part of Tesseract_VERSION: "@VERSION_MAJOR@" +# - Tesseract_VERSION_MINOR : Minor version part of Tesseract_VERSION: "@VERSION_MINOR@" +# +# =================================================================================== + +include(${CMAKE_CURRENT_LIST_DIR}/TesseractTargets.cmake) + +# ====================================================== +# Version variables: +# ====================================================== + +SET(Tesseract_VERSION @VERSION_PLAIN@) +SET(Tesseract_VERSION_MAJOR @VERSION_MAJOR@) +SET(Tesseract_VERSION_MINOR @VERSION_MINOR@) + +# ====================================================== +# Include directories to add to the user project: +# ====================================================== + +# Provide the include directories to the caller +set(Tesseract_INCLUDE_DIRS @INCLUDE_DIR@) + +# ==================================================================== +# Link libraries: +# ==================================================================== + +set(Tesseract_LIBRARIES tesseract) From 5e3b8d33e39de5036fb975a0c40b26f56341fbc3 Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Sun, 6 Sep 2015 13:47:30 +0300 Subject: [PATCH 02/26] Add source groups. --- CMakeLists.txt | 109 +++++++++++++----------------- cmake/BuildFunctions.cmake | 14 ++++ cmake/SourceGroups.cmake | 29 ++++++++ training/CMakeLists.txt | 132 +++++++++++++++++++++++++++++++++++++ 4 files changed, 219 insertions(+), 65 deletions(-) create mode 100644 cmake/BuildFunctions.cmake create mode 100644 cmake/SourceGroups.cmake create mode 100644 training/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index d28cacacd..f8b885619 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,28 +95,16 @@ configure_file( # ############################################################################### -######################################## -# FUNCTION build_dir -######################################## -function(build_dir target_name) - if (${ARGC} GREATER 1) - set(dir ${ARGV1}) - else() - set(dir ${target_name}) - endif() - file(GLOB ${dir}_src "${dir}/*.cpp") - file(GLOB ${dir}_hdr "${dir}/*.h") - add_library(${target_name} ${${dir}_src} ${${dir}_hdr}) -endfunction(build_dir) -######################################## +include(BuildFunctions) +include(SourceGroups) add_definitions(-D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1) add_definitions(-DUSE_STD_NAMESPACE=1) add_definitions(-DWINDLLNAME="libtesseract${VERSION_MAJOR}${VERSION_MINOR}.dll") -add_definitions(-DTESS_EXPORTS) include_directories(${Leptonica_INCLUDE_DIRS}) +include_directories(api) include_directories(ccmain) include_directories(ccstruct) include_directories(ccutil) @@ -132,65 +120,52 @@ include_directories(viewer) include_directories(wordrec) ######################################## -# LIBRARY api +# LIBRARY tesseract ######################################## -set(api_src + +file(GLOB tesseract_src + "ccmain/*.cpp" + "ccstruct/*.cpp" + "ccutil/*.cpp" + "classify/*.cpp" + "cube/*.cpp" + "cutil/*.cpp" + "dict/*.cpp" + "neural_networks/runtime/*.cpp" + "opencl/*.cpp" + "textord/*.cpp" + "viewer/*.cpp" + "vs2010/port/*.cpp" + "wordrec/*.cpp" +) +file(GLOB tesseract_hdr + "api/*.h" + "ccmain/*.h" + "ccstruct/*.h" + "ccutil/*.h" + "classify/*.h" + "cube/*.h" + "cutil/*.h" + "dict/*.h" + "neural_networks/runtime/*.h" + "opencl/*.h" + "textord/*.h" + "viewer/*.h" + "vs2010/port/*.h" + "wordrec/*.h" +) + +set(tesseract_src ${tesseract_src} api/baseapi.cpp api/capi.cpp api/renderer.cpp api/pdfrenderer.cpp ) -file(GLOB api_hdr "api/*.h") -add_library(api ${api_src} ${api_hdr}) - - -######################################## - -######################################## -# LIBRARIES tesseract -######################################## - -build_dir(main ccmain) -build_dir(struct ccstruct) -build_dir(ccutil) -build_dir(classify) -build_dir(cube) -build_dir(cutil) -build_dir(dict) -build_dir(neural neural_networks/runtime) -build_dir(opencl) -build_dir(textord) -build_dir(viewer) -build_dir(port vs2010/port) -build_dir(wordrec) - - -######################################## -# LIBRARY tesseract -######################################## add_library (tesseract ${LIBRARY_TYPE} ${tesseract_src} ${tesseract_hdr}) -target_link_libraries (tesseract - PRIVATE - main - struct - ccutil - classify - cube - cutil - dict - neural - opencl - textord - viewer - port - wordrec - - PUBLIC - ${Leptonica_LIBRARIES} - Ws2_32 -) +target_compile_definitions (tesseract PUBLIC -DTESS_EXPORTS) +target_link_libraries (tesseract ${Leptonica_LIBRARIES} Ws2_32) set_target_properties (tesseract PROPERTIES OUTPUT_NAME libtesseract${VERSION_MAJOR}${VERSION_MINOR}) set_target_properties (tesseract PROPERTIES DEBUG_OUTPUT_NAME libtesseract${VERSION_MAJOR}${VERSION_MINOR}d) export(TARGETS tesseract FILE ${CMAKE_BINARY_DIR}/TesseractTargets.cmake) @@ -208,4 +183,8 @@ set(tesseractmain_src add_executable (tesseractmain ${tesseractmain_src}) target_link_libraries (tesseractmain tesseract) +######################################## + +add_subdirectory(training) + ############################################################################### diff --git a/cmake/BuildFunctions.cmake b/cmake/BuildFunctions.cmake new file mode 100644 index 000000000..eea5a396c --- /dev/null +++ b/cmake/BuildFunctions.cmake @@ -0,0 +1,14 @@ +################################################################################ +# +# macros and functions +# +################################################################################ + +######################################## +# FUNCTION project_group +######################################## +function(project_group target name) + set_target_properties(${target} PROPERTIES FOLDER ${name}) +endfunction(project_group) + +################################################################################ diff --git a/cmake/SourceGroups.cmake b/cmake/SourceGroups.cmake new file mode 100644 index 000000000..ca87e808d --- /dev/null +++ b/cmake/SourceGroups.cmake @@ -0,0 +1,29 @@ +#include(SourceGroups) + +set(SSRC ${CMAKE_SOURCE_DIR}) +set(BSRC ${CMAKE_BINARY_DIR}) + +set(_CPP ".*\\.cpp") +set(CPP "${_CPP}$") + +set(_H ".*\\.h") +set(H "${_H}$") + +set(H_CPP "(${H}|${CPP})") + +source_group("Resource files" ".*\\.(rc|ico)") + +source_group("api" "${SSRC}/api/${H_CPP}") +source_group("ccmain" "${SSRC}/ccmain/${H_CPP}") +source_group("ccstruct" "${SSRC}/ccstruct/${H_CPP}") +source_group("ccutil" "${SSRC}/ccutil/${H_CPP}") +source_group("classify" "${SSRC}/classify/${H_CPP}") +source_group("cube" "${SSRC}/cube/${H_CPP}") +source_group("cutil" "${SSRC}/cutil/${H_CPP}") +source_group("dict" "${SSRC}/dict/${H_CPP}") +source_group("neural" "${SSRC}/neural_networks/runtime/${H_CPP}") +source_group("opencl" "${SSRC}/opencl/${H_CPP}") +source_group("textord" "${SSRC}/textord/${H_CPP}") +source_group("viewer" "${SSRC}/viewer/${H_CPP}") +source_group("port" "${SSRC}/vs2010/port/${H_CPP}") +source_group("wordrec" "${SSRC}/wordrec/${H_CPP}") diff --git a/training/CMakeLists.txt b/training/CMakeLists.txt new file mode 100644 index 000000000..8a2b1faa7 --- /dev/null +++ b/training/CMakeLists.txt @@ -0,0 +1,132 @@ +# +# tesseract +# + +######################################## +# LIBRARY tessopt +######################################## + +add_library (tessopt tessopt.cpp tessopt.h) +project_group (tessopt "Training Tools") + + +######################################## +# LIBRARY training +######################################## + +set(training_src + boxchar.cpp commandlineflags.cpp commontraining.cpp degradeimage.cpp + fileio.cpp ligature_table.cpp normstrngs.cpp pango_font_info.cpp + stringrenderer.cpp tlog.cpp unicharset_training_utils.cpp +) +set(training_hdr + boxchar.h commandlineflags.h commontraining.h degradeimage.h + fileio.h icuerrorcode.h ligature_table.h normstrngs.h + mergenf.h pango_font_info.h stringrenderer.h + tessopt.h tlog.h unicharset_training_utils.h util.h +) +add_library (training ${training_src} ${training_hdr}) +#target_link_libraries (training port) +project_group (training "Training Tools") + + +######################################## +# EXECUTABLE ambiguous_words +######################################## + +add_executable (ambiguous_words ambiguous_words.cpp) +target_link_libraries (ambiguous_words tesseract training tessopt) +project_group (ambiguous_words "Training Tools") + + +######################################## +# EXECUTABLE classifier_tester +######################################## + +add_executable (classifier_tester classifier_tester.cpp) +target_link_libraries (classifier_tester tesseract training tessopt) +project_group (classifier_tester "Training Tools") + + +######################################## +# EXECUTABLE combine_tessdata +######################################## + +add_executable (combine_tessdata combine_tessdata.cpp) +target_link_libraries (combine_tessdata tesseract) +project_group (combine_tessdata "Training Tools") + + +######################################## +# EXECUTABLE cntraining +######################################## + +add_executable (cntraining cntraining.cpp) +target_link_libraries (cntraining tesseract training tessopt) +project_group (cntraining "Training Tools") + + +######################################## +# EXECUTABLE dawg2wordlist +######################################## + +add_executable (dawg2wordlist dawg2wordlist.cpp) +target_link_libraries (dawg2wordlist tesseract training tessopt) +project_group (dawg2wordlist "Training Tools") + + +######################################## +# EXECUTABLE mftraining +######################################## + +add_executable (mftraining mftraining.cpp mergenf.cpp) +target_link_libraries (mftraining tesseract training tessopt) +project_group (mftraining "Training Tools") + + +######################################## +# EXECUTABLE set_unicharset_properties +######################################## + +add_executable (set_unicharset_properties set_unicharset_properties.cpp) +target_link_libraries (set_unicharset_properties tesseract training tessopt) +project_group (set_unicharset_properties "Training Tools") + + +######################################## +# EXECUTABLE shapeclustering +######################################## + +add_executable (shapeclustering shapeclustering.cpp) +target_link_libraries (shapeclustering tesseract training tessopt) +project_group (shapeclustering "Training Tools") + + +######################################## +# EXECUTABLE text2image +######################################## + +add_executable (text2image text2image.cpp) +target_link_libraries (text2image tesseract training tessopt) +project_group (text2image "Training Tools") + + +######################################## +# EXECUTABLE unicharset_extractor +######################################## + +add_executable (unicharset_extractor unicharset_extractor.cpp) +target_link_libraries (unicharset_extractor tesseract tessopt) +project_group (unicharset_extractor "Training Tools") + + +######################################## +# EXECUTABLE wordlist2dawg +######################################## + +add_executable (wordlist2dawg wordlist2dawg.cpp) +target_link_libraries (wordlist2dawg tesseract tessopt) +project_group (wordlist2dawg "Training Tools") + + +############################################################################### From 03531ba8a5bcb49eaeb9468e2b00d4cbc1829762 Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Sun, 6 Sep 2015 20:43:28 +0300 Subject: [PATCH 03/26] Fix linux build. --- CMakeLists.txt | 38 ++++- cmake/Configure.cmake | 90 ++++++------ cmake/FindICU.cmake | 314 ++++++++++++++++++++++++++++++++++++++++ training/CMakeLists.txt | 14 +- 4 files changed, 402 insertions(+), 54 deletions(-) create mode 100644 cmake/FindICU.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f8b885619..4acdb14ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,17 @@ set(VERSION_PLAIN ${VERSION_MAJOR}.${VERSION_MINOR}) find_package(Leptonica 1.72 REQUIRED) +find_package(ICU COMPONENTS uc i18n) +find_package(PkgConfig QUIET) +pkg_check_modules(Pango pango) +pkg_check_modules(Cairo cairo) +pkg_check_modules(PangoFt2 pangoft2) +pkg_check_modules(PangoCairo pangocairo) +pkg_check_modules(FontConfig fontconfig) + +include_directories(${Pango_INCLUDE_DIRS}) +include_directories(${Cairo_INCLUDE_DIRS}) + ############################################################################### # # compiler and linker @@ -65,6 +76,14 @@ if (WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0") endif() + + set(LIB_Ws2_32 Ws2_32) +endif() + +if (UNIX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11") + + set(LIB_pthread pthread) endif() ############################################################################### @@ -74,7 +93,7 @@ endif() ############################################################################### set(AUTOCONFIG_SRC ${CMAKE_BINARY_DIR}/config_auto.h.in) -set(AUTOCONFIG ${CMAKE_BINARY_DIR}/src/config_auto.h) +set(AUTOCONFIG ${CMAKE_BINARY_DIR}/config_auto.h) include(Configure) @@ -98,12 +117,15 @@ configure_file( include(BuildFunctions) include(SourceGroups) +add_definitions(-DHAVE_CONFIG_H) add_definitions(-D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1) add_definitions(-DUSE_STD_NAMESPACE=1) add_definitions(-DWINDLLNAME="libtesseract${VERSION_MAJOR}${VERSION_MINOR}.dll") include_directories(${Leptonica_INCLUDE_DIRS}) +include_directories(${CMAKE_BINARY_DIR}) + include_directories(api) include_directories(ccmain) include_directories(ccstruct) @@ -136,7 +158,6 @@ file(GLOB tesseract_src "opencl/*.cpp" "textord/*.cpp" "viewer/*.cpp" - "vs2010/port/*.cpp" "wordrec/*.cpp" ) file(GLOB tesseract_hdr @@ -152,9 +173,14 @@ file(GLOB tesseract_hdr "opencl/*.h" "textord/*.h" "viewer/*.h" - "vs2010/port/*.h" "wordrec/*.h" ) +if (WIN32) + file(GLOB tesseract_win32_src "vs2010/port/*.cpp") + file(GLOB tesseract_win32_hdr "vs2010/port/*.h") + set(tesseract_src ${tesseract_src} ${tesseract_win32_src}) + set(tesseract_hdr ${tesseract_hdr} ${tesseract_win32_hdr}) +endif() set(tesseract_src ${tesseract_src} api/baseapi.cpp @@ -165,9 +191,9 @@ set(tesseract_src ${tesseract_src} add_library (tesseract ${LIBRARY_TYPE} ${tesseract_src} ${tesseract_hdr}) target_compile_definitions (tesseract PUBLIC -DTESS_EXPORTS) -target_link_libraries (tesseract ${Leptonica_LIBRARIES} Ws2_32) -set_target_properties (tesseract PROPERTIES OUTPUT_NAME libtesseract${VERSION_MAJOR}${VERSION_MINOR}) -set_target_properties (tesseract PROPERTIES DEBUG_OUTPUT_NAME libtesseract${VERSION_MAJOR}${VERSION_MINOR}d) +target_link_libraries (tesseract ${Leptonica_LIBRARIES} ${LIB_Ws2_32} ${LIB_pthread}) +set_target_properties (tesseract PROPERTIES OUTPUT_NAME tesseract${VERSION_MAJOR}${VERSION_MINOR}) +set_target_properties (tesseract PROPERTIES DEBUG_OUTPUT_NAME tesseract${VERSION_MAJOR}${VERSION_MINOR}d) export(TARGETS tesseract FILE ${CMAKE_BINARY_DIR}/TesseractTargets.cmake) diff --git a/cmake/Configure.cmake b/cmake/Configure.cmake index 54a4ec293..37ea6a100 100644 --- a/cmake/Configure.cmake +++ b/cmake/Configure.cmake @@ -35,6 +35,24 @@ function(check_functions functions) endforeach() endfunction(check_functions) +######################################## +# FUNCTION check_types +######################################## +function(check_types types) + foreach(T ${${types}}) + set(name ${T}) + string(REPLACE " " "_" name ${name}) + string(REPLACE "-" "_" name ${name}) + string(REPLACE "." "_" name ${name}) + string(REPLACE "/" "_" name ${name}) + string(TOUPPER ${name} name) + check_type_size(${T} HAVE_${name}) + file(APPEND ${AUTOCONFIG_SRC} "/* Define to 1 if the system has the type `${T}'. */\n") + file(APPEND ${AUTOCONFIG_SRC} "#cmakedefine HAVE_${name} 1\n") + file(APPEND ${AUTOCONFIG_SRC} "\n") + endforeach() +endfunction(check_types) + ######################################## file(WRITE ${AUTOCONFIG_SRC}) @@ -55,78 +73,60 @@ include(TestBigEndian) set(include_files_list dlfcn.h inttypes.h + limits.h + malloc.h memory.h + stdbool.h stdint.h stdlib.h strings.h string.h + sys/ipc.h + sys/shm.h sys/stat.h sys/types.h + sys/wait.h + tiffio.h unistd.h - openjpeg-2.0/openjpeg.h - openjpeg-2.1/openjpeg.h - openjpeg-2.2/openjpeg.h + cairo/cairo-version.h + CL/cl.h + OpenCL/cl.h + pango-1.0/pango/pango-features.h + unicode/uchar.h ) check_includes(include_files_list) set(functions_list - fmemopen + getline + snprintf ) check_functions(functions_list) +set(types_list + "long long int" + mbstate_t + wchar_t + _Bool +) +check_types(types_list) + +check_c_source_compiles("#include \n#include \nmain(){}" TIME_WITH_SYS_TIME) + test_big_endian(WORDS_BIGENDIAN) set(STDC_HEADERS 1) -if (GIF_FOUND) - set(HAVE_LIBGIF 1) -endif() - -if (JPEG_FOUND) - set(HAVE_LIBJPEG 1) -endif() - -if (PNG_FOUND) - set(HAVE_LIBPNG 1) -endif() - -if (TIFF_FOUND) - set(HAVE_LIBTIFF 1) -endif() - -if (ZLIB_FOUND) - set(HAVE_LIBZ 1) -endif() - file(APPEND ${AUTOCONFIG_SRC} " /* Define to 1 if you have the ANSI C header files. */ #cmakedefine STDC_HEADERS 1 -/* Define to 1 if you have giflib. */ -#cmakedefine HAVE_LIBGIF 1 - -/* Define to 1 if you have libopenjp2. */ -#cmakedefine HAVE_LIBJP2K 1 - -/* Define to 1 if you have jpeg. */ -#cmakedefine HAVE_LIBJPEG 1 - -/* Define to 1 if you have libpng. */ -#cmakedefine HAVE_LIBPNG 1 - -/* Define to 1 if you have libtiff. */ -#cmakedefine HAVE_LIBTIFF 1 - -/* Define to 1 if you have libwebp. */ -#cmakedefine HAVE_LIBWEBP 1 - -/* Define to 1 if you have zlib. */ -#cmakedefine HAVE_LIBZ 1 - /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #cmakedefine WORDS_BIGENDIAN 1 + +/* Define to 1 if you can safely include both and . */ +#cmakedefine TIME_WITH_SYS_TIME 1 ") ######################################## diff --git a/cmake/FindICU.cmake b/cmake/FindICU.cmake new file mode 100644 index 000000000..cd6bf9265 --- /dev/null +++ b/cmake/FindICU.cmake @@ -0,0 +1,314 @@ +# This module can find the International Components for Unicode (ICU) Library +# +# Requirements: +# - CMake >= 2.8.3 (for new version of find_package_handle_standard_args) +# +# The following variables will be defined for your use: +# - ICU_FOUND : were all of your specified components found (include dependencies)? +# - ICU_INCLUDE_DIRS : ICU include directory +# - ICU_LIBRARIES : ICU libraries +# - ICU_VERSION : complete version of ICU (x.y.z) +# - ICU_MAJOR_VERSION : major version of ICU +# - ICU_MINOR_VERSION : minor version of ICU +# - ICU_PATCH_VERSION : patch version of ICU +# - ICU__FOUND : were found? (FALSE for non specified component if it is not a dependency) +# +# For windows or non standard installation, define ICU_ROOT variable to point to the root installation of ICU. Two ways: +# - run cmake with -DICU_ROOT= +# - define an environment variable with the same name before running cmake +# With cmake-gui, before pressing "Configure": +# 1) Press "Add Entry" button +# 2) Add a new entry defined as: +# - Name: ICU_ROOT +# - Type: choose PATH in the selection list +# - Press "..." button and select the root installation of ICU +# +# Example Usage: +# +# 1. Copy this file in the root of your project source directory +# 2. Then, tell CMake to search this non-standard module in your project directory by adding to your CMakeLists.txt: +# set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) +# 3. Finally call find_package() once, here are some examples to pick from +# +# Require ICU 4.4 or later +# find_package(ICU 4.4 REQUIRED) +# +# if(ICU_FOUND) +# include_directories(${ICU_INCLUDE_DIRS}) +# add_executable(myapp myapp.c) +# target_link_libraries(myapp ${ICU_LIBRARIES}) +# endif(ICU_FOUND) + +#============================================================================= +# Copyright (c) 2011-2013, julp +# +# Distributed under the OSI-approved BSD License +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +#============================================================================= + +find_package(PkgConfig QUIET) + +########## Private ########## +if(NOT DEFINED ICU_PUBLIC_VAR_NS) + set(ICU_PUBLIC_VAR_NS "ICU") # Prefix for all ICU relative public variables +endif(NOT DEFINED ICU_PUBLIC_VAR_NS) +if(NOT DEFINED ICU_PRIVATE_VAR_NS) + set(ICU_PRIVATE_VAR_NS "_${ICU_PUBLIC_VAR_NS}") # Prefix for all ICU relative internal variables +endif(NOT DEFINED ICU_PRIVATE_VAR_NS) +if(NOT DEFINED PC_ICU_PRIVATE_VAR_NS) + set(PC_ICU_PRIVATE_VAR_NS "_PC${ICU_PRIVATE_VAR_NS}") # Prefix for all pkg-config relative internal variables +endif(NOT DEFINED PC_ICU_PRIVATE_VAR_NS) + +function(icudebug _VARNAME) + if(${ICU_PUBLIC_VAR_NS}_DEBUG) + if(DEFINED ${ICU_PUBLIC_VAR_NS}_${_VARNAME}) + message("${ICU_PUBLIC_VAR_NS}_${_VARNAME} = ${${ICU_PUBLIC_VAR_NS}_${_VARNAME}}") + else(DEFINED ${ICU_PUBLIC_VAR_NS}_${_VARNAME}) + message("${ICU_PUBLIC_VAR_NS}_${_VARNAME} = ") + endif(DEFINED ${ICU_PUBLIC_VAR_NS}_${_VARNAME}) + endif(${ICU_PUBLIC_VAR_NS}_DEBUG) +endfunction(icudebug) + +set(${ICU_PRIVATE_VAR_NS}_ROOT "") +if(DEFINED ENV{ICU_ROOT}) + set(${ICU_PRIVATE_VAR_NS}_ROOT "$ENV{ICU_ROOT}") +endif(DEFINED ENV{ICU_ROOT}) +if (DEFINED ICU_ROOT) + set(${ICU_PRIVATE_VAR_NS}_ROOT "${ICU_ROOT}") +endif(DEFINED ICU_ROOT) + +set(${ICU_PRIVATE_VAR_NS}_BIN_SUFFIXES ) +set(${ICU_PRIVATE_VAR_NS}_LIB_SUFFIXES ) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + list(APPEND ${ICU_PRIVATE_VAR_NS}_BIN_SUFFIXES "bin64") + list(APPEND ${ICU_PRIVATE_VAR_NS}_LIB_SUFFIXES "lib64") +endif(CMAKE_SIZEOF_VOID_P EQUAL 8) +list(APPEND ${ICU_PRIVATE_VAR_NS}_BIN_SUFFIXES "bin") +list(APPEND ${ICU_PRIVATE_VAR_NS}_LIB_SUFFIXES "lib") + +set(${ICU_PRIVATE_VAR_NS}_COMPONENTS ) +# ... +macro(icu_declare_component _NAME) + list(APPEND ${ICU_PRIVATE_VAR_NS}_COMPONENTS ${_NAME}) + set("${ICU_PRIVATE_VAR_NS}_COMPONENTS_${_NAME}" ${ARGN}) +endmacro(icu_declare_component) + +icu_declare_component(data icudata) +icu_declare_component(uc icuuc) # Common and Data libraries +icu_declare_component(i18n icui18n icuin) # Internationalization library +icu_declare_component(io icuio ustdio) # Stream and I/O Library +icu_declare_component(le icule) # Layout library +icu_declare_component(lx iculx) # Paragraph Layout library + +########## Public ########## +set(${ICU_PUBLIC_VAR_NS}_FOUND TRUE) +set(${ICU_PUBLIC_VAR_NS}_LIBRARIES ) +set(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS ) +set(${ICU_PUBLIC_VAR_NS}_C_FLAGS "") +set(${ICU_PUBLIC_VAR_NS}_CXX_FLAGS "") +set(${ICU_PUBLIC_VAR_NS}_CPP_FLAGS "") +set(${ICU_PUBLIC_VAR_NS}_C_SHARED_FLAGS "") +set(${ICU_PUBLIC_VAR_NS}_CXX_SHARED_FLAGS "") +set(${ICU_PUBLIC_VAR_NS}_CPP_SHARED_FLAGS "") +foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PRIVATE_VAR_NS}_COMPONENTS}) + string(TOUPPER "${${ICU_PRIVATE_VAR_NS}_COMPONENT}" ${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT) + set("${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_FOUND" FALSE) # may be done in the icu_declare_component macro +endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT) + +# Check components +if(NOT ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS) # uc required at least + set(${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS uc) +else(NOT ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS) + list(APPEND ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS uc) + list(REMOVE_DUPLICATES ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS) + foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS}) + if(NOT DEFINED ${ICU_PRIVATE_VAR_NS}_COMPONENTS_${${ICU_PRIVATE_VAR_NS}_COMPONENT}) + message(FATAL_ERROR "Unknown ICU component: ${${ICU_PRIVATE_VAR_NS}_COMPONENT}") + endif(NOT DEFINED ${ICU_PRIVATE_VAR_NS}_COMPONENTS_${${ICU_PRIVATE_VAR_NS}_COMPONENT}) + endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT) +endif(NOT ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS) + +# Includes +find_path( + ${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS + NAMES unicode/utypes.h utypes.h + HINTS ${${ICU_PRIVATE_VAR_NS}_ROOT} + PATH_SUFFIXES "include" + DOC "Include directories for ICU" +) + +if(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS) + ########## ########## + if(EXISTS "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/uvernum.h") # ICU >= 4 + file(READ "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/uvernum.h" ${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS) + elseif(EXISTS "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/uversion.h") # ICU [2;4[ + file(READ "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/uversion.h" ${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS) + elseif(EXISTS "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/utypes.h") # ICU [1.4;2[ + file(READ "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/unicode/utypes.h" ${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS) + elseif(EXISTS "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/utypes.h") # ICU 1.3 + file(READ "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS}/utypes.h" ${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS) + else() + message(FATAL_ERROR "ICU version header not found") + endif() + + if(${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS MATCHES ".*# *define *ICU_VERSION *\"([0-9]+)\".*") # ICU 1.3 + # [1.3;1.4[ as #define ICU_VERSION "3" (no patch version, ie all 1.3.X versions will be detected as 1.3.0) + set(${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION "1") + set(${ICU_PUBLIC_VAR_NS}_MINOR_VERSION "${CMAKE_MATCH_1}") + set(${ICU_PUBLIC_VAR_NS}_PATCH_VERSION "0") + elseif(${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS MATCHES ".*# *define *U_ICU_VERSION_MAJOR_NUM *([0-9]+).*") + # + # Since version 4.9.1, ICU release version numbering was totaly changed, see: + # - http://site.icu-project.org/download/49 + # - http://userguide.icu-project.org/design#TOC-Version-Numbers-in-ICU + # + set(${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION "${CMAKE_MATCH_1}") + string(REGEX REPLACE ".*# *define *U_ICU_VERSION_MINOR_NUM *([0-9]+).*" "\\1" ${ICU_PUBLIC_VAR_NS}_MINOR_VERSION "${${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS}") + string(REGEX REPLACE ".*# *define *U_ICU_VERSION_PATCHLEVEL_NUM *([0-9]+).*" "\\1" ${ICU_PUBLIC_VAR_NS}_PATCH_VERSION "${${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS}") + elseif(${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS MATCHES ".*# *define *U_ICU_VERSION *\"(([0-9]+)(\\.[0-9]+)*)\".*") # ICU [1.4;1.8[ + # [1.4;1.8[ as #define U_ICU_VERSION "1.4.1.2" but it seems that some 1.4.1(?:\.\d)? have releasing error and appears as 1.4.0 + set(${ICU_PRIVATE_VAR_NS}_FULL_VERSION "${CMAKE_MATCH_1}") # copy CMAKE_MATCH_1, no longer valid on the following if + if(${ICU_PRIVATE_VAR_NS}_FULL_VERSION MATCHES "^([0-9]+)\\.([0-9]+)$") + set(${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION "${CMAKE_MATCH_1}") + set(${ICU_PUBLIC_VAR_NS}_MINOR_VERSION "${CMAKE_MATCH_2}") + set(${ICU_PUBLIC_VAR_NS}_PATCH_VERSION "0") + elseif(${ICU_PRIVATE_VAR_NS}_FULL_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)") + set(${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION "${CMAKE_MATCH_1}") + set(${ICU_PUBLIC_VAR_NS}_MINOR_VERSION "${CMAKE_MATCH_2}") + set(${ICU_PUBLIC_VAR_NS}_PATCH_VERSION "${CMAKE_MATCH_3}") + endif() + else() + message(FATAL_ERROR "failed to detect ICU version") + endif() + set(${ICU_PUBLIC_VAR_NS}_VERSION "${${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION}.${${ICU_PUBLIC_VAR_NS}_MINOR_VERSION}.${${ICU_PUBLIC_VAR_NS}_PATCH_VERSION}") + ########## ########## + + # Check dependencies (implies pkg-config) + if(PKG_CONFIG_FOUND) + set(${ICU_PRIVATE_VAR_NS}_COMPONENTS_DUP ${${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS}) + foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PRIVATE_VAR_NS}_COMPONENTS_DUP}) + pkg_check_modules(PC_ICU_PRIVATE_VAR_NS "icu-${${ICU_PRIVATE_VAR_NS}_COMPONENT}" QUIET) + + if(${PC_ICU_PRIVATE_VAR_NS}_FOUND) + foreach(${PC_ICU_PRIVATE_VAR_NS}_LIBRARY ${PC_ICU_LIBRARIES}) + string(REGEX REPLACE "^icu" "" ${PC_ICU_PRIVATE_VAR_NS}_STRIPPED_LIBRARY ${${PC_ICU_PRIVATE_VAR_NS}_LIBRARY}) + list(APPEND ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS ${${PC_ICU_PRIVATE_VAR_NS}_STRIPPED_LIBRARY}) + endforeach(${PC_ICU_PRIVATE_VAR_NS}_LIBRARY) + endif(${PC_ICU_PRIVATE_VAR_NS}_FOUND) + endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT) + list(REMOVE_DUPLICATES ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS) + endif(PKG_CONFIG_FOUND) + + # Check libraries + foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS}) + set(${ICU_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES ) + set(${ICU_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES ) + foreach(${ICU_PRIVATE_VAR_NS}_BASE_NAME ${${ICU_PRIVATE_VAR_NS}_COMPONENTS_${${ICU_PRIVATE_VAR_NS}_COMPONENT}}) + list(APPEND ${ICU_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES "${${ICU_PRIVATE_VAR_NS}_BASE_NAME}") + list(APPEND ${ICU_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES "${${ICU_PRIVATE_VAR_NS}_BASE_NAME}d") + list(APPEND ${ICU_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES "${${ICU_PRIVATE_VAR_NS}_BASE_NAME}${ICU_MAJOR_VERSION}${ICU_MINOR_VERSION}") + list(APPEND ${ICU_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES "${${ICU_PRIVATE_VAR_NS}_BASE_NAME}${ICU_MAJOR_VERSION}${ICU_MINOR_VERSION}d") + endforeach(${ICU_PRIVATE_VAR_NS}_BASE_NAME) + + find_library( + ${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT} + NAMES ${${ICU_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES} + HINTS ${${ICU_PRIVATE_VAR_NS}_ROOT} + PATH_SUFFIXES ${_ICU_LIB_SUFFIXES} + DOC "Release libraries for ICU" + ) + find_library( + ${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT} + NAMES ${${ICU_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES} + HINTS ${${ICU_PRIVATE_VAR_NS}_ROOT} + PATH_SUFFIXES ${_ICU_LIB_SUFFIXES} + DOC "Debug libraries for ICU" + ) + + string(TOUPPER "${${ICU_PRIVATE_VAR_NS}_COMPONENT}" ${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT) + if(NOT ${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT} AND NOT ${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}) # both not found + set("${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_FOUND" FALSE) + set("${ICU_PUBLIC_VAR_NS}_FOUND" FALSE) + else(NOT ${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT} AND NOT ${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}) # one or both found + set("${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_FOUND" TRUE) + if(NOT ${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT}) # release not found => we are in debug + set(${ICU_PRIVATE_VAR_NS}_LIB_${${ICU_PRIVATE_VAR_NS}_COMPONENT} "${${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}}") + elseif(NOT ${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}) # debug not found => we are in release + set(${ICU_PRIVATE_VAR_NS}_LIB_${${ICU_PRIVATE_VAR_NS}_COMPONENT} "${${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT}}") + else() # both found + set( + ${ICU_PRIVATE_VAR_NS}_LIB_${${ICU_PRIVATE_VAR_NS}_COMPONENT} + optimized ${${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT}} + debug ${${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}} + ) + endif() + list(APPEND ${ICU_PUBLIC_VAR_NS}_LIBRARIES ${${ICU_PRIVATE_VAR_NS}_LIB_${${ICU_PRIVATE_VAR_NS}_COMPONENT}}) + endif(NOT ${ICU_PRIVATE_VAR_NS}_LIB_RELEASE_${${ICU_PRIVATE_VAR_NS}_COMPONENT} AND NOT ${ICU_PRIVATE_VAR_NS}_LIB_DEBUG_${${ICU_PRIVATE_VAR_NS}_COMPONENT}) + endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT) + + # Try to find out compiler flags + find_program(${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE icu-config HINTS ${${ICU_PRIVATE_VAR_NS}_ROOT}) + if(${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE) + execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cflags OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_C_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cxxflags OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_CXX_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cppflags OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_CPP_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cflags-dynamic OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_C_SHARED_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cxxflags-dynamic OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_CXX_SHARED_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cppflags-dynamic OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_CPP_SHARED_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) + endif(${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE) + + # Check find_package arguments + include(FindPackageHandleStandardArgs) + if(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY) + find_package_handle_standard_args( + ${ICU_PUBLIC_VAR_NS} + REQUIRED_VARS ${ICU_PUBLIC_VAR_NS}_LIBRARIES ${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS + VERSION_VAR ${ICU_PUBLIC_VAR_NS}_VERSION + ) + else(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY) + find_package_handle_standard_args(${ICU_PUBLIC_VAR_NS} "ICU not found" ${ICU_PUBLIC_VAR_NS}_LIBRARIES ${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS) + endif(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY) +else(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS) + set("${ICU_PUBLIC_VAR_NS}_FOUND" FALSE) + if(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY) + message(FATAL_ERROR "Could not find ICU include directory") + endif(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY) +endif(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS) + +mark_as_advanced( + ${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS + ${ICU_PUBLIC_VAR_NS}_LIBRARIES +) + +# IN (args) +icudebug("FIND_COMPONENTS") +icudebug("FIND_REQUIRED") +icudebug("FIND_QUIETLY") +icudebug("FIND_VERSION") +# OUT +# Found +icudebug("FOUND") +icudebug("UC_FOUND") +icudebug("I18N_FOUND") +icudebug("IO_FOUND") +icudebug("LE_FOUND") +icudebug("LX_FOUND") +icudebug("DATA_FOUND") +# Flags +icudebug("C_FLAGS") +icudebug("CPP_FLAGS") +icudebug("CXX_FLAGS") +icudebug("C_SHARED_FLAGS") +icudebug("CPP_SHARED_FLAGS") +icudebug("CXX_SHARED_FLAGS") +# Linking +icudebug("INCLUDE_DIRS") +icudebug("LIBRARIES") +# Version +icudebug("MAJOR_VERSION") +icudebug("MINOR_VERSION") +icudebug("PATCH_VERSION") +icudebug("VERSION") diff --git a/training/CMakeLists.txt b/training/CMakeLists.txt index 8a2b1faa7..f8d56f54f 100644 --- a/training/CMakeLists.txt +++ b/training/CMakeLists.txt @@ -2,6 +2,8 @@ # tesseract # +add_definitions(-DPANGO_ENABLE_ENGINE) + ######################################## # LIBRARY tessopt ######################################## @@ -26,7 +28,6 @@ set(training_hdr tessopt.h tlog.h unicharset_training_utils.h util.h ) add_library (training ${training_src} ${training_hdr}) -#target_link_libraries (training port) project_group (training "Training Tools") @@ -89,7 +90,7 @@ project_group (mftraining "Training Tools") ######################################## add_executable (set_unicharset_properties set_unicharset_properties.cpp) -target_link_libraries (set_unicharset_properties tesseract training tessopt) +target_link_libraries (set_unicharset_properties tesseract training tessopt ${ICU_LIBRARIES}) project_group (set_unicharset_properties "Training Tools") @@ -107,7 +108,14 @@ project_group (shapeclustering "Training Tools") ######################################## add_executable (text2image text2image.cpp) -target_link_libraries (text2image tesseract training tessopt) +target_link_libraries (text2image tesseract training tessopt + ${ICU_LIBRARIES} + ${Pango_LIBRARIES} + ${Cairo_LIBRARIES} + ${PangoCairo_LIBRARIES} + ${PangoFt2_LIBRARIES} + ${FontConfig_LIBRARIES} +) project_group (text2image "Training Tools") From 0f651c187b67df984d71d5ec1ceda41d05fee6d0 Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Sun, 6 Sep 2015 20:54:05 +0300 Subject: [PATCH 04/26] Add .travis.yml. --- .travis.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..e5426f084 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,27 @@ +language: cpp + +notifications: + email: false + +sudo: required + +os: + - linux + - osx + +branches: + only: + - master + +install: + - wget http://www.cmake.org/files/v3.3/cmake-3.3.1-Linux-x86_64.sh + - sudo sh cmake-3.3.1-Linux-x86_64.sh --skip-license --prefix=/usr + - wget -O leptonica.zip https://github.com/egorpugin/leptonica/archive/master.zip + - unzip leptonica.zip -d . + - cmake -Hleptonica-master -Bleptonica-master/build + +script: + - mkdir build + - cd build + - cmake .. -DLeptonica_DIR=leptonica-master/build + - make From 707888a5821e343b0893b465404a55dc32c6f4ea Mon Sep 17 00:00:00 2001 From: egorpugin Date: Sun, 6 Sep 2015 20:55:05 +0300 Subject: [PATCH 05/26] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b93297439..2f5569bf0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/egorpugin/tesseract.svg?branch=master)](https://travis-ci.org/egorpugin/tesseract) + Note that this is possibly out-of-date version of the wiki ReadMe, which is located at: From e67372c8498f736770203880a82b6094a9b1dbc2 Mon Sep 17 00:00:00 2001 From: egorpugin Date: Sun, 6 Sep 2015 20:59:04 +0300 Subject: [PATCH 06/26] Update .travis.yml --- .travis.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.travis.yml b/.travis.yml index e5426f084..ca3494c52 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,12 +13,22 @@ branches: only: - master +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-4.8 + - g++-4.8 + install: - wget http://www.cmake.org/files/v3.3/cmake-3.3.1-Linux-x86_64.sh - sudo sh cmake-3.3.1-Linux-x86_64.sh --skip-license --prefix=/usr - wget -O leptonica.zip https://github.com/egorpugin/leptonica/archive/master.zip - unzip leptonica.zip -d . - cmake -Hleptonica-master -Bleptonica-master/build + - make -C leptonica-master/build + - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi script: - mkdir build From f9f85b88d0d5ec5697826eff196694f816316186 Mon Sep 17 00:00:00 2001 From: egorpugin Date: Sun, 6 Sep 2015 21:05:05 +0300 Subject: [PATCH 07/26] Update CMakeLists.txt --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4acdb14ca..bb0f848ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,7 @@ pkg_check_modules(PangoFt2 pangoft2) pkg_check_modules(PangoCairo pangocairo) pkg_check_modules(FontConfig fontconfig) +include_directories(${ICU_INCLUDE_DIRS}) include_directories(${Pango_INCLUDE_DIRS}) include_directories(${Cairo_INCLUDE_DIRS}) From d7059e13fd4202553f5ebd7523558cf330d96cfc Mon Sep 17 00:00:00 2001 From: egorpugin Date: Sun, 6 Sep 2015 21:15:04 +0300 Subject: [PATCH 08/26] Update .travis.yml --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index ca3494c52..997353ae2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,11 @@ addons: - gcc-4.8 - g++-4.8 +before_install: + - if [[ $OSX ]]; then brew update; fi + install: + - if [[ $OSX ]]; then brew install icu4c; fi - wget http://www.cmake.org/files/v3.3/cmake-3.3.1-Linux-x86_64.sh - sudo sh cmake-3.3.1-Linux-x86_64.sh --skip-license --prefix=/usr - wget -O leptonica.zip https://github.com/egorpugin/leptonica/archive/master.zip From df2309727da3cceb7ab1246741b57b413bc555fc Mon Sep 17 00:00:00 2001 From: egorpugin Date: Sun, 6 Sep 2015 21:21:53 +0300 Subject: [PATCH 09/26] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 997353ae2..b58c83a20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,7 @@ addons: - g++-4.8 before_install: + - if [[ $TRAVIS_OS_NAME == osx ]]; then OSX=true; fi - if [[ $OSX ]]; then brew update; fi install: From e5fad6432e356a5a7fc9d96a366a2dfba269e1a1 Mon Sep 17 00:00:00 2001 From: egorpugin Date: Sun, 6 Sep 2015 21:36:47 +0300 Subject: [PATCH 10/26] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b58c83a20..5cd018e8b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,7 @@ before_install: install: - if [[ $OSX ]]; then brew install icu4c; fi + - if [[ $OSX ]]; then export ICU_ROOT=/usr/local/opt/icu4c ; fi - wget http://www.cmake.org/files/v3.3/cmake-3.3.1-Linux-x86_64.sh - sudo sh cmake-3.3.1-Linux-x86_64.sh --skip-license --prefix=/usr - wget -O leptonica.zip https://github.com/egorpugin/leptonica/archive/master.zip From 8d8636a1fc878c61f7bdee5397ca0638124ed6df Mon Sep 17 00:00:00 2001 From: egorpugin Date: Sun, 6 Sep 2015 21:42:47 +0300 Subject: [PATCH 11/26] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb0f848ab..8565cf295 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,7 @@ set(VERSION_PLAIN ${VERSION_MAJOR}.${VERSION_MINOR}) find_package(Leptonica 1.72 REQUIRED) find_package(ICU COMPONENTS uc i18n) -find_package(PkgConfig QUIET) +find_package(PkgConfig) pkg_check_modules(Pango pango) pkg_check_modules(Cairo cairo) pkg_check_modules(PangoFt2 pangoft2) From c3198df3681dc96f6b102555d1b89c6a2335e7c4 Mon Sep 17 00:00:00 2001 From: egorpugin Date: Sun, 6 Sep 2015 21:52:42 +0300 Subject: [PATCH 12/26] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5cd018e8b..f7ffa5bf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ before_install: - if [[ $OSX ]]; then brew update; fi install: - - if [[ $OSX ]]; then brew install icu4c; fi + - if [[ $OSX ]]; then brew install icu4c pango ; fi - if [[ $OSX ]]; then export ICU_ROOT=/usr/local/opt/icu4c ; fi - wget http://www.cmake.org/files/v3.3/cmake-3.3.1-Linux-x86_64.sh - sudo sh cmake-3.3.1-Linux-x86_64.sh --skip-license --prefix=/usr From a65f2da409bdb38ca7be17459b7801f703fb47df Mon Sep 17 00:00:00 2001 From: egorpugin Date: Sun, 6 Sep 2015 21:58:49 +0300 Subject: [PATCH 13/26] Update .travis.yml --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f7ffa5bf3..3e6639a2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,9 @@ addons: - g++-4.8 before_install: - - if [[ $TRAVIS_OS_NAME == osx ]]; then OSX=true; fi + - if [[ $TRAVIS_OS_NAME == linux ]]; then LINUX=true; fi + - if [[ $TRAVIS_OS_NAME == osx ]]; then OSX=true; fi + - if [[ $OSX ]]; then brew update; fi install: @@ -34,7 +36,7 @@ install: - unzip leptonica.zip -d . - cmake -Hleptonica-master -Bleptonica-master/build - make -C leptonica-master/build - - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi + - if [ $LINUX && "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi script: - mkdir build From 57947cd053b45843d36cf6c1c758f6752935c2e2 Mon Sep 17 00:00:00 2001 From: egorpugin Date: Sun, 6 Sep 2015 22:05:54 +0300 Subject: [PATCH 14/26] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3e6639a2c..d4073819d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ before_install: - if [[ $OSX ]]; then brew update; fi install: - - if [[ $OSX ]]; then brew install icu4c pango ; fi + - if [[ $OSX ]]; then brew install icu4c pango; brew link --force gettext; fi - if [[ $OSX ]]; then export ICU_ROOT=/usr/local/opt/icu4c ; fi - wget http://www.cmake.org/files/v3.3/cmake-3.3.1-Linux-x86_64.sh - sudo sh cmake-3.3.1-Linux-x86_64.sh --skip-license --prefix=/usr From 25225117b6e6f9714857db6345b8082c40cddcbe Mon Sep 17 00:00:00 2001 From: egorpugin Date: Sun, 6 Sep 2015 22:12:45 +0300 Subject: [PATCH 15/26] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d4073819d..8875cfba4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ install: - unzip leptonica.zip -d . - cmake -Hleptonica-master -Bleptonica-master/build - make -C leptonica-master/build - - if [ $LINUX && "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi + - if [[ $LINUX && "$CXX" = "g++" ]]; then export CXX="g++-4.8" CC="gcc-4.8"; fi script: - mkdir build From 083639fff95519bbc089f78041ca6c443ddd362f Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Sun, 6 Sep 2015 22:30:11 +0300 Subject: [PATCH 16/26] Add appveyor.yml. --- appveyor.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..bcc07bf74 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,24 @@ +os: Visual Studio 2015 + +platform: + - Win32 + - Win64 + +configuration: + - Debug + +before_build: + - if %platform%==Win32 set generator=Visual Studio 14 + - if %platform%==Win64 set generator=Visual Studio 14 Win64 + - if %platform%==Win32 set vcplatform=Win32 + - if %platform%==Win64 set vcplatform=x64 + - ps: Start-FileDownload 'https://github.com/egorpugin/leptonica/archive/master.zip' -FileName leptonica.zip + - 7z x leptonica.zip + - cmake -Hleptonica-master -Bleptonica-master/build + - make -C leptonica-master/build + +build_script: + - mkdir build + - cd build + - cmake .. -G "%generator%" -DLeptonica_DIR=leptonica-master/build + - msbuild tesseract.sln /p:Platform=%vcplatform% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" From 9c55472210de1f8071e7b3eb667e80942a3927b8 Mon Sep 17 00:00:00 2001 From: egorpugin Date: Sun, 6 Sep 2015 22:59:23 +0300 Subject: [PATCH 17/26] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2f5569bf0..5eff4402f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![Build Status](https://travis-ci.org/egorpugin/tesseract.svg?branch=master)](https://travis-ci.org/egorpugin/tesseract) +[![Build status](https://ci.appveyor.com/api/projects/status/34s8gu4md3i9s93k?svg=true)](https://ci.appveyor.com/project/egorpugin/tesseract) Note that this is possibly out-of-date version of the wiki ReadMe, which is located at: From bf36e5200aa7f2fb544912e706703a27de942cd6 Mon Sep 17 00:00:00 2001 From: egorpugin Date: Sun, 6 Sep 2015 23:35:30 +0300 Subject: [PATCH 18/26] Update appveyor.yml --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index bcc07bf74..5137df8b7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,7 +15,7 @@ before_build: - ps: Start-FileDownload 'https://github.com/egorpugin/leptonica/archive/master.zip' -FileName leptonica.zip - 7z x leptonica.zip - cmake -Hleptonica-master -Bleptonica-master/build - - make -C leptonica-master/build + - msbuild leptonica-master/build/leptonica.sln /p:Platform=%vcplatform% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" build_script: - mkdir build From b3757280128e75d2b3f74a8b207a7d97274dac6d Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Sun, 6 Sep 2015 23:59:54 +0300 Subject: [PATCH 19/26] Add BUILD_TRAINING CMake option. --- .travis.yml | 2 +- CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8875cfba4..8bb375452 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,5 +41,5 @@ install: script: - mkdir build - cd build - - cmake .. -DLeptonica_DIR=leptonica-master/build + - cmake .. -DLeptonica_DIR=leptonica-master/build -DBUILD_TRAINING=1 - make diff --git a/CMakeLists.txt b/CMakeLists.txt index 8565cf295..9ffa62d52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ set(VERSION_PLAIN ${VERSION_MAJOR}.${VERSION_MINOR}) find_package(Leptonica 1.72 REQUIRED) +if (BUILD_TRAINING) find_package(ICU COMPONENTS uc i18n) find_package(PkgConfig) pkg_check_modules(Pango pango) @@ -57,6 +58,7 @@ pkg_check_modules(FontConfig fontconfig) include_directories(${ICU_INCLUDE_DIRS}) include_directories(${Pango_INCLUDE_DIRS}) include_directories(${Cairo_INCLUDE_DIRS}) +endif() ############################################################################### # @@ -212,6 +214,8 @@ target_link_libraries (tesseractmain tesseract) ######################################## +if (BUILD_TRAINING) add_subdirectory(training) +endif() ############################################################################### From b1d0cb96920c9ea7349584bd8cdab601119e820e Mon Sep 17 00:00:00 2001 From: egorpugin Date: Mon, 7 Sep 2015 00:40:24 +0300 Subject: [PATCH 20/26] Update appveyor.yml --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 5137df8b7..105a86781 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,7 +14,7 @@ before_build: - if %platform%==Win64 set vcplatform=x64 - ps: Start-FileDownload 'https://github.com/egorpugin/leptonica/archive/master.zip' -FileName leptonica.zip - 7z x leptonica.zip - - cmake -Hleptonica-master -Bleptonica-master/build + - cmake -Hleptonica-master -Bleptonica-master/build -G "%generator%" - msbuild leptonica-master/build/leptonica.sln /p:Platform=%vcplatform% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" build_script: From c0d8a07b9de08a873dbb382619b3fbe82da0d7e5 Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Mon, 7 Sep 2015 01:46:33 +0300 Subject: [PATCH 21/26] Fix a lot of training tool to work on windows with static build. --- CMakeLists.txt | 4 +- training/CMakeLists.txt | 205 +++++++++++++++++++++++----------------- 2 files changed, 120 insertions(+), 89 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ffa62d52..9966b87de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -193,7 +193,9 @@ set(tesseract_src ${tesseract_src} ) add_library (tesseract ${LIBRARY_TYPE} ${tesseract_src} ${tesseract_hdr}) +if (NOT STATIC) target_compile_definitions (tesseract PUBLIC -DTESS_EXPORTS) +endif() target_link_libraries (tesseract ${Leptonica_LIBRARIES} ${LIB_Ws2_32} ${LIB_pthread}) set_target_properties (tesseract PROPERTIES OUTPUT_NAME tesseract${VERSION_MAJOR}${VERSION_MINOR}) set_target_properties (tesseract PROPERTIES DEBUG_OUTPUT_NAME tesseract${VERSION_MAJOR}${VERSION_MINOR}d) @@ -214,8 +216,6 @@ target_link_libraries (tesseractmain tesseract) ######################################## -if (BUILD_TRAINING) add_subdirectory(training) -endif() ############################################################################### diff --git a/training/CMakeLists.txt b/training/CMakeLists.txt index f8d56f54f..85862bfea 100644 --- a/training/CMakeLists.txt +++ b/training/CMakeLists.txt @@ -2,7 +2,7 @@ # tesseract # -add_definitions(-DPANGO_ENABLE_ENGINE) +if (STATIC) ######################################## # LIBRARY tessopt @@ -13,7 +13,115 @@ project_group (tessopt "Training Tools") ######################################## -# LIBRARY training +# LIBRARY common_training +######################################## + +set(common_training_src + commandlineflags.cpp + commontraining.cpp +) +set(common_training_hdr + commandlineflags.h + commontraining.h +) +add_library (common_training ${common_training_src} ${common_training_hdr}) +target_link_libraries (common_training tessopt) +project_group (common_training "Training Tools") + + +######################################## +# EXECUTABLE ambiguous_words +######################################## + +add_executable (ambiguous_words ambiguous_words.cpp) +target_link_libraries (ambiguous_words tesseract) +project_group (ambiguous_words "Training Tools") + + +######################################## +# EXECUTABLE classifier_tester +######################################## + +add_executable (classifier_tester classifier_tester.cpp) +target_link_libraries (classifier_tester tesseract common_training) +project_group (classifier_tester "Training Tools") + + +######################################## +# EXECUTABLE combine_tessdata +######################################## + +add_executable (combine_tessdata combine_tessdata.cpp) +target_link_libraries (combine_tessdata tesseract) +project_group (combine_tessdata "Training Tools") + + +######################################## +# EXECUTABLE cntraining +######################################## + +add_executable (cntraining cntraining.cpp) +target_link_libraries (cntraining tesseract common_training) +project_group (cntraining "Training Tools") + + +######################################## +# EXECUTABLE dawg2wordlist +######################################## + +add_executable (dawg2wordlist dawg2wordlist.cpp) +target_link_libraries (dawg2wordlist tesseract) +project_group (dawg2wordlist "Training Tools") + + +######################################## +# EXECUTABLE mftraining +######################################## + +add_executable (mftraining mftraining.cpp mergenf.cpp) +target_link_libraries (mftraining tesseract common_training) +project_group (mftraining "Training Tools") + + +######################################## +# EXECUTABLE shapeclustering +######################################## + +add_executable (shapeclustering shapeclustering.cpp) +target_link_libraries (shapeclustering tesseract common_training) +project_group (shapeclustering "Training Tools") + + +######################################## +# EXECUTABLE unicharset_extractor +######################################## + +add_executable (unicharset_extractor unicharset_extractor.cpp) +target_link_libraries (unicharset_extractor tesseract tessopt) +project_group (unicharset_extractor "Training Tools") + + +######################################## +# EXECUTABLE wordlist2dawg +######################################## + +add_executable (wordlist2dawg wordlist2dawg.cpp) +target_link_libraries (wordlist2dawg tesseract) +project_group (wordlist2dawg "Training Tools") + + +endif(STATIC) + +############################################################################### +# UNCHECKED +############################################################################### + +if (BUILD_TRAINING) + +add_definitions(-DPANGO_ENABLE_ENGINE) + +######################################## +# LIBRARY training ? ######################################## set(training_src @@ -32,79 +140,19 @@ project_group (training "Training Tools") ######################################## -# EXECUTABLE ambiguous_words +# EXECUTABLE set_unicharset_properties ? ######################################## -add_executable (ambiguous_words ambiguous_words.cpp) -target_link_libraries (ambiguous_words tesseract training tessopt) -project_group (ambiguous_words "Training Tools") - - -######################################## -# EXECUTABLE classifier_tester -######################################## - -add_executable (classifier_tester classifier_tester.cpp) -target_link_libraries (classifier_tester tesseract training tessopt) -project_group (classifier_tester "Training Tools") - - -######################################## -# EXECUTABLE combine_tessdata -######################################## - -add_executable (combine_tessdata combine_tessdata.cpp) -target_link_libraries (combine_tessdata tesseract) -project_group (combine_tessdata "Training Tools") - - -######################################## -# EXECUTABLE cntraining -######################################## - -add_executable (cntraining cntraining.cpp) -target_link_libraries (cntraining tesseract training tessopt) -project_group (cntraining "Training Tools") - - -######################################## -# EXECUTABLE dawg2wordlist -######################################## - -add_executable (dawg2wordlist dawg2wordlist.cpp) -target_link_libraries (dawg2wordlist tesseract training tessopt) -project_group (dawg2wordlist "Training Tools") - - -######################################## -# EXECUTABLE mftraining -######################################## - -add_executable (mftraining mftraining.cpp mergenf.cpp) -target_link_libraries (mftraining tesseract training tessopt) -project_group (mftraining "Training Tools") - - -######################################## -# EXECUTABLE set_unicharset_properties -######################################## - -add_executable (set_unicharset_properties set_unicharset_properties.cpp) -target_link_libraries (set_unicharset_properties tesseract training tessopt ${ICU_LIBRARIES}) +add_executable (set_unicharset_properties + set_unicharset_properties.cpp + unicharset_training_utils.cpp +) +target_link_libraries (set_unicharset_properties tesseract common_training ${ICU_LIBRARIES}) project_group (set_unicharset_properties "Training Tools") ######################################## -# EXECUTABLE shapeclustering -######################################## - -add_executable (shapeclustering shapeclustering.cpp) -target_link_libraries (shapeclustering tesseract training tessopt) -project_group (shapeclustering "Training Tools") - - -######################################## -# EXECUTABLE text2image +# EXECUTABLE text2image ? ######################################## add_executable (text2image text2image.cpp) @@ -118,23 +166,6 @@ target_link_libraries (text2image tesseract training tessopt ) project_group (text2image "Training Tools") - -######################################## -# EXECUTABLE unicharset_extractor -######################################## - -add_executable (unicharset_extractor unicharset_extractor.cpp) -target_link_libraries (unicharset_extractor tesseract tessopt) -project_group (unicharset_extractor "Training Tools") - - -######################################## -# EXECUTABLE wordlist2dawg -######################################## - -add_executable (wordlist2dawg wordlist2dawg.cpp) -target_link_libraries (wordlist2dawg tesseract tessopt) -project_group (wordlist2dawg "Training Tools") - +endif(BUILD_TRAINING) ############################################################################### From da3852dc77fd44a85894fcc5660c4957d8e80abc Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Mon, 7 Sep 2015 02:49:18 +0300 Subject: [PATCH 22/26] Fix cygwin build. --- CMakeLists.txt | 10 ++++- ccutil/platform.h | 2 +- training/CMakeLists.txt | 83 +++++++++++++++++++++++------------------ 3 files changed, 55 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9966b87de..35349c106 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ # ############################################################################### -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 2.8.11) # In-source builds are disabled. if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) @@ -46,9 +46,11 @@ set(VERSION_PLAIN ${VERSION_MAJOR}.${VERSION_MINOR}) find_package(Leptonica 1.72 REQUIRED) -if (BUILD_TRAINING) find_package(ICU COMPONENTS uc i18n) +find_package(OpenCL QUIET) find_package(PkgConfig) + +if (PKG_CONFIG_FOUND) pkg_check_modules(Pango pango) pkg_check_modules(Cairo cairo) pkg_check_modules(PangoFt2 pangoft2) @@ -83,6 +85,10 @@ if (WIN32) set(LIB_Ws2_32 Ws2_32) endif() +if (CYGWIN) + add_definitions(-D__CYGWIN__) +endif() + if (UNIX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11") diff --git a/ccutil/platform.h b/ccutil/platform.h index dc85f5b96..219f9e31e 100644 --- a/ccutil/platform.h +++ b/ccutil/platform.h @@ -47,7 +47,7 @@ #define SIGNED signed #endif -#ifdef _WIN32 +#if defined(_WIN32) || defined(__CYGWIN__) #ifndef M_PI #define M_PI 3.14159265358979323846 #endif diff --git a/training/CMakeLists.txt b/training/CMakeLists.txt index 85862bfea..3aceeceae 100644 --- a/training/CMakeLists.txt +++ b/training/CMakeLists.txt @@ -2,7 +2,7 @@ # tesseract # -if (STATIC) +if (STATIC OR NOT (WIN32 OR CYGWIN)) ######################################## # LIBRARY tessopt @@ -25,7 +25,7 @@ set(common_training_hdr commontraining.h ) add_library (common_training ${common_training_src} ${common_training_hdr}) -target_link_libraries (common_training tessopt) +target_link_libraries (common_training tesseract tessopt) project_group (common_training "Training Tools") @@ -43,7 +43,7 @@ project_group (ambiguous_words "Training Tools") ######################################## add_executable (classifier_tester classifier_tester.cpp) -target_link_libraries (classifier_tester tesseract common_training) +target_link_libraries (classifier_tester common_training) project_group (classifier_tester "Training Tools") @@ -61,7 +61,7 @@ project_group (combine_tessdata "Training Tools") ######################################## add_executable (cntraining cntraining.cpp) -target_link_libraries (cntraining tesseract common_training) +target_link_libraries (cntraining common_training) project_group (cntraining "Training Tools") @@ -78,8 +78,8 @@ project_group (dawg2wordlist "Training Tools") # EXECUTABLE mftraining ######################################## -add_executable (mftraining mftraining.cpp mergenf.cpp) -target_link_libraries (mftraining tesseract common_training) +add_executable (mftraining mftraining.cpp mergenf.cpp mergenf.h) +target_link_libraries (mftraining common_training) project_group (mftraining "Training Tools") @@ -88,7 +88,7 @@ project_group (mftraining "Training Tools") ######################################## add_executable (shapeclustering shapeclustering.cpp) -target_link_libraries (shapeclustering tesseract common_training) +target_link_libraries (shapeclustering common_training) project_group (shapeclustering "Training Tools") @@ -110,53 +110,61 @@ target_link_libraries (wordlist2dawg tesseract) project_group (wordlist2dawg "Training Tools") -endif(STATIC) - -############################################################################### -# UNCHECKED ############################################################################### -if (BUILD_TRAINING) +if (PKG_CONFIG_FOUND) add_definitions(-DPANGO_ENABLE_ENGINE) ######################################## -# LIBRARY training ? -######################################## - -set(training_src - boxchar.cpp commandlineflags.cpp commontraining.cpp degradeimage.cpp - fileio.cpp ligature_table.cpp normstrngs.cpp pango_font_info.cpp - stringrenderer.cpp tlog.cpp unicharset_training_utils.cpp -) -set(training_hdr - boxchar.h commandlineflags.h commontraining.h degradeimage.h - fileio.h icuerrorcode.h ligature_table.h normstrngs.h - mergenf.h pango_font_info.h stringrenderer.h - tessopt.h tlog.h unicharset_training_utils.h util.h -) -add_library (training ${training_src} ${training_hdr}) -project_group (training "Training Tools") - - -######################################## -# EXECUTABLE set_unicharset_properties ? +# EXECUTABLE set_unicharset_properties ######################################## add_executable (set_unicharset_properties set_unicharset_properties.cpp unicharset_training_utils.cpp + unicharset_training_utils.h + fileio.cpp + fileio.h + normstrngs.cpp + normstrngs.h + icuerrorcode.h ) -target_link_libraries (set_unicharset_properties tesseract common_training ${ICU_LIBRARIES}) +target_link_libraries (set_unicharset_properties common_training ${ICU_LIBRARIES}) project_group (set_unicharset_properties "Training Tools") ######################################## -# EXECUTABLE text2image ? +# EXECUTABLE text2image ######################################## -add_executable (text2image text2image.cpp) -target_link_libraries (text2image tesseract training tessopt +set(text2image_src + text2image.cpp + boxchar.cpp + boxchar.h + degradeimage.cpp + degradeimage.h + fileio.cpp + fileio.h + ligature_table.cpp + ligature_table.h + normstrngs.cpp + normstrngs.h + pango_font_info.cpp + pango_font_info.h + stringrenderer.cpp + stringrenderer.h + tlog.cpp + tlog.h + util.h + icuerrorcode.h +) +if (CYGWIN) +set(text2image_src ${text2image_src} ../vs2010/port/strcasestr.cpp) +endif() + +add_executable (text2image ${text2image_src}) +target_link_libraries (text2image tesseract common_training ${ICU_LIBRARIES} ${Pango_LIBRARIES} ${Cairo_LIBRARIES} @@ -166,6 +174,7 @@ target_link_libraries (text2image tesseract training tessopt ) project_group (text2image "Training Tools") -endif(BUILD_TRAINING) +endif(PKG_CONFIG_FOUND) +endif(STATIC OR NOT (WIN32 OR CYGWIN)) ############################################################################### From 670e0fafb364ab29e1b0742b205d7384ee171b07 Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Mon, 7 Sep 2015 12:49:08 +0300 Subject: [PATCH 23/26] Hide pango and cairo includes from targets that do not use it. --- CMakeLists.txt | 12 ----- training/CMakeLists.txt | 98 ++++++++++++++++++++++------------------- 2 files changed, 53 insertions(+), 57 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 35349c106..cc785f474 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,18 +50,6 @@ find_package(ICU COMPONENTS uc i18n) find_package(OpenCL QUIET) find_package(PkgConfig) -if (PKG_CONFIG_FOUND) -pkg_check_modules(Pango pango) -pkg_check_modules(Cairo cairo) -pkg_check_modules(PangoFt2 pangoft2) -pkg_check_modules(PangoCairo pangocairo) -pkg_check_modules(FontConfig fontconfig) - -include_directories(${ICU_INCLUDE_DIRS}) -include_directories(${Pango_INCLUDE_DIRS}) -include_directories(${Cairo_INCLUDE_DIRS}) -endif() - ############################################################################### # # compiler and linker diff --git a/training/CMakeLists.txt b/training/CMakeLists.txt index 3aceeceae..d5cce0b96 100644 --- a/training/CMakeLists.txt +++ b/training/CMakeLists.txt @@ -8,8 +8,8 @@ if (STATIC OR NOT (WIN32 OR CYGWIN)) # LIBRARY tessopt ######################################## -add_library (tessopt tessopt.cpp tessopt.h) -project_group (tessopt "Training Tools") +add_library (tessopt tessopt.cpp tessopt.h) +project_group (tessopt "Training Tools") ######################################## @@ -24,103 +24,99 @@ set(common_training_hdr commandlineflags.h commontraining.h ) -add_library (common_training ${common_training_src} ${common_training_hdr}) -target_link_libraries (common_training tesseract tessopt) -project_group (common_training "Training Tools") +add_library (common_training ${common_training_src} ${common_training_hdr}) +target_link_libraries (common_training tesseract tessopt) +project_group (common_training "Training Tools") ######################################## # EXECUTABLE ambiguous_words ######################################## -add_executable (ambiguous_words ambiguous_words.cpp) -target_link_libraries (ambiguous_words tesseract) -project_group (ambiguous_words "Training Tools") +add_executable (ambiguous_words ambiguous_words.cpp) +target_link_libraries (ambiguous_words tesseract) +project_group (ambiguous_words "Training Tools") ######################################## # EXECUTABLE classifier_tester ######################################## -add_executable (classifier_tester classifier_tester.cpp) -target_link_libraries (classifier_tester common_training) -project_group (classifier_tester "Training Tools") +add_executable (classifier_tester classifier_tester.cpp) +target_link_libraries (classifier_tester common_training) +project_group (classifier_tester "Training Tools") ######################################## # EXECUTABLE combine_tessdata ######################################## -add_executable (combine_tessdata combine_tessdata.cpp) -target_link_libraries (combine_tessdata tesseract) -project_group (combine_tessdata "Training Tools") +add_executable (combine_tessdata combine_tessdata.cpp) +target_link_libraries (combine_tessdata tesseract) +project_group (combine_tessdata "Training Tools") ######################################## # EXECUTABLE cntraining ######################################## -add_executable (cntraining cntraining.cpp) -target_link_libraries (cntraining common_training) -project_group (cntraining "Training Tools") +add_executable (cntraining cntraining.cpp) +target_link_libraries (cntraining common_training) +project_group (cntraining "Training Tools") ######################################## # EXECUTABLE dawg2wordlist ######################################## -add_executable (dawg2wordlist dawg2wordlist.cpp) -target_link_libraries (dawg2wordlist tesseract) -project_group (dawg2wordlist "Training Tools") +add_executable (dawg2wordlist dawg2wordlist.cpp) +target_link_libraries (dawg2wordlist tesseract) +project_group (dawg2wordlist "Training Tools") ######################################## # EXECUTABLE mftraining ######################################## -add_executable (mftraining mftraining.cpp mergenf.cpp mergenf.h) -target_link_libraries (mftraining common_training) -project_group (mftraining "Training Tools") +add_executable (mftraining mftraining.cpp mergenf.cpp mergenf.h) +target_link_libraries (mftraining common_training) +project_group (mftraining "Training Tools") ######################################## # EXECUTABLE shapeclustering ######################################## -add_executable (shapeclustering shapeclustering.cpp) -target_link_libraries (shapeclustering common_training) -project_group (shapeclustering "Training Tools") +add_executable (shapeclustering shapeclustering.cpp) +target_link_libraries (shapeclustering common_training) +project_group (shapeclustering "Training Tools") ######################################## # EXECUTABLE unicharset_extractor ######################################## -add_executable (unicharset_extractor unicharset_extractor.cpp) -target_link_libraries (unicharset_extractor tesseract tessopt) -project_group (unicharset_extractor "Training Tools") +add_executable (unicharset_extractor unicharset_extractor.cpp) +target_link_libraries (unicharset_extractor tesseract tessopt) +project_group (unicharset_extractor "Training Tools") ######################################## # EXECUTABLE wordlist2dawg ######################################## -add_executable (wordlist2dawg wordlist2dawg.cpp) -target_link_libraries (wordlist2dawg tesseract) -project_group (wordlist2dawg "Training Tools") +add_executable (wordlist2dawg wordlist2dawg.cpp) +target_link_libraries (wordlist2dawg tesseract) +project_group (wordlist2dawg "Training Tools") -############################################################################### - -if (PKG_CONFIG_FOUND) - -add_definitions(-DPANGO_ENABLE_ENGINE) - ######################################## # EXECUTABLE set_unicharset_properties ######################################## -add_executable (set_unicharset_properties +if (ICU_FOUND) + +add_executable (set_unicharset_properties set_unicharset_properties.cpp unicharset_training_utils.cpp unicharset_training_utils.h @@ -130,14 +126,24 @@ add_executable (set_unicharset_properties normstrngs.h icuerrorcode.h ) -target_link_libraries (set_unicharset_properties common_training ${ICU_LIBRARIES}) -project_group (set_unicharset_properties "Training Tools") +#target_include_directories (set_unicharset_properties PRIVATE ${ICU_INCLUDE_DIRS}) +target_link_libraries (set_unicharset_properties common_training ${ICU_LIBRARIES}) +project_group (set_unicharset_properties "Training Tools") +endif (ICU_FOUND) ######################################## # EXECUTABLE text2image ######################################## +if (ICU_FOUND AND PKG_CONFIG_FOUND) + +pkg_check_modules(Pango REQUIRED pango) +pkg_check_modules(Cairo REQUIRED cairo) +pkg_check_modules(PangoFt2 REQUIRED pangoft2) +pkg_check_modules(PangoCairo REQUIRED pangocairo) +pkg_check_modules(FontConfig REQUIRED fontconfig) + set(text2image_src text2image.cpp boxchar.cpp @@ -163,8 +169,10 @@ if (CYGWIN) set(text2image_src ${text2image_src} ../vs2010/port/strcasestr.cpp) endif() -add_executable (text2image ${text2image_src}) -target_link_libraries (text2image tesseract common_training +add_executable (text2image ${text2image_src}) +target_include_directories (text2image BEFORE PRIVATE ${Cairo_INCLUDE_DIRS} ${Pango_INCLUDE_DIRS}) +target_compile_definitions (text2image PRIVATE -DPANGO_ENABLE_ENGINE) +target_link_libraries (text2image tesseract common_training ${ICU_LIBRARIES} ${Pango_LIBRARIES} ${Cairo_LIBRARIES} @@ -172,9 +180,9 @@ target_link_libraries (text2image tesseract common_training ${PangoFt2_LIBRARIES} ${FontConfig_LIBRARIES} ) -project_group (text2image "Training Tools") +project_group (text2image "Training Tools") -endif(PKG_CONFIG_FOUND) +endif(ICU_FOUND AND PKG_CONFIG_FOUND) endif(STATIC OR NOT (WIN32 OR CYGWIN)) ############################################################################### From 252080dbca6221ffba0af4bf2850395b12d363e5 Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Mon, 7 Sep 2015 12:50:20 +0300 Subject: [PATCH 24/26] Do static build with some tools on appveyor. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 105a86781..f9318fd0c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,5 +20,5 @@ before_build: build_script: - mkdir build - cd build - - cmake .. -G "%generator%" -DLeptonica_DIR=leptonica-master/build + - cmake .. -G "%generator%" -DLeptonica_DIR=leptonica-master/build -DSTATIC=1 - msbuild tesseract.sln /p:Platform=%vcplatform% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" From 5e7ffe9e566e519bcd6eec42164a71fbd39960b4 Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Mon, 7 Sep 2015 12:57:02 +0300 Subject: [PATCH 25/26] Remove unused option. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8bb375452..8875cfba4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,5 +41,5 @@ install: script: - mkdir build - cd build - - cmake .. -DLeptonica_DIR=leptonica-master/build -DBUILD_TRAINING=1 + - cmake .. -DLeptonica_DIR=leptonica-master/build - make From 25136e40ea363594d57711e9f9427f9cead76e38 Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Mon, 7 Sep 2015 13:02:22 +0300 Subject: [PATCH 26/26] Restore ICU_INCLUDE_DIRS for OS X. --- training/CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/training/CMakeLists.txt b/training/CMakeLists.txt index d5cce0b96..68f9e6b54 100644 --- a/training/CMakeLists.txt +++ b/training/CMakeLists.txt @@ -116,6 +116,8 @@ project_group (wordlist2dawg "Training Tools") if (ICU_FOUND) +include_directories(${ICU_INCLUDE_DIRS}) + add_executable (set_unicharset_properties set_unicharset_properties.cpp unicharset_training_utils.cpp @@ -126,17 +128,15 @@ add_executable (set_unicharset_properties normstrngs.h icuerrorcode.h ) -#target_include_directories (set_unicharset_properties PRIVATE ${ICU_INCLUDE_DIRS}) target_link_libraries (set_unicharset_properties common_training ${ICU_LIBRARIES}) project_group (set_unicharset_properties "Training Tools") -endif (ICU_FOUND) ######################################## # EXECUTABLE text2image ######################################## -if (ICU_FOUND AND PKG_CONFIG_FOUND) +if (PKG_CONFIG_FOUND) pkg_check_modules(Pango REQUIRED pango) pkg_check_modules(Cairo REQUIRED cairo) @@ -182,7 +182,8 @@ target_link_libraries (text2image tesseract common_training ) project_group (text2image "Training Tools") -endif(ICU_FOUND AND PKG_CONFIG_FOUND) +endif(PKG_CONFIG_FOUND) +endif(ICU_FOUND) endif(STATIC OR NOT (WIN32 OR CYGWIN)) ###############################################################################