summaryrefslogtreecommitdiffstats
path: root/Modules/FindQt4.cmake
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2009-02-19 20:51:43 (GMT)
committerClinton Stimpson <clinton@elemtech.com>2009-02-19 20:51:43 (GMT)
commitabdcf91422fe8dbb28aaeff9ed467157db8836e4 (patch)
tree935e8362f3ae3f2bbce86d628e19229f782f094f /Modules/FindQt4.cmake
parent819a4f2e57831b5c53bdca6812b4317fdea92ada (diff)
downloadCMake-abdcf91422fe8dbb28aaeff9ed467157db8836e4.zip
CMake-abdcf91422fe8dbb28aaeff9ed467157db8836e4.tar.gz
CMake-abdcf91422fe8dbb28aaeff9ed467157db8836e4.tar.bz2
ENH: Support version argument in find_package().
See bug #8542.
Diffstat (limited to 'Modules/FindQt4.cmake')
-rw-r--r--Modules/FindQt4.cmake43
1 files changed, 41 insertions, 2 deletions
diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake
index bfb9187..9978557 100644
--- a/Modules/FindQt4.cmake
+++ b/Modules/FindQt4.cmake
@@ -372,6 +372,18 @@ IF (QT_QMAKE_EXECUTABLE)
STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers "${QT_MIN_VERSION}")
STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}")
+ # Suppport finding at least a particular version, for instance FIND_PACKAGE( Qt4 4.4.3 )
+ # This implementation is a hack to avoid duplicating code and make sure we stay
+ # source-compatible with CMake 2.6.x
+ # For CMake 2.8, we should not set QT_MIN_VERSION but only use Qt4_FIND_VERSION_MAJOR,
+ # Qt4_FIND_VERSION_MINOR, etc
+ IF( Qt4_FIND_VERSION )
+ SET( QT_MIN_VERSION ${Qt4_FIND_VERSION} )
+ SET( req_qt_major_vers ${Qt4_FIND_VERSION_MAJOR} )
+ SET( req_qt_minor_vers ${Qt4_FIND_VERSION_MINOR} )
+ SET( req_qt_patch_vers ${Qt4_FIND_VERSION_PATCH} )
+ ENDIF( Qt4_FIND_VERSION )
+
IF (NOT req_qt_major_vers EQUAL 4)
MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", major version 4 is required, e.g. \"4.0.1\"")
ENDIF (NOT req_qt_major_vers EQUAL 4)
@@ -385,12 +397,27 @@ IF (QT_QMAKE_EXECUTABLE)
MATH(EXPR req_vers "${req_qt_major_vers}*10000 + ${req_qt_minor_vers}*100 + ${req_qt_patch_vers}")
MATH(EXPR found_vers "${QT_VERSION_MAJOR}*10000 + ${QT_VERSION_MINOR}*100 + ${QT_VERSION_PATCH}")
+ # Support finding *exactly* a particular version, for instance FIND_PACKAGE( Qt4 4.4.3 EXACT )
+ # The 'else' branch should be removed for CMake 2.8
+ IF( Qt4_FIND_VERSION_EXACT )
+ IF(found_vers EQUAL req_vers)
+ SET( QT4_QMAKE_FOUND TRUE )
+ ELSE(found_vers EQUAL req_vers)
+ SET( QT4_QMAKE_FOUND FALSE )
+ IF (found_vers LESS req_vers)
+ SET(QT4_INSTALLED_VERSION_TOO_OLD TRUE)
+ ELSE (found_vers LESS req_vers)
+ SET(QT4_INSTALLED_VERSION_TOO_NEW TRUE)
+ ENDIF (found_vers LESS req_vers)
+ ENDIF(found_vers EQUAL req_vers)
+ ELSE( Qt4_FIND_VERSION_EXACT )
IF (found_vers LESS req_vers)
SET(QT4_QMAKE_FOUND FALSE)
SET(QT4_INSTALLED_VERSION_TOO_OLD TRUE)
ELSE (found_vers LESS req_vers)
SET(QT4_QMAKE_FOUND TRUE)
ENDIF (found_vers LESS req_vers)
+ ENDIF( Qt4_FIND_VERSION_EXACT )
ENDIF (qt_version_tmp)
ENDIF (QT_QMAKE_EXECUTABLE)
@@ -1550,11 +1577,23 @@ IF (QT4_QMAKE_FOUND)
ELSE(QT4_QMAKE_FOUND)
SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
+
+ # The code below is overly complex to make sure we do not break compatibility with CMake 2.6.x
+ # For CMake 2.8, it should be simplified by getting rid of QT4_INSTALLED_VERSION_TOO_OLD and
+ # QT4_INSTALLED_VERSION_TOO_NEW
IF(Qt4_FIND_REQUIRED)
IF(QT4_INSTALLED_VERSION_TOO_OLD)
- MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
+ IF( Qt4_FIND_VERSION_EXACT )
+ MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, version ${QT_MIN_VERSION} is required")
+ ELSE( Qt4_FIND_VERSION_EXACT )
+ MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
+ ENDIF( Qt4_FIND_VERSION_EXACT )
ELSE(QT4_INSTALLED_VERSION_TOO_OLD)
- MESSAGE( FATAL_ERROR "Qt qmake not found!")
+ IF( Qt4_FIND_VERSION_EXACT AND QT4_INSTALLED_VERSION_TOO_NEW )
+ MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too new, version ${QT_MIN_VERSION} is required")
+ ELSE( Qt4_FIND_VERSION_EXACT AND QT4_INSTALLED_VERSION_TOO_NEW )
+ MESSAGE( FATAL_ERROR "Qt qmake not found!")
+ ENDIF( Qt4_FIND_VERSION_EXACT AND QT4_INSTALLED_VERSION_TOO_NEW )
ENDIF(QT4_INSTALLED_VERSION_TOO_OLD)
ELSE(Qt4_FIND_REQUIRED)
IF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)