Skip to content

Commit 93d1c66

Browse files
committed
Add FindLeptonica.cmake module to find installed liblept on *nix systems.
1 parent 03531ba commit 93d1c66

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

CMakeLists.txt

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

47-
find_package(Leptonica 1.72 REQUIRED)
47+
find_package(Leptonica 1.71 REQUIRED)
4848

4949
find_package(ICU COMPONENTS uc i18n)
5050
find_package(PkgConfig QUIET)

cmake/FindLeptonica.cmake

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#
2+
# Find Leptonica
3+
#
4+
# Exported variables:
5+
# Leptonica_FOUND
6+
# Leptonica_INCLUDE_DIRS
7+
# Leptonica_LIBRARIES
8+
#
9+
# Leptonica_VERSION
10+
# Leptonica_MAJOR_VERSION
11+
# Leptonica_MINOR_VERSION
12+
#
13+
14+
find_path(Leptonica_INCLUDE_DIR leptonica/allheaders.h
15+
HINTS
16+
/usr/include
17+
/usr/local/include
18+
/opt/include
19+
/opt/local/include
20+
)
21+
if(NOT Leptonica_INCLUDE_DIR-NOTFOUND)
22+
set(Leptonica_INCLUDE_DIRS ${Leptonica_INCLUDE_DIR}/leptonica)
23+
file(STRINGS ${Leptonica_INCLUDE_DIRS}/allheaders.h Leptonica_MAJOR_VERSION REGEX "LIBLEPT_MAJOR_VERSION")
24+
file(STRINGS ${Leptonica_INCLUDE_DIRS}/allheaders.h Leptonica_MINOR_VERSION REGEX "LIBLEPT_MINOR_VERSION")
25+
string(REGEX MATCH "[0-9]+" Leptonica_MAJOR_VERSION ${Leptonica_MAJOR_VERSION})
26+
string(REGEX MATCH "[0-9]+" Leptonica_MINOR_VERSION ${Leptonica_MINOR_VERSION})
27+
set(Leptonica_VERSION ${Leptonica_MAJOR_VERSION}.${Leptonica_MINOR_VERSION})
28+
endif()
29+
30+
find_library(Leptonica_LIBRARY NAMES lept liblept
31+
HINTS
32+
/usr/lib
33+
/usr/local/lib
34+
/opt/lib
35+
/opt/local/lib
36+
)
37+
set(Leptonica_LIBRARIES ${Leptonica_LIBRARY})
38+
39+
include(FindPackageHandleStandardArgs)
40+
41+
find_package_handle_standard_args(Leptonica
42+
REQUIRED_VARS
43+
Leptonica_INCLUDE_DIRS
44+
Leptonica_LIBRARIES
45+
VERSION_VAR Leptonica_VERSION
46+
)
47+
48+
mark_as_advanced(Leptonica_INCLUDE_DIRS Leptonica_LIBRARIES)
49+

0 commit comments

Comments
 (0)