summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2012-03-06 20:26:31 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2012-03-06 20:26:31 (GMT)
commit5aa0f24350fbb59daa3e7269ada2cf1caf9abd1c (patch)
tree6216d8810fefe5330b6a91e956873d2aee84c6fc /Modules
parentef6613718ee899d14f9021387742084b1ee33098 (diff)
parent678c24d230d7abcdb2ace778d59b8c1286d86a8a (diff)
downloadCMake-5aa0f24350fbb59daa3e7269ada2cf1caf9abd1c.zip
CMake-5aa0f24350fbb59daa3e7269ada2cf1caf9abd1c.tar.gz
CMake-5aa0f24350fbb59daa3e7269ada2cf1caf9abd1c.tar.bz2
Merge topic 'improve-findqt3'
678c24d FindQt3: fix detection of Qt3 include directory 91a1670 FindQt3: let FPHSA handle the version selection 9dae4d6 FindQt3: fix version extraction for versions with letters 2cd898d FindQt3: fix warning when Qt3 is not found
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindQt3.cmake91
1 files changed, 31 insertions, 60 deletions
diff --git a/Modules/FindQt3.cmake b/Modules/FindQt3.cmake
index 86236cc..2d8dbde 100644
--- a/Modules/FindQt3.cmake
+++ b/Modules/FindQt3.cmake
@@ -1,10 +1,11 @@
# - Locate Qt include paths and libraries
# This module defines:
-# QT_INCLUDE_DIR - where to find qt.h, etc.
-# QT_LIBRARIES - the libraries to link against to use Qt.
-# QT_DEFINITIONS - definitions to use when
-# compiling code that uses Qt.
-# QT_FOUND - If false, don't try to use Qt.
+# QT_INCLUDE_DIR - where to find qt.h, etc.
+# QT_LIBRARIES - the libraries to link against to use Qt.
+# QT_DEFINITIONS - definitions to use when
+# compiling code that uses Qt.
+# QT_FOUND - If false, don't try to use Qt.
+# QT_VERSION_STRING - the version of Qt found
#
# If you need the multithreaded version of Qt, set QT_MT_REQUIRED to TRUE
#
@@ -46,13 +47,16 @@ IF(QT4_FOUND)
ENDIF(QT4_FOUND)
-FILE(GLOB GLOB_PATHS_BIN /usr/lib/qt-3*/bin/)
+FILE(GLOB GLOB_PATHS /usr/lib/qt-3*)
+FOREACH(GLOB_PATH ${GLOB_PATHS})
+ LIST(APPEND GLOB_PATHS_BIN "${GLOB_PATH}/bin")
+ENDFOREACH(GLOB_PATH)
FIND_PATH(QT_INCLUDE_DIR qt.h
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/include/Qt"
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt"
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt"
$ENV{QTDIR}/include
- ${GLOB_PATHS_BIN}
+ ${GLOB_PATHS}
/usr/local/qt/include
/usr/lib/qt/include
/usr/lib/qt3/include
@@ -71,12 +75,13 @@ ENDIF(NOT EXISTS ${QT_INCLUDE_DIR}/qglobal.h)
IF(QT_INCLUDE_DIR)
#extract the version string from qglobal.h
FILE(READ ${QT_INCLUDE_DIR}/qglobal.h QGLOBAL_H)
- STRING(REGEX MATCH "#define[\t ]+QT_VERSION_STR[\t ]+\"([0-9]+.[0-9]+.[0-9]+)\"" QGLOBAL_H "${QGLOBAL_H}")
- STRING(REGEX REPLACE ".*\"([0-9]+.[0-9]+.[0-9]+)\".*" "\\1" qt_version_str "${QGLOBAL_H}")
+ STRING(REGEX MATCH "#define[\t ]+QT_VERSION_STR[\t ]+\"[0-9]+.[0-9]+.[0-9]+[a-z]*\"" QGLOBAL_H "${QGLOBAL_H}")
+ STRING(REGEX REPLACE ".*\"([0-9]+.[0-9]+.[0-9]+[a-z]*)\".*" "\\1" qt_version_str "${QGLOBAL_H}")
# Under windows the qt library (MSVC) has the format qt-mtXYZ where XYZ is the
# version X.Y.Z, so we need to remove the dots from version
STRING(REGEX REPLACE "\\." "" qt_version_str_lib "${qt_version_str}")
+ SET(QT_VERSION_STRING "${qt_version_str}")
ENDIF(QT_INCLUDE_DIR)
FILE(GLOB GLOB_PATHS_LIB /usr/lib/qt-3*/lib/)
@@ -195,58 +200,16 @@ IF (WIN32)
)
ENDIF (WIN32)
-
-IF (QT_MIN_VERSION)
-
- STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" qt_major_vers "${qt_version_str}")
- STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" qt_minor_vers "${qt_version_str}")
- STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" qt_patch_vers "${qt_version_str}")
-
- #now parse the parts of the user given version string into variables
- STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+$" req_qt_major_vers "${QT_MIN_VERSION}")
- IF (NOT req_qt_major_vers)
- error_message( "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"3.1.5\"")
- ENDIF (NOT req_qt_major_vers)
-
- STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}")
- 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}")
-
- # req = "6.5.4", qt = "3.2.1"
- MACRO(error_message msg)
- IF(QT3_REQUIRED)
- MESSAGE( FATAL_ERROR ${msg})
- ELSE(QT3_REQUIRED)
- MESSAGE( STATUS ${msg})
- ENDIF(QT3_REQUIRED)
- ENDMACRO(error_message)
-
- IF (req_qt_major_vers GREATER qt_major_vers) # (6 > 3) ?
- ERROR_MESSAGE( "Qt major version not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes
- ELSE (req_qt_major_vers GREATER qt_major_vers) # no
- IF (req_qt_major_vers LESS qt_major_vers) # (6 < 3) ?
- SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes
- ELSE (req_qt_major_vers LESS qt_major_vers) # ( 6==3) ?
- IF (req_qt_minor_vers GREATER qt_minor_vers) # (5>2) ?
- ERROR_MESSAGE( "Qt minor version not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes
- ELSE (req_qt_minor_vers GREATER qt_minor_vers) # no
- IF (req_qt_minor_vers LESS qt_minor_vers) # (5<2) ?
- SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes
- ELSE (req_qt_minor_vers LESS qt_minor_vers) # (5==2)
- IF (req_qt_patch_vers GREATER qt_patch_vers) # (4>1) ?
- ERROR_MESSAGE( "Qt patch level not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes
- ELSE (req_qt_patch_vers GREATER qt_patch_vers) # (4>1) ?
- SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes
- ENDIF (req_qt_patch_vers GREATER qt_patch_vers) # (4>1) ?
- ENDIF (req_qt_minor_vers LESS qt_minor_vers)
- ENDIF (req_qt_minor_vers GREATER qt_minor_vers)
- ENDIF (req_qt_major_vers LESS qt_major_vers)
- ENDIF (req_qt_major_vers GREATER qt_major_vers)
-ENDIF (QT_MIN_VERSION)
+#support old QT_MIN_VERSION if set, but not if version is supplied by find_package()
+IF(NOT Qt3_FIND_VERSION AND QT_MIN_VERSION)
+ SET(Qt3_FIND_VERSION ${QT_MIN_VERSION})
+ENDIF(NOT Qt3_FIND_VERSION AND QT_MIN_VERSION)
# if the include a library are found then we have it
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Qt3 DEFAULT_MSG QT_QT_LIBRARY QT_INCLUDE_DIR QT_MOC_EXECUTABLE)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Qt3
+ REQUIRED_VARS QT_QT_LIBRARY QT_INCLUDE_DIR QT_MOC_EXECUTABLE
+ VERSION_VAR QT_VERSION_STRING)
SET(QT_FOUND ${QT3_FOUND} )
IF(QT_FOUND)
@@ -296,8 +259,16 @@ IF(QT_FOUND)
ENDIF(QT_QT_LIBRARY MATCHES "qt-mt")
ENDIF(QT_FOUND)
-EXEC_PROGRAM(${QT_MOC_EXECUTABLE} ARGS "-v" OUTPUT_VARIABLE QTVERSION_MOC)
-EXEC_PROGRAM(${QT_UIC_EXECUTABLE} ARGS "-version" OUTPUT_VARIABLE QTVERSION_UIC)
+IF(QT_MOC_EXECUTABLE)
+ EXECUTE_PROCESS(COMMAND ${QT_MOC_EXECUTABLE} "-v"
+ OUTPUT_VARIABLE QTVERSION_MOC
+ ERROR_QUIET)
+ENDIF(QT_MOC_EXECUTABLE)
+IF(QT_UIC_EXECUTABLE)
+ EXECUTE_PROCESS(COMMAND ${QT_UIC_EXECUTABLE} "-version"
+ OUTPUT_VARIABLE QTVERSION_UIC
+ ERROR_QUIET)
+ENDIF(QT_UIC_EXECUTABLE)
SET(_QT_UIC_VERSION_3 FALSE)
IF("${QTVERSION_UIC}" MATCHES ".* 3..*")