From a94334a255f6022062066c6dd3e86da2a6e8d783 Mon Sep 17 00:00:00 2001 From: zdenop <zdenop@gmail.com> Date: Wed, 8 May 2019 18:49:48 +0200 Subject: [PATCH] cmake: fix build without pkg-config (issue #2424) --- CMakeLists.txt | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff6e6c617b..cf16124193 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,16 +142,19 @@ endif() # ############################################################################### -if(NOT CPPAN_BUILD) - find_package(PkgConfig) - if (NOT Leptonica_DIR AND NOT MSVC AND COMMAND pkg_check_modules) - if(NOT PKG_CONFIG_EXECUTABLE) - message(FATAL_ERROR "Missing required pkg-config") +if(NOT CPPAN_BUILD AND NOT Leptonica_DIR) + find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} CONFIG QUIET) + if (NOT Leptonica_FOUND) + find_package(PkgConfig QUIET) + if(PKG_CONFIG_EXECUTABLE) + pkg_check_modules(Leptonica REQUIRED lept>=${MINIMUM_LEPTONICA_VERSION}) + link_directories(${Leptonica_LIBRARY_DIRS}) + endif(PKG_CONFIG_EXECUTABLE) + # message ("Leptonica: ${Leptonica_LIBRARY_DIRS}, ${Leptonica_FOUND}") + + if (NOT Leptonica_FOUND) + message(FATAL_ERROR "Cannot find required library Leptonica. Quitting!") endif() - pkg_check_modules(Leptonica REQUIRED lept>=${MINIMUM_LEPTONICA_VERSION}) - link_directories(${Leptonica_LIBRARY_DIRS}) - else() - find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED CONFIG) endif() else() if (STATIC)