Commit 5aa0f243 authored by David Cole's avatar David Cole Committed by Kitware Robot

Merge topic 'improve-findqt3'

678c24d2 FindQt3: fix detection of Qt3 include directory
91a1670f FindQt3: let FPHSA handle the version selection
9dae4d65 FindQt3: fix version extraction for versions with letters
2cd898d5 FindQt3: fix warning when Qt3 is not found
parents ef661371 678c24d2
# - 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..*")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment