Skip to content

Commit

Permalink
Add Leptonica_BUILD_DIR option for CMake find_package in Config mode.…
Browse files Browse the repository at this point in the history
… Set correct .so name on Linux.
  • Loading branch information
egorpugin committed Oct 9, 2015
1 parent a614edb commit dfb5aa5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -41,5 +41,5 @@ install:
script:
- mkdir build
- cd build
- cmake .. -DLeptonica_DIR=leptonica-master/build
- cmake .. -DLeptonica_BUILD_DIR=leptonica-master/build
- make
14 changes: 13 additions & 1 deletion CMakeLists.txt
Expand Up @@ -44,7 +44,13 @@ set(VERSION_MAJOR 3)
set(VERSION_MINOR 05)
set(VERSION_PLAIN ${VERSION_MAJOR}.${VERSION_MINOR})

find_package(Leptonica 1.71 REQUIRED)
set(MINIMUM_LEPTONICA_VERSION 1.71)

if (NOT Leptonica_BUILD_DIR)
find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED)
else()
find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED CONFIG)
endif()

find_package(ICU COMPONENTS uc i18n)
find_package(OpenCL QUIET)
Expand Down Expand Up @@ -142,6 +148,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"
Expand Down Expand Up @@ -191,8 +199,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)


Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Expand Up @@ -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"
5 changes: 4 additions & 1 deletion cmake/FindLeptonica.cmake
Expand Up @@ -17,8 +17,9 @@ find_path(Leptonica_INCLUDE_DIR leptonica/allheaders.h
/usr/local/include
/opt/include
/opt/local/include
${Leptonica_DIR}/include
)
if(NOT Leptonica_INCLUDE_DIR-NOTFOUND)
if("${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")
Expand All @@ -33,6 +34,7 @@ find_library(Leptonica_LIBRARY NAMES lept liblept
/usr/local/lib
/opt/lib
/opt/local/lib
${Leptonica_DIR}/lib
)
set(Leptonica_LIBRARIES ${Leptonica_LIBRARY})

Expand All @@ -43,6 +45,7 @@ find_package_handle_standard_args(Leptonica
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)
Expand Down

0 comments on commit dfb5aa5

Please sign in to comment.