1# Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2# file Copyright.txt or https://cmake.org/licensing for details. 3 4#[=======================================================================[.rst: 5FindQt 6------ 7 8.. deprecated:: 3.14 9 This module is available only if policy :policy:`CMP0084` is not set to ``NEW``. 10 11Searches for all installed versions of Qt3 or Qt4. 12 13This module cannot handle Qt5 or any later versions. 14For those, see :manual:`cmake-qt(7)`. 15 16This module should only be used if your project can work with multiple 17versions of Qt. If not, you should just directly use FindQt4 or 18FindQt3. If multiple versions of Qt are found on the machine, then 19The user must set the option DESIRED_QT_VERSION to the version they 20want to use. If only one version of qt is found on the machine, then 21the DESIRED_QT_VERSION is set to that version and the matching FindQt3 22or FindQt4 module is included. Once the user sets DESIRED_QT_VERSION, 23then the FindQt3 or FindQt4 module is included. 24 25:: 26 27 QT_REQUIRED if this is set to TRUE then if CMake can 28 not find Qt4 or Qt3 an error is raised 29 and a message is sent to the user. 30 31 32 33:: 34 35 DESIRED_QT_VERSION OPTION is created 36 QT4_INSTALLED is set to TRUE if qt4 is found. 37 QT3_INSTALLED is set to TRUE if qt3 is found. 38#]=======================================================================] 39 40if(_findqt_testing) 41 set(_findqt_included TRUE) 42 return() 43endif() 44 45# look for signs of qt3 installations 46file(GLOB GLOB_TEMP_VAR /usr/lib*/qt-3*/bin/qmake /usr/lib*/qt3*/bin/qmake) 47if(GLOB_TEMP_VAR) 48 set(QT3_INSTALLED TRUE) 49endif() 50set(GLOB_TEMP_VAR) 51 52file(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-3*/bin/qmake) 53if(GLOB_TEMP_VAR) 54 set(QT3_INSTALLED TRUE) 55endif() 56set(GLOB_TEMP_VAR) 57 58file(GLOB GLOB_TEMP_VAR /usr/local/lib/qt3/bin/qmake) 59if(GLOB_TEMP_VAR) 60 set(QT3_INSTALLED TRUE) 61endif() 62set(GLOB_TEMP_VAR) 63 64# look for qt4 installations 65file(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-4*/bin/qmake) 66if(GLOB_TEMP_VAR) 67 set(QT4_INSTALLED TRUE) 68endif() 69set(GLOB_TEMP_VAR) 70 71file(GLOB GLOB_TEMP_VAR /usr/local/Trolltech/Qt-4*/bin/qmake) 72if(GLOB_TEMP_VAR) 73 set(QT4_INSTALLED TRUE) 74endif() 75set(GLOB_TEMP_VAR) 76 77file(GLOB GLOB_TEMP_VAR /usr/local/lib/qt4/bin/qmake) 78if(GLOB_TEMP_VAR) 79 set(QT4_INSTALLED TRUE) 80endif() 81set(GLOB_TEMP_VAR) 82 83if (Qt_FIND_VERSION) 84 if (Qt_FIND_VERSION MATCHES "^([34])(\\.[0-9]+.*)?$") 85 set(DESIRED_QT_VERSION ${CMAKE_MATCH_1}) 86 else () 87 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.") 88 endif () 89endif () 90 91# now find qmake 92find_program(QT_QMAKE_EXECUTABLE_FINDQT NAMES qmake PATHS "${QT_SEARCH_PATH}/bin" "$ENV{QTDIR}/bin") 93if(QT_QMAKE_EXECUTABLE_FINDQT) 94 exec_program(${QT_QMAKE_EXECUTABLE_FINDQT} ARGS "-query QT_VERSION" 95 OUTPUT_VARIABLE QTVERSION) 96 if(QTVERSION MATCHES "4") 97 set(QT_QMAKE_EXECUTABLE ${QT_QMAKE_EXECUTABLE_FINDQT} CACHE PATH "Qt4 qmake program.") 98 set(QT4_INSTALLED TRUE) 99 endif() 100 if(QTVERSION MATCHES "Unknown") 101 set(QT3_INSTALLED TRUE) 102 endif() 103endif() 104 105if(QT_QMAKE_EXECUTABLE_FINDQT) 106 exec_program( ${QT_QMAKE_EXECUTABLE_FINDQT} 107 ARGS "-query QT_INSTALL_HEADERS" 108 OUTPUT_VARIABLE qt_headers ) 109endif() 110 111find_file( QT4_QGLOBAL_H_FILE qglobal.h 112 "${QT_SEARCH_PATH}/Qt/include" 113 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/include/Qt" 114 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/include/Qt" 115 ${qt_headers}/Qt 116 $ENV{QTDIR}/include/Qt 117 /usr/lib/qt/include/Qt 118 /usr/share/qt4/include/Qt 119 /usr/local/include/X11/qt4/Qt 120 C:/Progra~1/qt/include/Qt 121 PATH_SUFFIXES qt/include/Qt include/Qt) 122 123if(QT4_QGLOBAL_H_FILE) 124 set(QT4_INSTALLED TRUE) 125endif() 126 127find_file( QT3_QGLOBAL_H_FILE qglobal.h 128 "${QT_SEARCH_PATH}/Qt/include" 129 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/include/Qt" 130 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt" 131 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt" 132 C:/Qt/3.3.3Educational/include 133 $ENV{QTDIR}/include 134 /usr/include/qt3/Qt 135 /usr/share/qt3/include 136 /usr/local/include/X11/qt3 137 C:/Progra~1/qt/include 138 PATH_SUFFIXES qt/include include/qt3) 139 140if(QT3_QGLOBAL_H_FILE) 141 set(QT3_INSTALLED TRUE) 142endif() 143 144if(QT3_INSTALLED AND QT4_INSTALLED AND NOT DESIRED_QT_VERSION) 145 # force user to pick if we have both 146 set(DESIRED_QT_VERSION 0 CACHE STRING "Pick a version of Qt to use: 3 or 4") 147else() 148 # if only one found then pick that one 149 if(QT3_INSTALLED AND NOT DESIRED_QT_VERSION EQUAL 4) 150 set(DESIRED_QT_VERSION 3 CACHE STRING "Pick a version of Qt to use: 3 or 4") 151 endif() 152 if(QT4_INSTALLED AND NOT DESIRED_QT_VERSION EQUAL 3) 153 set(DESIRED_QT_VERSION 4 CACHE STRING "Pick a version of Qt to use: 3 or 4") 154 endif() 155endif() 156 157if(DESIRED_QT_VERSION EQUAL 3) 158 set(Qt3_FIND_REQUIRED ${Qt_FIND_REQUIRED}) 159 set(Qt3_FIND_QUIETLY ${Qt_FIND_QUIETLY}) 160 include(${CMAKE_CURRENT_LIST_DIR}/FindQt3.cmake) 161endif() 162if(DESIRED_QT_VERSION EQUAL 4) 163 set(Qt4_FIND_REQUIRED ${Qt_FIND_REQUIRED}) 164 set(Qt4_FIND_QUIETLY ${Qt_FIND_QUIETLY}) 165 include(${CMAKE_CURRENT_LIST_DIR}/FindQt4.cmake) 166endif() 167 168if(NOT QT3_INSTALLED AND NOT QT4_INSTALLED) 169 if(QT_REQUIRED) 170 message(SEND_ERROR "CMake was unable to find any Qt versions, put qmake in your path, or set QT_QMAKE_EXECUTABLE.") 171 endif() 172else() 173 if(NOT QT_FOUND AND NOT DESIRED_QT_VERSION) 174 if(QT_REQUIRED) 175 message(SEND_ERROR "Multiple versions of Qt found please set DESIRED_QT_VERSION") 176 else() 177 message("Multiple versions of Qt found please set DESIRED_QT_VERSION") 178 endif() 179 endif() 180 if(NOT QT_FOUND AND DESIRED_QT_VERSION) 181 if(QT_REQUIRED) 182 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.") 183 else() 184 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.") 185 endif() 186 endif() 187endif() 188mark_as_advanced(QT3_QGLOBAL_H_FILE QT4_QGLOBAL_H_FILE QT_QMAKE_EXECUTABLE_FINDQT) 189