ENH: update for Tcl/Tk 8.5
[cmake.git] / Modules / FindQt.cmake
blob63b6de951ba4d42194971b7bff103c6a8c1b96d7
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
10 # is included.
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)
23 IF(GLOB_TEMP_VAR)
24   SET(QT3_INSTALLED TRUE)
25 ENDIF(GLOB_TEMP_VAR)
26 SET(GLOB_TEMP_VAR)
28 FILE(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-3*/bin/qmake)
29 IF(GLOB_TEMP_VAR)
30   SET(QT3_INSTALLED TRUE)
31 ENDIF(GLOB_TEMP_VAR)
32 SET(GLOB_TEMP_VAR)
34 # look for qt4 installations
35 FILE(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-4*/bin/qmake)
36 IF(GLOB_TEMP_VAR)
37   SET(QT4_INSTALLED TRUE)
38 ENDIF(GLOB_TEMP_VAR)
39 SET(GLOB_TEMP_VAR)
41 FILE(GLOB GLOB_TEMP_VAR /usr/local/Trolltech/Qt-4*/bin/qmake)
42 IF(GLOB_TEMP_VAR)
43   SET(QT4_INSTALLED TRUE)
44 ENDIF(GLOB_TEMP_VAR)
45 SET(GLOB_TEMP_VAR)
47 # now find qmake
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"
71   ${qt_headers}/Qt
72   $ENV{QTDIR}/include/Qt
73   /usr/local/qt/include/Qt
74   /usr/local/include/Qt
75   /usr/lib/qt/include/Qt
76   /usr/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
90   $ENV{QTDIR}/include
91   /usr/include/qt3/Qt
92   /usr/local/qt/include
93   /usr/local/include
94   /usr/lib/qt/include
95   /usr/include
96   /usr/share/qt3/include
97   C:/Progra~1/qt/include
98   /usr/include/qt3 )
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
109   IF(QT3_INSTALLED)
110     SET(DESIRED_QT_VERSION 3 CACHE STRING "Pick a version of QT to use: 3 or 4")
111   ENDIF(QT3_INSTALLED)
112   IF(QT4_INSTALLED)
113     SET(DESIRED_QT_VERSION 4 CACHE STRING "Pick a version of QT to use: 3 or 4")
114   ENDIF(QT4_INSTALLED)
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})
120   INCLUDE(FindQt3)
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})
125   INCLUDE(FindQt4)
126 ENDIF(DESIRED_QT_VERSION MATCHES 4)
128 IF(NOT QT3_INSTALLED AND NOT QT4_INSTALLED)
129   IF(QT_REQUIRED)
130     MESSAGE(SEND_ERROR "CMake was unable to find any QT versions, put qmake in your path, or set QT_QMAKE_EXECUTABLE.")
131   ENDIF(QT_REQUIRED)
132 ELSE(NOT QT3_INSTALLED AND NOT QT4_INSTALLED)
133   IF(NOT QT_FOUND AND NOT DESIRED_QT_VERSION)
134     IF(QT_REQUIRED)
135       MESSAGE(SEND_ERROR "Multiple versions of QT found please set DESIRED_QT_VERSION")
136     ELSE(QT_REQUIRED)
137       MESSAGE("Multiple versions of QT found please set DESIRED_QT_VERSION")
138     ENDIF(QT_REQUIRED)
139   ENDIF(NOT QT_FOUND AND NOT DESIRED_QT_VERSION)
140   IF(NOT QT_FOUND AND DESIRED_QT_VERSION)
141     IF(QT_REQUIRED)
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.")
143     ELSE(QT_REQUIRED)
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.")
145     ENDIF(QT_REQUIRED)
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)