aboutsummaryrefslogtreecommitdiff
path: root/modules/FindKDE4Internal.cmake
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2006-05-04 21:30:40 +0000
committerDavid Faure <faure@kde.org>2006-05-04 21:30:40 +0000
commit3b050c47ec301264e5d380cf4e19f0fb7f397d1a (patch)
tree6b16cc97e60439512728a093769496beb7aac9df /modules/FindKDE4Internal.cmake
parent5abb820acb3f67e5a121b22c428d0b5ab9e9e699 (diff)
downloadextra-cmake-modules-3b050c47ec301264e5d380cf4e19f0fb7f397d1a.tar.gz
extra-cmake-modules-3b050c47ec301264e5d380cf4e19f0fb7f397d1a.tar.bz2
Factorize the version-number parsing and checking code into a separate macro.
Already used by the gpgme version check in kdepim. FindQt4 has similar code, but since it's a fork of a CMake module I'm not sure if I should modify it CCMAIL: kde-buildsystem@kde.org svn path=/trunk/KDE/kdelibs/; revision=537476
Diffstat (limited to 'modules/FindKDE4Internal.cmake')
-rw-r--r--modules/FindKDE4Internal.cmake24
1 files changed, 5 insertions, 19 deletions
diff --git a/modules/FindKDE4Internal.cmake b/modules/FindKDE4Internal.cmake
index ad0ccb80..f37cdbb2 100644
--- a/modules/FindKDE4Internal.cmake
+++ b/modules/FindKDE4Internal.cmake
@@ -177,6 +177,8 @@
# _KDE4_PLATFORM_INCLUDE_DIRS is used only internally
# _KDE4_PLATFORM_DEFINITIONS is used only internally
+INCLUDE (MacroEnsureVersion)
+
cmake_minimum_required(VERSION 2.4.0 FATAL_ERROR)
set(QT_MIN_VERSION "4.1.1")
@@ -292,6 +294,7 @@ else(EXISTS ${CMAKE_SOURCE_DIR}/kdecore/kglobal.h)
message ( FATAL_ERROR "ERROR: don't port against this version of kdelibs! Use /branches/work/kdelibs4_snapshot instead!!" )
endif (_match)
+ STRING(REGEX REPLACE "^KDE: " "" KDEVERSION "${KDEVERSION}")
# we need at least this version:
IF (NOT KDE_MIN_VERSION)
@@ -299,26 +302,9 @@ else(EXISTS ${CMAKE_SOURCE_DIR}/kdecore/kglobal.h)
ENDIF (NOT KDE_MIN_VERSION)
#message(STATUS "KDE_MIN_VERSION=${KDE_MIN_VERSION} found ${KDEVERSION}")
-
- # now parse the parts of the user given version string into variables
- STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_kde_major_vers "${KDE_MIN_VERSION}")
- STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_kde_minor_vers "${KDE_MIN_VERSION}")
- STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_kde_patch_vers "${KDE_MIN_VERSION}")
-
- # and now the version string given by kde-config
- STRING(REGEX REPLACE "KDE: ([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" found_kde_major_vers "${KDEVERSION}")
- STRING(REGEX REPLACE "KDE: [0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" found_kde_minor_vers "${KDEVERSION}")
- STRING(REGEX REPLACE "KDE: [0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" found_kde_patch_vers "${KDEVERSION}")
-
- # compute an overall version number which can be compared at once
- MATH(EXPR req_vers "${req_kde_major_vers}*10000 + ${req_kde_minor_vers}*100 + ${req_kde_patch_vers}")
- MATH(EXPR found_vers "${found_kde_major_vers}*10000 + ${found_kde_minor_vers}*100 + ${found_kde_patch_vers}")
-
- IF (found_vers LESS req_vers)
- SET(KDE4_FOUND FALSE)
- SET(KDE4_INSTALLED_VERSION_TOO_OLD TRUE)
- ENDIF (found_vers LESS req_vers)
+ MACRO_ENSURE_VERSION( ${KDE_MIN_VERSION} ${KDEVERSION} KDE4_INSTALLED_VERSION_TOO_OLD )
+
ELSE (KDEVERSION)
message(FATAL_ERROR "Couldn't parse KDE version string from the kde-config output:\n${kdeconfig_output}")
ENDIF (KDEVERSION)