Skip to content

Commit

Permalink
Add source groups.
Browse files Browse the repository at this point in the history
  • Loading branch information
egorpugin committed Sep 6, 2015
1 parent 56a5195 commit 5e3b8d3
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 65 deletions.
109 changes: 44 additions & 65 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -208,4 +183,8 @@ set(tesseractmain_src
add_executable (tesseractmain ${tesseractmain_src})
target_link_libraries (tesseractmain tesseract)

########################################

add_subdirectory(training)

###############################################################################
14 changes: 14 additions & 0 deletions cmake/BuildFunctions.cmake
Original file line number Diff line number Diff line change
@@ -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)

################################################################################
29 changes: 29 additions & 0 deletions cmake/SourceGroups.cmake
Original file line number Diff line number Diff line change
@@ -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}")
132 changes: 132 additions & 0 deletions training/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")


###############################################################################

0 comments on commit 5e3b8d3

Please sign in to comment.