summaryrefslogtreecommitdiff
path: root/Modules/FindQt.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/FindQt.cmake')
-rw-r--r--Modules/FindQt.cmake71
1 files changed, 39 insertions, 32 deletions
diff --git a/Modules/FindQt.cmake b/Modules/FindQt.cmake
index 54b7c6f97..4d8aea92e 100644
--- a/Modules/FindQt.cmake
+++ b/Modules/FindQt.cmake
@@ -1,34 +1,37 @@
-# - Searches for all installed versions of Qt.
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#.rst:
+# FindQt
+# ------
+#
+# Searches for all installed versions of Qt.
+#
# This should only be used if your project can work with multiple
-# versions of Qt. If not, you should just directly use FindQt4 or FindQt3.
-# If multiple versions of Qt are found on the machine, then
-# The user must set the option DESIRED_QT_VERSION to the version
-# they want to use. If only one version of qt is found on the machine,
-# then the DESIRED_QT_VERSION is set to that version and the
-# matching FindQt3 or FindQt4 module is included.
-# Once the user sets DESIRED_QT_VERSION, then the FindQt3 or FindQt4 module
-# is included.
+# versions of Qt. If not, you should just directly use FindQt4 or
+# FindQt3. If multiple versions of Qt are found on the machine, then
+# The user must set the option DESIRED_QT_VERSION to the version they
+# want to use. If only one version of qt is found on the machine, then
+# the DESIRED_QT_VERSION is set to that version and the matching FindQt3
+# or FindQt4 module is included. Once the user sets DESIRED_QT_VERSION,
+# then the FindQt3 or FindQt4 module is included.
+#
+# This module can only detect and switch between Qt versions 3 and 4. It
+# cannot handle Qt5 or any later versions.
+#
+# ::
+#
+# QT_REQUIRED if this is set to TRUE then if CMake can
+# not find Qt4 or Qt3 an error is raised
+# and a message is sent to the user.
#
-# QT_REQUIRED if this is set to TRUE then if CMake can
-# not find Qt4 or Qt3 an error is raised
-# and a message is sent to the user.
#
-# DESIRED_QT_VERSION OPTION is created
-# QT4_INSTALLED is set to TRUE if qt4 is found.
-# QT3_INSTALLED is set to TRUE if qt3 is found.
-
-#=============================================================================
-# Copyright 2001-2009 Kitware, Inc.
#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
+# ::
#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-# License text for the above reference.)
+# DESIRED_QT_VERSION OPTION is created
+# QT4_INSTALLED is set to TRUE if qt4 is found.
+# QT3_INSTALLED is set to TRUE if qt3 is found.
# look for signs of qt3 installations
file(GLOB GLOB_TEMP_VAR /usr/lib*/qt-3*/bin/qmake /usr/lib*/qt3*/bin/qmake)
@@ -69,7 +72,11 @@ endif()
set(GLOB_TEMP_VAR)
if (Qt_FIND_VERSION)
- set(DESIRED_QT_VERSION "${Qt_FIND_VERSION}")
+ if (Qt_FIND_VERSION MATCHES "^([34])(\\.[0-9]+.*)?$")
+ set(DESIRED_QT_VERSION ${CMAKE_MATCH_1})
+ else ()
+ message(FATAL_ERROR "FindQt was called with invalid version '${Qt_FIND_VERSION}'. Only Qt major versions 3 or 4 are supported. If you do not need to support both Qt3 and Qt4 in your source consider calling find_package(Qt3) or find_package(Qt4) instead of find_package(Qt) instead.")
+ endif ()
endif ()
# now find qmake
@@ -77,7 +84,7 @@ find_program(QT_QMAKE_EXECUTABLE_FINDQT NAMES qmake PATHS "${QT_SEARCH_PATH}/bin
if(QT_QMAKE_EXECUTABLE_FINDQT)
exec_program(${QT_QMAKE_EXECUTABLE_FINDQT} ARGS "-query QT_VERSION"
OUTPUT_VARIABLE QTVERSION)
- if(QTVERSION MATCHES "4.*")
+ if(QTVERSION MATCHES "4")
set(QT_QMAKE_EXECUTABLE ${QT_QMAKE_EXECUTABLE_FINDQT} CACHE PATH "Qt4 qmake program.")
set(QT4_INSTALLED TRUE)
endif()
@@ -144,12 +151,12 @@ else()
endif()
endif()
-if(DESIRED_QT_VERSION MATCHES 3)
+if(DESIRED_QT_VERSION EQUAL 3)
set(Qt3_FIND_REQUIRED ${Qt_FIND_REQUIRED})
set(Qt3_FIND_QUIETLY ${Qt_FIND_QUIETLY})
include(${CMAKE_CURRENT_LIST_DIR}/FindQt3.cmake)
endif()
-if(DESIRED_QT_VERSION MATCHES 4)
+if(DESIRED_QT_VERSION EQUAL 4)
set(Qt4_FIND_REQUIRED ${Qt_FIND_REQUIRED})
set(Qt4_FIND_QUIETLY ${Qt_FIND_QUIETLY})
include(${CMAKE_CURRENT_LIST_DIR}/FindQt4.cmake)
@@ -169,9 +176,9 @@ else()
endif()
if(NOT QT_FOUND AND DESIRED_QT_VERSION)
if(QT_REQUIRED)
- message(FATAL_ERROR "CMake was unable to find Qt version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_FILE, if those are set then QT_QT_LIBRARY or QT_LIBRARY_DIR.")
+ message(FATAL_ERROR "CMake was unable to find Qt version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_H_FILE, if those are set then QT_QT_LIBRARY or QT_LIBRARY_DIR.")
else()
- message( "CMake was unable to find desired Qt version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_FILE.")
+ message( "CMake was unable to find desired Qt version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_H_FILE.")
endif()
endif()
endif()