diff --git a/CMakeLists.txt b/CMakeLists.txt index fc521e4453..302416ca62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,11 +54,15 @@ if(NOT EXISTS ${PROJECT_SOURCE_DIR}/.cppan) find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED CONFIG) endif() else() + if (STATIC) + set(CPPAN_BUILD_SHARED_LIBS 0) + else() + set(CPPAN_BUILD_SHARED_LIBS 1) + endif() add_subdirectory(.cppan) endif() find_package(OpenCL QUIET) -find_package(PkgConfig) ############################################################################### # @@ -203,7 +207,11 @@ set(tesseract_src ${tesseract_src} add_library (tesseract ${LIBRARY_TYPE} ${tesseract_src} ${tesseract_hdr}) if (NOT STATIC) -target_compile_definitions (tesseract PUBLIC -DTESS_EXPORTS) +target_compile_definitions (tesseract + PRIVATE -DTESS_EXPORTS + INTERFACE -DTESS_IMPORTS +) +set_target_properties (tesseract PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS True) endif() target_link_libraries (tesseract ${LIB_Ws2_32} ${LIB_pthread}) set_target_properties (tesseract PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR_0}.${VERSION_MINOR_1}) @@ -217,7 +225,8 @@ if (NOT CPPAN_BUILD) target_link_libraries (tesseract ${Leptonica_LIBRARIES}) export(TARGETS tesseract FILE ${CMAKE_BINARY_DIR}/TesseractTargets.cmake) else() - target_link_libraries (tesseract cppan) + target_link_libraries (tesseract pvt.cppan.demo.leptonica) + add_dependencies (tesseract cppan) file(WRITE ${CMAKE_BINARY_DIR}/TesseractTargets.cmake "include(${CMAKE_BINARY_DIR}/cppan.cmake)\n") export(TARGETS tesseract APPEND FILE ${CMAKE_BINARY_DIR}/TesseractTargets.cmake) endif() diff --git a/ccutil/unicharset.h b/ccutil/unicharset.h index 19eb7cfc29..716147eebd 100644 --- a/ccutil/unicharset.h +++ b/ccutil/unicharset.h @@ -141,7 +141,7 @@ class UNICHARSET { // Custom list of characters and their ligature forms (UTF8) // These map to unicode values in the private use area (PUC) and are supported // by only few font families (eg. Wyld, Adobe Caslon Pro). - static const char* kCustomLigatures[][2]; + static TESS_API const char* kCustomLigatures[][2]; // List of strings for the SpecialUnicharCodes. Keep in sync with the enum. static const char* kSpecialUnicharCodes[SPECIAL_UNICHAR_CODES_COUNT]; diff --git a/classify/featdefs.h b/classify/featdefs.h index 704bbdfde2..7c168f3daa 100644 --- a/classify/featdefs.h +++ b/classify/featdefs.h @@ -77,7 +77,7 @@ int ShortNameToFeatureType(const FEATURE_DEFS_STRUCT &FeatureDefs, Global Data Definitions and Declarations ----------------------------------------------------------------------------**/ extern const FEATURE_DESC_STRUCT MicroFeatureDesc; -extern const FEATURE_DESC_STRUCT PicoFeatDesc; +extern TESS_API const FEATURE_DESC_STRUCT PicoFeatDesc; extern const FEATURE_DESC_STRUCT CharNormDesc; extern const FEATURE_DESC_STRUCT OutlineFeatDesc; extern const FEATURE_DESC_STRUCT IntFeatDesc; diff --git a/classify/picofeat.h b/classify/picofeat.h index 208b7e7708..966ffc32e7 100644 --- a/classify/picofeat.h +++ b/classify/picofeat.h @@ -61,5 +61,5 @@ extern double_VAR_H(classify_pico_feature_length, 0.05, "Pico Feature Length"); /**---------------------------------------------------------------------------- Global Data Definitions and Declarations ----------------------------------------------------------------------------**/ -extern FLOAT32 PicoFeatureLength; +extern TESS_API FLOAT32 PicoFeatureLength; #endif diff --git a/cppan.yml b/cppan.yml index d366b0f9e8..789c2e7b73 100644 --- a/cppan.yml +++ b/cppan.yml @@ -122,10 +122,14 @@ options: - WINDLLNAME="tesseract" shared: definitions: - public: TESS_EXPORTS + private: + - TESS_EXPORTS + interface: + - TESS_IMPORTS dependencies: - private: - # tesseract uses leptonica only internally - # and does not expose its interface to users - pvt.cppan.demo.leptonica: master + private: + pvt.cppan.demo.leptonica: master + # only for training tools, move to them later + pvt.cppan.demo.unicode.icu.i18n: "*" + diff --git a/dict/trie.h b/dict/trie.h index 48ec56e0c7..65c060603e 100644 --- a/dict/trie.h +++ b/dict/trie.h @@ -402,7 +402,7 @@ class Trie : public Dawg { EDGE_VECTOR* backward_edges, NODE_MARKER reduced_nodes); - /** + /** * Order num_edges of consequtive EDGE_RECORDS in the given EDGE_VECTOR in * increasing order of unichar ids. This function is normally called * for all edges in a single node, and since number of edges in each node diff --git a/training/CMakeLists.txt b/training/CMakeLists.txt index 66821390f8..737c17f80d 100644 --- a/training/CMakeLists.txt +++ b/training/CMakeLists.txt @@ -2,56 +2,62 @@ # tesseract # -if (STATIC OR NOT (WIN32 OR CYGWIN)) - -# experimental -if (MSVC) - -include(CheckTypeSize) -check_type_size("void *" SIZEOF_VOID_P) - -if (SIZEOF_VOID_P EQUAL 8) - set(X64 1) - set(ARCH_DIR_NAME 64) -elseif (SIZEOF_VOID_P EQUAL 4) - set(X86 1) - set(ARCH_DIR_NAME 32) -else() - message(FATAL_ERROR "Cannot determine target architecture") +if (NOT CPPAN_BUILD AND NOT (WIN32 OR CYGWIN)) + return() endif() -set(icu_dir "${CMAKE_CURRENT_BINARY_DIR}/icu") -set(icu_archive "${icu_dir}/icu${ARCH_DIR_NAME}.zip") - -if (X86) - set(icu_hash 45167a240b60e36b59a87eda23490ce4) -else() - set(icu_hash 480c72491576c048de1218c3c5519399) +if (CPPAN_BUILD) + set(ICU_FOUND 1) endif() -message(STATUS "Downloading latest ICU binaries") - -file(DOWNLOAD - "http://download.icu-project.org/files/icu4c/56.1/icu4c-56_1-Win${ARCH_DIR_NAME}-msvc10.zip" - "${icu_archive}" - SHOW_PROGRESS - INACTIVITY_TIMEOUT 60 # seconds - EXPECTED_HASH MD5=${icu_hash} -) -execute_process(COMMAND ${CMAKE_COMMAND} -E tar xz "${icu_archive}" - WORKING_DIRECTORY "${icu_dir}" - RESULT_VARIABLE __result -) -if(NOT __result EQUAL 0) - message(FATAL_ERROR "error ${__result}") +# experimental +if (MSVC AND NOT CPPAN_BUILD) + include(CheckTypeSize) + check_type_size("void *" SIZEOF_VOID_P) + + if (SIZEOF_VOID_P EQUAL 8) + set(X64 1) + set(ARCH_DIR_NAME 64) + elseif (SIZEOF_VOID_P EQUAL 4) + set(X86 1) + set(ARCH_DIR_NAME 32) + else() + message(FATAL_ERROR "Cannot determine target architecture") + endif() + + set(icu_dir "${CMAKE_CURRENT_BINARY_DIR}/icu") + set(icu_archive "${icu_dir}/icu${ARCH_DIR_NAME}.zip") + + if (X86) + set(icu_hash 45167a240b60e36b59a87eda23490ce4) + else() + set(icu_hash 480c72491576c048de1218c3c5519399) + endif() + + message(STATUS "Downloading latest ICU binaries") + + file(DOWNLOAD + "http://download.icu-project.org/files/icu4c/56.1/icu4c-56_1-Win${ARCH_DIR_NAME}-msvc10.zip" + "${icu_archive}" + SHOW_PROGRESS + INACTIVITY_TIMEOUT 60 # seconds + EXPECTED_HASH MD5=${icu_hash} + ) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xz "${icu_archive}" + WORKING_DIRECTORY "${icu_dir}" + RESULT_VARIABLE __result + ) + if(NOT __result EQUAL 0) + message(FATAL_ERROR "error ${__result}") + endif() + + set(ICU_ROOT ${icu_dir}/icu) endif() - -set(ICU_ROOT ${icu_dir}/icu) - -endif(MSVC) # experimental +if (NOT CPPAN_BUILD) find_package(ICU COMPONENTS uc i18n) +endif() ######################################## # LIBRARY tessopt @@ -159,7 +165,9 @@ project_group (wordlist2dawg "Training Tools") if (ICU_FOUND) +if (NOT CPPAN_BUILD) include_directories(${ICU_INCLUDE_DIRS}) +endif() ######################################## # LIBRARY unicharset_training @@ -177,7 +185,11 @@ set(unicharset_training_src unicharset_training_utils.h ) add_library (unicharset_training ${unicharset_training_src}) +if (NOT CPPAN_BUILD) target_link_libraries (unicharset_training common_training ${ICU_LIBRARIES}) +else() +target_link_libraries (unicharset_training common_training pvt.cppan.demo.unicode.icu.i18n) +endif() project_group (unicharset_training "Training Tools") @@ -198,6 +210,7 @@ add_executable (lstmtraining lstmtraining.cpp) target_link_libraries (lstmtraining unicharset_training) project_group (lstmtraining "Training Tools") + ######################################## # EXECUTABLE set_unicharset_properties ######################################## @@ -211,6 +224,10 @@ project_group (set_unicharset_properties "Training Tools") # EXECUTABLE text2image ######################################## +if (NOT CPPAN_BUILD) +find_package(PkgConfig) +endif() + if (PKG_CONFIG_FOUND) pkg_check_modules(Pango REQUIRED pango) @@ -246,7 +263,6 @@ 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 unicharset_training - ${ICU_LIBRARIES} ${Pango_LIBRARIES} ${Cairo_LIBRARIES} ${PangoCairo_LIBRARIES} @@ -257,6 +273,5 @@ project_group (text2image "Training Tools") endif(PKG_CONFIG_FOUND) endif(ICU_FOUND) -endif(STATIC OR NOT (WIN32 OR CYGWIN)) ############################################################################### diff --git a/training/mergenf.cpp b/training/mergenf.cpp index 1f7c9a413c..4c8e7037d8 100644 --- a/training/mergenf.cpp +++ b/training/mergenf.cpp @@ -33,7 +33,6 @@ #include #include - /*-------------------once in subfeat---------------------------------*/ double_VAR(training_angle_match_scale, 1.0, "Angle Match Scale ..."); @@ -199,9 +198,9 @@ int FindClosestExistingProto(CLASS_TYPE Class, int NumMerged[], * * @param New new proto to be filled in * @param Old old proto to be converted - * + * * Globals: none - * + * * Exceptions: none * History: Mon Nov 26 09:45:39 1990, DSJ, Created. */