1 # - Searches for all installed versions of Qt.
2 # This should only be used if your project can work with multiple
3 # versions of Qt. If not, you should just directly use FindQt4 or FindQt3.
4 # If multiple versions of Qt are found on the machine, then
5 # The user must set the option DESIRED_QT_VERSION to the version
6 # they want to use. If only one version of qt is found on the machine,
7 # then the DESIRED_QT_VERSION is set to that version and the
8 # matching FindQt3 or FindQt4 module is included.
9 # Once the user sets DESIRED_QT_VERSION, then the FindQt3 or FindQt4 module
12 # QT_REQUIRED if this is set to TRUE then if CMake can
13 # not find Qt4 or Qt3 an error is raised
14 # and a message is sent to the user.
16 # DESIRED_QT_VERSION OPTION is created
17 # QT4_INSTALLED is set to TRUE if qt4 is found.
18 # QT3_INSTALLED is set to TRUE if qt3 is found.
20 #=============================================================================
21 # Copyright 2001-2009 Kitware, Inc.
23 # Distributed under the OSI-approved BSD License (the "License");
24 # see accompanying file Copyright.txt for details.
26 # This software is distributed WITHOUT ANY WARRANTY; without even the
27 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
28 # See the License for more information.
29 #=============================================================================
30 # (To distribute this file outside of CMake, substitute the full
31 # License text for the above reference.)
33 # look for signs of qt3 installations
34 file(GLOB GLOB_TEMP_VAR /usr/lib*/qt-3*/bin/qmake /usr/lib*/qt3*/bin/qmake)
36 set(QT3_INSTALLED TRUE)
40 file(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-3*/bin/qmake)
42 set(QT3_INSTALLED TRUE)
46 file(GLOB GLOB_TEMP_VAR /usr/local/lib/qt3/bin/qmake)
48 set(QT3_INSTALLED TRUE)
52 # look for qt4 installations
53 file(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-4*/bin/qmake)
55 set(QT4_INSTALLED TRUE)
59 file(GLOB GLOB_TEMP_VAR /usr/local/Trolltech/Qt-4*/bin/qmake)
61 set(QT4_INSTALLED TRUE)
65 file(GLOB GLOB_TEMP_VAR /usr/local/lib/qt4/bin/qmake)
67 set(QT4_INSTALLED TRUE)
72 set(DESIRED_QT_VERSION "${Qt_FIND_VERSION}")
76 find_program(QT_QMAKE_EXECUTABLE_FINDQT NAMES qmake PATHS "${QT_SEARCH_PATH}/bin" "$ENV{QTDIR}/bin")
77 if(QT_QMAKE_EXECUTABLE_FINDQT)
78 exec_program(${QT_QMAKE_EXECUTABLE_FINDQT} ARGS "-query QT_VERSION"
79 OUTPUT_VARIABLE QTVERSION)
80 if(QTVERSION MATCHES "4.*")
81 set(QT_QMAKE_EXECUTABLE ${QT_QMAKE_EXECUTABLE_FINDQT} CACHE PATH "Qt4 qmake program.")
82 set(QT4_INSTALLED TRUE)
84 if(QTVERSION MATCHES "Unknown")
85 set(QT3_INSTALLED TRUE)
89 if(QT_QMAKE_EXECUTABLE_FINDQT)
90 exec_program( ${QT_QMAKE_EXECUTABLE_FINDQT}
91 ARGS "-query QT_INSTALL_HEADERS"
92 OUTPUT_VARIABLE qt_headers )
95 find_file( QT4_QGLOBAL_H_FILE qglobal.h
96 "${QT_SEARCH_PATH}/Qt/include"
97 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/include/Qt"
98 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/include/Qt"
100 $ENV{QTDIR}/include/Qt
101 /usr/local/qt/include/Qt
102 /usr/local/include/Qt
103 /usr/lib/qt/include/Qt
105 /usr/share/qt4/include/Qt
106 /usr/local/include/X11/qt4/Qt
107 C:/Progra~1/qt/include/Qt )
109 if(QT4_QGLOBAL_H_FILE)
110 set(QT4_INSTALLED TRUE)
113 find_file( QT3_QGLOBAL_H_FILE qglobal.h
114 "${QT_SEARCH_PATH}/Qt/include"
115 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/include/Qt"
116 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt"
117 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt"
118 C:/Qt/3.3.3Educational/include
121 /usr/local/qt/include
125 /usr/share/qt3/include
126 /usr/local/include/X11/qt3
127 C:/Progra~1/qt/include
130 if(QT3_QGLOBAL_H_FILE)
131 set(QT3_INSTALLED TRUE)
134 if(QT3_INSTALLED AND QT4_INSTALLED AND NOT DESIRED_QT_VERSION)
135 # force user to pick if we have both
136 set(DESIRED_QT_VERSION 0 CACHE STRING "Pick a version of Qt to use: 3 or 4")
138 # if only one found then pick that one
139 if(QT3_INSTALLED AND NOT DESIRED_QT_VERSION EQUAL 4)
140 set(DESIRED_QT_VERSION 3 CACHE STRING "Pick a version of Qt to use: 3 or 4")
142 if(QT4_INSTALLED AND NOT DESIRED_QT_VERSION EQUAL 3)
143 set(DESIRED_QT_VERSION 4 CACHE STRING "Pick a version of Qt to use: 3 or 4")
147 if(DESIRED_QT_VERSION MATCHES 3)
148 set(Qt3_FIND_REQUIRED ${Qt_FIND_REQUIRED})
149 set(Qt3_FIND_QUIETLY ${Qt_FIND_QUIETLY})
150 include(${CMAKE_CURRENT_LIST_DIR}/FindQt3.cmake)
152 if(DESIRED_QT_VERSION MATCHES 4)
153 set(Qt4_FIND_REQUIRED ${Qt_FIND_REQUIRED})
154 set(Qt4_FIND_QUIETLY ${Qt_FIND_QUIETLY})
155 include(${CMAKE_CURRENT_LIST_DIR}/FindQt4.cmake)
158 if(NOT QT3_INSTALLED AND NOT QT4_INSTALLED)
160 message(SEND_ERROR "CMake was unable to find any Qt versions, put qmake in your path, or set QT_QMAKE_EXECUTABLE.")
163 if(NOT QT_FOUND AND NOT DESIRED_QT_VERSION)
165 message(SEND_ERROR "Multiple versions of Qt found please set DESIRED_QT_VERSION")
167 message("Multiple versions of Qt found please set DESIRED_QT_VERSION")
170 if(NOT QT_FOUND AND DESIRED_QT_VERSION)
172 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.")
174 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.")
178 mark_as_advanced(QT3_QGLOBAL_H_FILE QT4_QGLOBAL_H_FILE QT_QMAKE_EXECUTABLE_FINDQT)