Skip to content

Commit dfb5aa5

Browse files
committed
Add Leptonica_BUILD_DIR option for CMake find_package in Config mode. Set correct .so name on Linux.
1 parent a614edb commit dfb5aa5

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ install:
4141
script:
4242
- mkdir build
4343
- cd build
44-
- cmake .. -DLeptonica_DIR=leptonica-master/build
44+
- cmake .. -DLeptonica_BUILD_DIR=leptonica-master/build
4545
- make

CMakeLists.txt

+13-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ set(VERSION_MAJOR 3)
4444
set(VERSION_MINOR 05)
4545
set(VERSION_PLAIN ${VERSION_MAJOR}.${VERSION_MINOR})
4646

47-
find_package(Leptonica 1.71 REQUIRED)
47+
set(MINIMUM_LEPTONICA_VERSION 1.71)
48+
49+
if (NOT Leptonica_BUILD_DIR)
50+
find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED)
51+
else()
52+
find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED CONFIG)
53+
endif()
4854

4955
find_package(ICU COMPONENTS uc i18n)
5056
find_package(OpenCL QUIET)
@@ -142,6 +148,8 @@ include_directories(wordrec)
142148
# LIBRARY tesseract
143149
########################################
144150

151+
string(SUBSTRING ${VERSION_MINOR} 0 1 VERSION_MINOR_0)
152+
string(SUBSTRING ${VERSION_MINOR} 1 1 VERSION_MINOR_1)
145153

146154
file(GLOB tesseract_src
147155
"ccmain/*.cpp"
@@ -191,8 +199,12 @@ if (NOT STATIC)
191199
target_compile_definitions (tesseract PUBLIC -DTESS_EXPORTS)
192200
endif()
193201
target_link_libraries (tesseract ${Leptonica_LIBRARIES} ${LIB_Ws2_32} ${LIB_pthread})
202+
set_target_properties (tesseract PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR_0}.${VERSION_MINOR_1})
203+
set_target_properties (tesseract PROPERTIES SOVERSION ${VERSION_MAJOR}.${VERSION_MINOR_0}.${VERSION_MINOR_1})
204+
if (WIN32)
194205
set_target_properties (tesseract PROPERTIES OUTPUT_NAME tesseract${VERSION_MAJOR}${VERSION_MINOR})
195206
set_target_properties (tesseract PROPERTIES DEBUG_OUTPUT_NAME tesseract${VERSION_MAJOR}${VERSION_MINOR}d)
207+
endif()
196208
export(TARGETS tesseract FILE ${CMAKE_BINARY_DIR}/TesseractTargets.cmake)
197209

198210

appveyor.yml

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

cmake/FindLeptonica.cmake

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ find_path(Leptonica_INCLUDE_DIR leptonica/allheaders.h
1717
/usr/local/include
1818
/opt/include
1919
/opt/local/include
20+
${Leptonica_DIR}/include
2021
)
21-
if(NOT Leptonica_INCLUDE_DIR-NOTFOUND)
22+
if("${Leptonica_INCLUDE_DIR}" EQUAL "Leptonica_INCLUDE_DIR-NOTFOUND")
2223
set(Leptonica_INCLUDE_DIRS ${Leptonica_INCLUDE_DIR}/leptonica)
2324
file(STRINGS ${Leptonica_INCLUDE_DIRS}/allheaders.h Leptonica_MAJOR_VERSION REGEX "LIBLEPT_MAJOR_VERSION")
2425
file(STRINGS ${Leptonica_INCLUDE_DIRS}/allheaders.h Leptonica_MINOR_VERSION REGEX "LIBLEPT_MINOR_VERSION")
@@ -33,6 +34,7 @@ find_library(Leptonica_LIBRARY NAMES lept liblept
3334
/usr/local/lib
3435
/opt/lib
3536
/opt/local/lib
37+
${Leptonica_DIR}/lib
3638
)
3739
set(Leptonica_LIBRARIES ${Leptonica_LIBRARY})
3840

@@ -43,6 +45,7 @@ find_package_handle_standard_args(Leptonica
4345
Leptonica_INCLUDE_DIRS
4446
Leptonica_LIBRARIES
4547
VERSION_VAR Leptonica_VERSION
48+
FAIL_MESSAGE "Try to set Leptonica_DIR or Leptonica_ROOT"
4649
)
4750

4851
mark_as_advanced(Leptonica_INCLUDE_DIRS Leptonica_LIBRARIES)

0 commit comments

Comments
 (0)