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.
21 # look for signs of qt3 installations
22 FILE(GLOB GLOB_TEMP_VAR /usr/lib/qt-3*/bin/qmake)
24 SET(QT3_INSTALLED TRUE)
28 FILE(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-3*/bin/qmake)
30 SET(QT3_INSTALLED TRUE)
34 # look for qt4 installations
35 FILE(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-4*/bin/qmake)
37 SET(QT4_INSTALLED TRUE)
41 FILE(GLOB GLOB_TEMP_VAR /usr/local/Trolltech/Qt-4*/bin/qmake)
43 SET(QT4_INSTALLED TRUE)
48 FIND_PROGRAM(QT_QMAKE_EXECUTABLE_FINDQT NAMES qmake PATHS "${QT_SEARCH_PATH}/bin" "$ENV{QTDIR}/bin")
49 IF(QT_QMAKE_EXECUTABLE_FINDQT)
50 EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE_FINDQT} ARGS "-query QT_VERSION"
51 OUTPUT_VARIABLE QTVERSION)
52 IF(QTVERSION MATCHES "4.*")
53 SET(QT_QMAKE_EXECUTABLE ${QT_QMAKE_EXECUTABLE_FINDQT} CACHE PATH "QT4 qmake program.")
54 SET(QT4_INSTALLED TRUE)
55 ENDIF(QTVERSION MATCHES "4.*")
56 IF(QTVERSION MATCHES "Unknown")
57 SET(QT3_INSTALLED TRUE)
58 ENDIF(QTVERSION MATCHES "Unknown")
59 ENDIF(QT_QMAKE_EXECUTABLE_FINDQT)
61 IF(QT_QMAKE_EXECUTABLE_FINDQT)
62 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE_FINDQT}
63 ARGS "-query QT_INSTALL_HEADERS"
64 OUTPUT_VARIABLE qt_headers )
65 ENDIF(QT_QMAKE_EXECUTABLE_FINDQT)
67 FIND_FILE( QT4_QGLOBAL_H_FILE qglobal.h
68 "${QT_SEARCH_PATH}/Qt/include"
69 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/include/Qt"
70 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/include/Qt"
72 $ENV{QTDIR}/include/Qt
73 /usr/local/qt/include/Qt
75 /usr/lib/qt/include/Qt
77 /usr/share/qt4/include/Qt
78 C:/Progra~1/qt/include/Qt )
80 IF(QT4_QGLOBAL_H_FILE)
81 SET(QT4_INSTALLED TRUE)
82 ENDIF(QT4_QGLOBAL_H_FILE)
84 FIND_FILE( QT3_QGLOBAL_H_FILE qglobal.h
85 "${QT_SEARCH_PATH}/Qt/include"
86 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/include/Qt"
87 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt"
88 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt"
89 C:/Qt/3.3.3Educational/include
96 /usr/share/qt3/include
97 C:/Progra~1/qt/include
100 IF(QT3_QGLOBAL_H_FILE)
101 SET(QT3_INSTALLED TRUE)
102 ENDIF(QT3_QGLOBAL_H_FILE)
104 IF(QT3_INSTALLED AND QT4_INSTALLED )
105 # force user to pick if we have both
106 SET(DESIRED_QT_VERSION 0 CACHE STRING "Pick a version of QT to use: 3 or 4")
107 ELSE(QT3_INSTALLED AND QT4_INSTALLED )
108 # if only one found then pick that one
110 SET(DESIRED_QT_VERSION 3 CACHE STRING "Pick a version of QT to use: 3 or 4")
113 SET(DESIRED_QT_VERSION 4 CACHE STRING "Pick a version of QT to use: 3 or 4")
115 ENDIF(QT3_INSTALLED AND QT4_INSTALLED )
117 IF(DESIRED_QT_VERSION MATCHES 3)
118 SET(Qt3_FIND_REQUIRED ${Qt_FIND_REQUIRED})
119 SET(Qt3_FIND_QUIETLY ${Qt_FIND_QUIETLY})
121 ENDIF(DESIRED_QT_VERSION MATCHES 3)
122 IF(DESIRED_QT_VERSION MATCHES 4)
123 SET(Qt4_FIND_REQUIRED ${Qt_FIND_REQUIRED})
124 SET(Qt4_FIND_QUIETLY ${Qt_FIND_QUIETLY})
126 ENDIF(DESIRED_QT_VERSION MATCHES 4)
128 IF(NOT QT3_INSTALLED AND NOT QT4_INSTALLED)
130 MESSAGE(SEND_ERROR "CMake was unable to find any QT versions, put qmake in your path, or set QT_QMAKE_EXECUTABLE.")
132 ELSE(NOT QT3_INSTALLED AND NOT QT4_INSTALLED)
133 IF(NOT QT_FOUND AND NOT DESIRED_QT_VERSION)
135 MESSAGE(SEND_ERROR "Multiple versions of QT found please set DESIRED_QT_VERSION")
137 MESSAGE("Multiple versions of QT found please set DESIRED_QT_VERSION")
139 ENDIF(NOT QT_FOUND AND NOT DESIRED_QT_VERSION)
140 IF(NOT QT_FOUND AND DESIRED_QT_VERSION)
142 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.")
144 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.")
146 ENDIF(NOT QT_FOUND AND DESIRED_QT_VERSION)
147 ENDIF(NOT QT3_INSTALLED AND NOT QT4_INSTALLED)
148 MARK_AS_ADVANCED(QT3_QGLOBAL_H_FILE QT4_QGLOBAL_H_FILE QT_QMAKE_EXECUTABLE_FINDQT)