Skip to content

Commit a94334a

Browse files
committed
cmake: fix build without pkg-config (issue #2424)
1 parent 68ca351 commit a94334a

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

CMakeLists.txt

+12-9
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,19 @@ endif()
142142
#
143143
###############################################################################
144144

145-
if(NOT CPPAN_BUILD)
146-
find_package(PkgConfig)
147-
if (NOT Leptonica_DIR AND NOT MSVC AND COMMAND pkg_check_modules)
148-
if(NOT PKG_CONFIG_EXECUTABLE)
149-
message(FATAL_ERROR "Missing required pkg-config")
145+
if(NOT CPPAN_BUILD AND NOT Leptonica_DIR)
146+
find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} CONFIG QUIET)
147+
if (NOT Leptonica_FOUND)
148+
find_package(PkgConfig QUIET)
149+
if(PKG_CONFIG_EXECUTABLE)
150+
pkg_check_modules(Leptonica REQUIRED lept>=${MINIMUM_LEPTONICA_VERSION})
151+
link_directories(${Leptonica_LIBRARY_DIRS})
152+
endif(PKG_CONFIG_EXECUTABLE)
153+
# message ("Leptonica: ${Leptonica_LIBRARY_DIRS}, ${Leptonica_FOUND}")
154+
155+
if (NOT Leptonica_FOUND)
156+
message(FATAL_ERROR "Cannot find required library Leptonica. Quitting!")
150157
endif()
151-
pkg_check_modules(Leptonica REQUIRED lept>=${MINIMUM_LEPTONICA_VERSION})
152-
link_directories(${Leptonica_LIBRARY_DIRS})
153-
else()
154-
find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED CONFIG)
155158
endif()
156159
else()
157160
if (STATIC)

0 commit comments

Comments
 (0)