cmake: backport master changes

This commit is contained in:
zdenop 2019-06-16 18:54:41 +02:00
parent 5d23dfa5ce
commit 9897bc9c8d

View File

@ -46,7 +46,7 @@ string(REGEX REPLACE "^([^.]*)\\..*" "\\1" VERSION_MAJOR ${VERSION_PLAIN})
string(REGEX REPLACE "^[^.]*\\.([^.]*)\\..*" "\\1" VERSION_MINOR ${VERSION_PLAIN})
string(REGEX REPLACE "^[^.]*\\.[^.]*\\.([0-9]*).*" "\\1" VERSION_PATCH ${VERSION_PLAIN})
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
execute_process(COMMAND git describe --abbrev=4
execute_process(COMMAND git --git-dir ${CMAKE_CURRENT_SOURCE_DIR}/.git describe --abbrev=4
OUTPUT_VARIABLE GIT_REV)
string(REGEX REPLACE "\n$" "" PACKAGE_VERSION "${GIT_REV}")
endif()
@ -151,27 +151,24 @@ endif()
#
###############################################################################
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()
endif()
else()
if(CPPAN_BUILD)
if (STATIC)
set(CPPAN_BUILD_SHARED_LIBS 0)
else()
set(CPPAN_BUILD_SHARED_LIBS 1)
endif()
add_subdirectory(.cppan)
else()
find_package(PkgConfig)
if(PKG_CONFIG_EXECUTABLE AND NOT Leptonica_DIR)
pkg_check_modules(Leptonica REQUIRED lept>=${MINIMUM_LEPTONICA_VERSION})
link_directories(${Leptonica_LIBRARY_DIRS})
else()
find_package(Leptonica ${MINIMUM_LEPTONICA_VERSION} REQUIRED CONFIG)
endif()
if (NOT Leptonica_FOUND)
message(FATAL_ERROR "Cannot find required library Leptonica. Quitting!")
endif(NOT Leptonica_FOUND)
endif()
find_package(OpenCL QUIET)