From 49d05a4713729d7531192ae16fc94511dac9b8ec Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 16 Jan 2015 20:50:15 +0100 Subject: FindQt: fix setting DESIRED_QT_VERSION if "find_package(Qt VVV)" was called In case the given version was not only "3" or "4", but something like "4.8" DESIRED_QT_VERSION was set to an unsupported value. While at it also check that the version passed in is really in the range of 3.x and 4.x. Also suggest switching to the more specific find modules if possible. --- Modules/FindQt.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Modules/FindQt.cmake b/Modules/FindQt.cmake index 1bc0940..19f1773 100644 --- a/Modules/FindQt.cmake +++ b/Modules/FindQt.cmake @@ -79,7 +79,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 -- cgit v0.12 From 6af8cbf214c7de6ef4bb036cb9f6c4bc147fd511 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 16 Jan 2015 20:59:12 +0100 Subject: FindQt: fix variable name in error message --- Modules/FindQt.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/FindQt.cmake b/Modules/FindQt.cmake index 19f1773..8014768 100644 --- a/Modules/FindQt.cmake +++ b/Modules/FindQt.cmake @@ -183,9 +183,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() -- cgit v0.12 From b937f7537943e56998f1f4630e3684ca7417442b Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 16 Jan 2015 22:04:29 +0100 Subject: FindQt: explicitely mention that it cannot Qt5 or later --- Modules/FindQt.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/FindQt.cmake b/Modules/FindQt.cmake index 8014768..41b7271 100644 --- a/Modules/FindQt.cmake +++ b/Modules/FindQt.cmake @@ -13,6 +13,9 @@ # 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 -- cgit v0.12