Merge pull request #109 from egorpugin/master

CMake improvements
This commit is contained in:
zdenop 2015-10-10 14:49:26 +02:00
commit bb15031266
4 changed files with 68 additions and 3 deletions

View File

@ -41,5 +41,5 @@ install:
script:
- mkdir build
- cd build
- cmake .. -DLeptonica_DIR=leptonica-master/build
- cmake .. -DLeptonica_BUILD_DIR=leptonica-master/build
- make

View File

@ -44,7 +44,14 @@ set(VERSION_MAJOR 3)
set(VERSION_MINOR 05)
set(VERSION_PLAIN ${VERSION_MAJOR}.${VERSION_MINOR})
find_package(Leptonica 1.72 REQUIRED)
set(MINIMUM_LEPTONICA_VERSION 1.71)
if (NOT Leptonica_BUILD_DIR)
find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED)
else()
set(Leptonica_DIR ${Leptonica_BUILD_DIR})
find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED CONFIG)
endif()
find_package(ICU COMPONENTS uc i18n)
find_package(OpenCL QUIET)
@ -142,6 +149,8 @@ include_directories(wordrec)
# LIBRARY tesseract
########################################
string(SUBSTRING ${VERSION_MINOR} 0 1 VERSION_MINOR_0)
string(SUBSTRING ${VERSION_MINOR} 1 1 VERSION_MINOR_1)
file(GLOB tesseract_src
"ccmain/*.cpp"
@ -191,8 +200,12 @@ 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 VERSION ${VERSION_MAJOR}.${VERSION_MINOR_0}.${VERSION_MINOR_1})
set_target_properties (tesseract PROPERTIES SOVERSION ${VERSION_MAJOR}.${VERSION_MINOR_0}.${VERSION_MINOR_1})
if (WIN32)
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)
endif()
export(TARGETS tesseract FILE ${CMAKE_BINARY_DIR}/TesseractTargets.cmake)

View File

@ -20,5 +20,5 @@ before_build:
build_script:
- mkdir build
- cd build
- cmake .. -G "%generator%" -DLeptonica_DIR=leptonica-master/build -DSTATIC=1
- cmake .. -G "%generator%" -DLeptonica_BUILD_DIR=leptonica-master/build -DSTATIC=1
- msbuild tesseract.sln /p:Platform=%vcplatform% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"

52
cmake/FindLeptonica.cmake Normal file
View File

@ -0,0 +1,52 @@
#
# Find Leptonica
#
# Exported variables:
# Leptonica_FOUND
# Leptonica_INCLUDE_DIRS
# Leptonica_LIBRARIES
#
# Leptonica_VERSION
# Leptonica_MAJOR_VERSION
# Leptonica_MINOR_VERSION
#
find_path(Leptonica_INCLUDE_DIR leptonica/allheaders.h
HINTS
/usr/include
/usr/local/include
/opt/include
/opt/local/include
${Leptonica_DIR}/include
)
if(NOT "${Leptonica_INCLUDE_DIR}" EQUAL "Leptonica_INCLUDE_DIR-NOTFOUND")
set(Leptonica_INCLUDE_DIRS ${Leptonica_INCLUDE_DIR}/leptonica)
file(STRINGS ${Leptonica_INCLUDE_DIRS}/allheaders.h Leptonica_MAJOR_VERSION REGEX "LIBLEPT_MAJOR_VERSION")
file(STRINGS ${Leptonica_INCLUDE_DIRS}/allheaders.h Leptonica_MINOR_VERSION REGEX "LIBLEPT_MINOR_VERSION")
string(REGEX MATCH "[0-9]+" Leptonica_MAJOR_VERSION ${Leptonica_MAJOR_VERSION})
string(REGEX MATCH "[0-9]+" Leptonica_MINOR_VERSION ${Leptonica_MINOR_VERSION})
set(Leptonica_VERSION ${Leptonica_MAJOR_VERSION}.${Leptonica_MINOR_VERSION})
endif()
find_library(Leptonica_LIBRARY NAMES lept liblept
HINTS
/usr/lib
/usr/local/lib
/opt/lib
/opt/local/lib
${Leptonica_DIR}/lib
)
set(Leptonica_LIBRARIES ${Leptonica_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Leptonica
REQUIRED_VARS
Leptonica_INCLUDE_DIRS
Leptonica_LIBRARIES
VERSION_VAR Leptonica_VERSION
FAIL_MESSAGE "Try to set Leptonica_DIR or Leptonica_ROOT"
)
mark_as_advanced(Leptonica_INCLUDE_DIRS Leptonica_LIBRARIES)