TZIVI-254: IVI needs a newer version of cmake
[profile/ivi/cmake.git] / Modules / FindQt4.cmake
1 # - Find QT 4
2 # This module can be used to find Qt4.
3 # The most important issue is that the Qt4 qmake is available via the system path.
4 # This qmake is then used to detect basically everything else.
5 # This module defines a number of key variables and macros. 
6 # The variable QT_USE_FILE is set which is the path to a CMake file that can be included 
7 # to compile Qt 4 applications and libraries.  It sets up the compilation
8 # environment for include directories, preprocessor defines and populates a
9 # QT_LIBRARIES variable.
10 #
11 # Typical usage could be something like:
12 #   find_package(Qt4 4.4.3 REQUIRED QtCore QtGui QtXml)
13 #   include(${QT_USE_FILE})
14 #   add_executable(myexe main.cpp)
15 #   target_link_libraries(myexe ${QT_LIBRARIES})
16 #
17 # The minimum required version can be specified using the standard find_package()-syntax
18 # (see example above). 
19 # For compatibility with older versions of FindQt4.cmake it is also possible to
20 # set the variable QT_MIN_VERSION to the minimum required version of Qt4 before the 
21 # find_package(Qt4) command. 
22 # If both are used, the version used in the find_package() command overrides the
23 # one from QT_MIN_VERSION.
24 #
25 # When using the components argument, QT_USE_QT* variables are automatically set
26 # for the QT_USE_FILE to pick up.  If one wishes to manually set them, the
27 # available ones to set include:
28 #                    QT_DONT_USE_QTCORE
29 #                    QT_DONT_USE_QTGUI
30 #                    QT_USE_QT3SUPPORT
31 #                    QT_USE_QTASSISTANT
32 #                    QT_USE_QAXCONTAINER
33 #                    QT_USE_QAXSERVER
34 #                    QT_USE_QTDESIGNER
35 #                    QT_USE_QTMOTIF
36 #                    QT_USE_QTMAIN
37 #                    QT_USE_QTMULTIMEDIA
38 #                    QT_USE_QTNETWORK
39 #                    QT_USE_QTNSPLUGIN
40 #                    QT_USE_QTOPENGL
41 #                    QT_USE_QTSQL
42 #                    QT_USE_QTXML
43 #                    QT_USE_QTSVG
44 #                    QT_USE_QTTEST
45 #                    QT_USE_QTUITOOLS
46 #                    QT_USE_QTDBUS
47 #                    QT_USE_QTSCRIPT
48 #                    QT_USE_QTASSISTANTCLIENT
49 #                    QT_USE_QTHELP
50 #                    QT_USE_QTWEBKIT
51 #                    QT_USE_QTXMLPATTERNS
52 #                    QT_USE_PHONON
53 #                    QT_USE_QTSCRIPTTOOLS
54 #                    QT_USE_QTDECLARATIVE
55 #
56 #  QT_USE_IMPORTED_TARGETS 
57 #        If this variable is set to TRUE, FindQt4.cmake will create imported
58 #        library targets for the various Qt libraries and set the 
59 #        library variables like QT_QTCORE_LIBRARY to point at these imported
60 #        targets instead of the library file on disk. This provides much better 
61 #        handling of the release and debug versions of the Qt libraries and is 
62 #       also always backwards compatible, except for the case that dependencies
63 #       of libraries are exported, these will then also list the names of the 
64 #       imported targets as dependency and not the file location on disk. This
65 #       is much more flexible, but requires that FindQt4.cmake is executed before
66 #       such an exported dependency file is processed.
67 #
68 # There are also some files that need processing by some Qt tools such as moc
69 # and uic.  Listed below are macros that may be used to process those files.
70 #  
71 #  macro QT4_WRAP_CPP(outfiles inputfile ... OPTIONS ...)
72 #        create moc code from a list of files containing Qt class with
73 #        the Q_OBJECT declaration.  Per-direcotry preprocessor definitions 
74 #        are also added.  Options may be given to moc, such as those found
75 #        when executing "moc -help".  
76 #
77 #  macro QT4_WRAP_UI(outfiles inputfile ... OPTIONS ...)
78 #        create code from a list of Qt designer ui files.
79 #        Options may be given to uic, such as those found
80 #        when executing "uic -help"
81 #
82 #  macro QT4_ADD_RESOURCES(outfiles inputfile ... OPTIONS ...)
83 #        create code from a list of Qt resource files.
84 #        Options may be given to rcc, such as those found
85 #        when executing "rcc -help"
86 #
87 #  macro QT4_GENERATE_MOC(inputfile outputfile )
88 #        creates a rule to run moc on infile and create outfile.
89 #        Use this if for some reason QT4_WRAP_CPP() isn't appropriate, e.g.
90 #        because you need a custom filename for the moc file or something similar.
91 #
92 #  macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... )
93 #        This macro is still experimental.
94 #        It can be used to have moc automatically handled.
95 #        So if you have the files foo.h and foo.cpp, and in foo.h a 
96 #        a class uses the Q_OBJECT macro, moc has to run on it. If you don't
97 #        want to use QT4_WRAP_CPP() (which is reliable and mature), you can insert
98 #        #include "foo.moc"
99 #        in foo.cpp and then give foo.cpp as argument to QT4_AUTOMOC(). This will the
100 #        scan all listed files at cmake-time for such included moc files and if it finds
101 #        them cause a rule to be generated to run moc at build time on the 
102 #        accompanying header file foo.h.
103 #        If a source file has the SKIP_AUTOMOC property set it will be ignored by this macro.
104 #
105 #  macro QT4_ADD_DBUS_INTERFACE(outfiles interface basename)
106 #        create a the interface header and implementation files with the 
107 #        given basename from the given interface xml file and add it to 
108 #        the list of sources
109 #
110 #  macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... )
111 #        create the interface header and implementation files 
112 #        for all listed interface xml files
113 #        the name will be automatically determined from the name of the xml file
114 #
115 #  macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname [basename] [classname])
116 #        create a dbus adaptor (header and implementation file) from the xml file
117 #        describing the interface, and add it to the list of sources. The adaptor
118 #        forwards the calls to a parent class, defined in parentheader and named
119 #        parentclassname. The name of the generated files will be
120 #        <basename>adaptor.{cpp,h} where basename defaults to the basename of the xml file.
121 #        If <classname> is provided, then it will be used as the classname of the
122 #        adaptor itself.
123 #
124 #  macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] OPTIONS ...)
125 #        generate the xml interface file from the given header.
126 #        If the optional argument interfacename is omitted, the name of the 
127 #        interface file is constructed from the basename of the header with
128 #        the suffix .xml appended.
129 #        Options may be given to qdbuscpp2xml, such as those found when executing "qdbuscpp2xml --help"
130 #
131 #  macro QT4_CREATE_TRANSLATION( qm_files directories ... sources ... 
132 #                                ts_files ... OPTIONS ...)
133 #        out: qm_files
134 #        in:  directories sources ts_files
135 #        options: flags to pass to lupdate, such as -extensions to specify
136 #        extensions for a directory scan.
137 #        generates commands to create .ts (vie lupdate) and .qm
138 #        (via lrelease) - files from directories and/or sources. The ts files are 
139 #        created and/or updated in the source tree (unless given with full paths).
140 #        The qm files are generated in the build tree.
141 #        Updating the translations can be done by adding the qm_files
142 #        to the source list of your library/executable, so they are
143 #        always updated, or by adding a custom target to control when
144 #        they get updated/generated.
145 #
146 #  macro QT4_ADD_TRANSLATION( qm_files ts_files ... )
147 #        out: qm_files
148 #        in:  ts_files
149 #        generates commands to create .qm from .ts - files. The generated
150 #        filenames can be found in qm_files. The ts_files
151 #        must exists and are not updated in any way.
152 #
153 #
154 #  Below is a detailed list of variables that FindQt4.cmake sets.
155 #  QT_FOUND         If false, don't try to use Qt.
156 #  QT4_FOUND        If false, don't try to use Qt 4.
157 #
158 #  QT_VERSION_MAJOR The major version of Qt found.
159 #  QT_VERSION_MINOR The minor version of Qt found.
160 #  QT_VERSION_PATCH The patch version of Qt found.
161 #
162 #  QT_EDITION               Set to the edition of Qt (i.e. DesktopLight)
163 #  QT_EDITION_DESKTOPLIGHT  True if QT_EDITION == DesktopLight
164 #  QT_QTCORE_FOUND          True if QtCore was found.
165 #  QT_QTGUI_FOUND           True if QtGui was found.
166 #  QT_QT3SUPPORT_FOUND      True if Qt3Support was found.
167 #  QT_QTASSISTANT_FOUND     True if QtAssistant was found.
168 #  QT_QTASSISTANTCLIENT_FOUND  True if QtAssistantClient was found.
169 #  QT_QAXCONTAINER_FOUND    True if QAxContainer was found (Windows only).
170 #  QT_QAXSERVER_FOUND       True if QAxServer was found (Windows only).
171 #  QT_QTDBUS_FOUND          True if QtDBus was found.
172 #  QT_QTDESIGNER_FOUND      True if QtDesigner was found.
173 #  QT_QTDESIGNERCOMPONENTS  True if QtDesignerComponents was found.
174 #  QT_QTHELP_FOUND          True if QtHelp was found.
175 #  QT_QTMOTIF_FOUND         True if QtMotif was found.
176 #  QT_QTMULTIMEDIA_FOUND    True if QtMultimedia was found (since Qt 4.6.0).
177 #  QT_QTNETWORK_FOUND       True if QtNetwork was found.
178 #  QT_QTNSPLUGIN_FOUND      True if QtNsPlugin was found.
179 #  QT_QTOPENGL_FOUND        True if QtOpenGL was found.
180 #  QT_QTSQL_FOUND           True if QtSql was found.
181 #  QT_QTSVG_FOUND           True if QtSvg was found.
182 #  QT_QTSCRIPT_FOUND        True if QtScript was found.
183 #  QT_QTSCRIPTTOOLS_FOUND   True if QtScriptTools was found.
184 #  QT_QTTEST_FOUND          True if QtTest was found.
185 #  QT_QTUITOOLS_FOUND       True if QtUiTools was found.
186 #  QT_QTWEBKIT_FOUND        True if QtWebKit was found.
187 #  QT_QTXML_FOUND           True if QtXml was found.
188 #  QT_QTXMLPATTERNS_FOUND   True if QtXmlPatterns was found.
189 #  QT_PHONON_FOUND          True if phonon was found.
190 #  QT_QTDECLARATIVE_FOUND   True if QtDeclarative was found.
191 #
192 #  QT_MAC_USE_COCOA    For Mac OS X, its whether Cocoa or Carbon is used.
193 #                      In general, this should not be used, but its useful
194 #                      when having platform specific code.
195 #
196 #  QT_DEFINITIONS   Definitions to use when compiling code that uses Qt.
197 #                   You do not need to use this if you include QT_USE_FILE.
198 #                   The QT_USE_FILE will also define QT_DEBUG and QT_NO_DEBUG
199 #                   to fit your current build type.  Those are not contained
200 #                   in QT_DEFINITIONS.
201 #                  
202 #  QT_INCLUDES      List of paths to all include directories of 
203 #                   Qt4 QT_INCLUDE_DIR and QT_QTCORE_INCLUDE_DIR are
204 #                   always in this variable even if NOTFOUND,
205 #                   all other INCLUDE_DIRS are
206 #                   only added if they are found.
207 #                   You do not need to use this if you include QT_USE_FILE.
208 #   
209 #
210 #  Include directories for the Qt modules are listed here.
211 #  You do not need to use these variables if you include QT_USE_FILE.
212 #
213 #  QT_INCLUDE_DIR              Path to "include" of Qt4
214 #  QT_QT3SUPPORT_INCLUDE_DIR   Path to "include/Qt3Support" 
215 #  QT_QTASSISTANT_INCLUDE_DIR  Path to "include/QtAssistant" 
216 #  QT_QTASSISTANTCLIENT_INCLUDE_DIR       Path to "include/QtAssistant"
217 #  QT_QAXCONTAINER_INCLUDE_DIR Path to "include/ActiveQt" (Windows only)
218 #  QT_QAXSERVER_INCLUDE_DIR    Path to "include/ActiveQt" (Windows only)
219 #  QT_QTCORE_INCLUDE_DIR       Path to "include/QtCore"         
220 #  QT_QTDBUS_INCLUDE_DIR       Path to "include/QtDBus" 
221 #  QT_QTDESIGNER_INCLUDE_DIR   Path to "include/QtDesigner" 
222 #  QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR   Path to "include/QtDesigner"
223 #  QT_QTGUI_INCLUDE_DIR        Path to "include/QtGui" 
224 #  QT_QTHELP_INCLUDE_DIR       Path to "include/QtHelp"
225 #  QT_QTMOTIF_INCLUDE_DIR      Path to "include/QtMotif" 
226 #  QT_QTMULTIMEDIA_INCLUDE_DIR Path to "include/QtMultimedia" 
227 #  QT_QTNETWORK_INCLUDE_DIR    Path to "include/QtNetwork" 
228 #  QT_QTNSPLUGIN_INCLUDE_DIR   Path to "include/QtNsPlugin" 
229 #  QT_QTOPENGL_INCLUDE_DIR     Path to "include/QtOpenGL" 
230 #  QT_QTSCRIPT_INCLUDE_DIR     Path to "include/QtScript"
231 #  QT_QTSQL_INCLUDE_DIR        Path to "include/QtSql" 
232 #  QT_QTSVG_INCLUDE_DIR        Path to "include/QtSvg"
233 #  QT_QTTEST_INCLUDE_DIR       Path to "include/QtTest"
234 #  QT_QTWEBKIT_INCLUDE_DIR     Path to "include/QtWebKit"
235 #  QT_QTXML_INCLUDE_DIR        Path to "include/QtXml" 
236 #  QT_QTXMLPATTERNS_INCLUDE_DIR  Path to "include/QtXmlPatterns"
237 #  QT_PHONON_INCLUDE_DIR       Path to "include/phonon"
238 #  QT_QTSCRIPTTOOLS_INCLUDE_DIR       Path to "include/QtScriptTools"
239 #  QT_QTDECLARATIVE_INCLUDE_DIR       Path to "include/QtDeclarative"
240 #
241 #  QT_BINARY_DIR               Path to "bin" of Qt4
242 #  QT_LIBRARY_DIR              Path to "lib" of Qt4
243 #  QT_PLUGINS_DIR              Path to "plugins" for Qt4
244 #  QT_TRANSLATIONS_DIR         Path to "translations" of Qt4
245 #  QT_IMPORTS_DIR              Path to "imports" of Qt4
246 #  QT_DOC_DIR                  Path to "doc" of Qt4
247 #  QT_MKSPECS_DIR              Path to "mkspecs" of Qt4
248 #
249 #
250 # The Qt toolkit may contain both debug and release libraries.
251 # In that case, the following library variables will contain both.
252 # You do not need to use these variables if you include QT_USE_FILE,
253 # and use QT_LIBRARIES.
254 #
255 #  QT_QT3SUPPORT_LIBRARY            The Qt3Support library
256 #  QT_QTASSISTANT_LIBRARY           The QtAssistant library
257 #  QT_QTASSISTANTCLIENT_LIBRARY     The QtAssistantClient library
258 #  QT_QAXCONTAINER_LIBRARY           The QAxContainer library (Windows only)
259 #  QT_QAXSERVER_LIBRARY                The QAxServer library (Windows only)
260 #  QT_QTCORE_LIBRARY                The QtCore library
261 #  QT_QTDBUS_LIBRARY                The QtDBus library
262 #  QT_QTDESIGNER_LIBRARY            The QtDesigner library
263 #  QT_QTDESIGNERCOMPONENTS_LIBRARY  The QtDesignerComponents library
264 #  QT_QTGUI_LIBRARY                 The QtGui library
265 #  QT_QTHELP_LIBRARY                The QtHelp library
266 #  QT_QTMOTIF_LIBRARY               The QtMotif library
267 #  QT_QTMULTIMEDIA_LIBRARY          The QtMultimedia library
268 #  QT_QTNETWORK_LIBRARY             The QtNetwork library
269 #  QT_QTNSPLUGIN_LIBRARY            The QtNsPLugin library
270 #  QT_QTOPENGL_LIBRARY              The QtOpenGL library
271 #  QT_QTSCRIPT_LIBRARY              The QtScript library
272 #  QT_QTSQL_LIBRARY                 The QtSql library
273 #  QT_QTSVG_LIBRARY                 The QtSvg library
274 #  QT_QTTEST_LIBRARY                The QtTest library
275 #  QT_QTUITOOLS_LIBRARY             The QtUiTools library
276 #  QT_QTWEBKIT_LIBRARY              The QtWebKit library
277 #  QT_QTXML_LIBRARY                 The QtXml library
278 #  QT_QTXMLPATTERNS_LIBRARY         The QtXmlPatterns library
279 #  QT_QTMAIN_LIBRARY                The qtmain library for Windows
280 #  QT_PHONON_LIBRARY                The phonon library
281 #  QT_QTSCRIPTTOOLS_LIBRARY         The QtScriptTools library
282 #  
283 # The QtDeclarative library:             QT_QTDECLARATIVE_LIBRARY
284 #
285 # also defined, but NOT for general use are
286 #  QT_MOC_EXECUTABLE                   Where to find the moc tool.
287 #  QT_UIC_EXECUTABLE                   Where to find the uic tool.
288 #  QT_UIC3_EXECUTABLE                  Where to find the uic3 tool.
289 #  QT_RCC_EXECUTABLE                   Where to find the rcc tool
290 #  QT_DBUSCPP2XML_EXECUTABLE           Where to find the qdbuscpp2xml tool.
291 #  QT_DBUSXML2CPP_EXECUTABLE           Where to find the qdbusxml2cpp tool.
292 #  QT_LUPDATE_EXECUTABLE               Where to find the lupdate tool.
293 #  QT_LRELEASE_EXECUTABLE              Where to find the lrelease tool.
294 #  QT_QCOLLECTIONGENERATOR_EXECUTABLE  Where to find the qcollectiongenerator tool.
295 #  QT_DESIGNER_EXECUTABLE              Where to find the Qt designer tool.
296 #  QT_LINGUIST_EXECUTABLE              Where to find the Qt linguist tool.
297 #  
298 #
299 # These are around for backwards compatibility 
300 # they will be set
301 #  QT_WRAP_CPP  Set true if QT_MOC_EXECUTABLE is found
302 #  QT_WRAP_UI   Set true if QT_UIC_EXECUTABLE is found
303 #  
304 # These variables do _NOT_ have any effect anymore (compared to FindQt.cmake)
305 #  QT_MT_REQUIRED         Qt4 is now always multithreaded
306 #  
307 # These variables are set to "" Because Qt structure changed 
308 # (They make no sense in Qt4)
309 #  QT_QT_LIBRARY        Qt-Library is now split
310
311 #=============================================================================
312 # Copyright 2005-2009 Kitware, Inc.
313 #
314 # Distributed under the OSI-approved BSD License (the "License");
315 # see accompanying file Copyright.txt for details.
316 #
317 # This software is distributed WITHOUT ANY WARRANTY; without even the
318 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
319 # See the License for more information.
320 #=============================================================================
321 # (To distribute this file outside of CMake, substitute the full
322 #  License text for the above reference.)
323
324 # Use FIND_PACKAGE( Qt4 COMPONENTS ... ) to enable modules
325 IF( Qt4_FIND_COMPONENTS )
326   FOREACH( component ${Qt4_FIND_COMPONENTS} )
327     STRING( TOUPPER ${component} _COMPONENT )
328     SET( QT_USE_${_COMPONENT} 1 )
329   ENDFOREACH( component )
330   
331   # To make sure we don't use QtCore or QtGui when not in COMPONENTS
332   IF(NOT QT_USE_QTCORE)
333     SET( QT_DONT_USE_QTCORE 1 )
334   ENDIF(NOT QT_USE_QTCORE)
335   
336   IF(NOT QT_USE_QTGUI)
337     SET( QT_DONT_USE_QTGUI 1 )
338   ENDIF(NOT QT_USE_QTGUI)
339
340 ENDIF( Qt4_FIND_COMPONENTS )
341
342 # If Qt3 has already been found, fail.
343 IF(QT_QT_LIBRARY)
344   IF(Qt4_FIND_REQUIRED)
345     MESSAGE( FATAL_ERROR "Qt3 and Qt4 cannot be used together in one project.  If switching to Qt4, the CMakeCache.txt needs to be cleaned.")
346   ELSE(Qt4_FIND_REQUIRED)
347     IF(NOT Qt4_FIND_QUIETLY)
348       MESSAGE( STATUS    "Qt3 and Qt4 cannot be used together in one project.  If switching to Qt4, the CMakeCache.txt needs to be cleaned.")
349     ENDIF(NOT Qt4_FIND_QUIETLY)
350     RETURN()
351   ENDIF(Qt4_FIND_REQUIRED)
352 ENDIF(QT_QT_LIBRARY)
353
354
355 INCLUDE(CheckCXXSymbolExists)
356 INCLUDE(MacroAddFileDependencies)
357 INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
358
359 SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake)
360
361 SET( QT_DEFINITIONS "")
362
363 # convenience macro for dealing with debug/release library names
364 MACRO (_QT4_ADJUST_LIB_VARS _camelCaseBasename)
365
366   STRING(TOUPPER "${_camelCaseBasename}" basename)
367
368   # The name of the imported targets, i.e. the prefix "Qt4::" must not change,
369   # since it is stored in EXPORT-files as name of a required library. If the name would change
370   # here, this would lead to the imported Qt4-library targets not being resolved by cmake anymore.
371   IF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG)
372
373     IF(NOT TARGET Qt4::${_camelCaseBasename})
374       ADD_LIBRARY(Qt4::${_camelCaseBasename} UNKNOWN IMPORTED )
375
376       IF (QT_${basename}_LIBRARY_RELEASE)
377         SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
378         if(QT_USE_FRAMEWORKS)
379           SET_PROPERTY(TARGET Qt4::${_camelCaseBasename}        PROPERTY IMPORTED_LOCATION_RELEASE "${QT_${basename}_LIBRARY_RELEASE}/${_camelCaseBasename}" )
380         else()
381           SET_PROPERTY(TARGET Qt4::${_camelCaseBasename}        PROPERTY IMPORTED_LOCATION_RELEASE "${QT_${basename}_LIBRARY_RELEASE}" )
382         endif()
383       ENDIF (QT_${basename}_LIBRARY_RELEASE)
384
385       IF (QT_${basename}_LIBRARY_DEBUG)
386         SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
387         if(QT_USE_FRAMEWORKS)
388           SET_PROPERTY(TARGET Qt4::${_camelCaseBasename}        PROPERTY IMPORTED_LOCATION_DEBUG "${QT_${basename}_LIBRARY_DEBUG}/${_camelCaseBasename}" )
389         else()
390           SET_PROPERTY(TARGET Qt4::${_camelCaseBasename}        PROPERTY IMPORTED_LOCATION_DEBUG "${QT_${basename}_LIBRARY_DEBUG}" )
391         endif()
392       ENDIF (QT_${basename}_LIBRARY_DEBUG)
393     ENDIF(NOT TARGET Qt4::${_camelCaseBasename})
394
395     # If QT_USE_IMPORTED_TARGETS is enabled, the QT_QTFOO_LIBRARY variables are set to point at these
396     # imported targets. This works better in general, and is also in almost all cases fully
397     # backward compatible. The only issue is when a project A which had this enabled then exports its
398     # libraries via export or EXPORT_LIBRARY_DEPENDENCIES(). In this case the libraries from project
399     # A will depend on the imported Qt targets, and the names of these imported targets will be stored
400     # in the dependency files on disk. This means when a project B then uses project A, these imported
401     # targets must be created again, otherwise e.g. "Qt4__QtCore" will be interpreted as name of a
402     # library file on disk, and not as a target, and linking will fail:
403     IF(QT_USE_IMPORTED_TARGETS)
404         SET(QT_${basename}_LIBRARY       Qt4::${_camelCaseBasename} )
405         SET(QT_${basename}_LIBRARIES     Qt4::${_camelCaseBasename} )
406     ELSE(QT_USE_IMPORTED_TARGETS)
407
408       # if the release- as well as the debug-version of the library have been found:
409       IF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
410         # if the generator supports configuration types then set
411         # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
412         IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
413           SET(QT_${basename}_LIBRARY       optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
414         ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
415           # if there are no configuration types and CMAKE_BUILD_TYPE has no value
416           # then just use the release libraries
417           SET(QT_${basename}_LIBRARY       ${QT_${basename}_LIBRARY_RELEASE} )
418         ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
419         SET(QT_${basename}_LIBRARIES       optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
420       ENDIF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
421
422       # if only the release version was found, set the debug variable also to the release version
423       IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
424         SET(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE})
425         SET(QT_${basename}_LIBRARY       ${QT_${basename}_LIBRARY_RELEASE})
426         SET(QT_${basename}_LIBRARIES     ${QT_${basename}_LIBRARY_RELEASE})
427       ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
428
429       # if only the debug version was found, set the release variable also to the debug version
430       IF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE)
431         SET(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG})
432         SET(QT_${basename}_LIBRARY         ${QT_${basename}_LIBRARY_DEBUG})
433         SET(QT_${basename}_LIBRARIES       ${QT_${basename}_LIBRARY_DEBUG})
434       ENDIF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE)
435
436       # put the value in the cache:
437       SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE STRING "The Qt ${basename} library" FORCE)
438
439     ENDIF(QT_USE_IMPORTED_TARGETS)
440
441     SET(QT_${basename}_FOUND 1)
442
443   ELSE (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG)
444
445     SET(QT_${basename}_LIBRARY "" CACHE STRING "The Qt ${basename} library" FORCE)
446
447   ENDIF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG)
448
449   IF (QT_${basename}_INCLUDE_DIR)
450     #add the include directory to QT_INCLUDES
451     SET(QT_INCLUDES "${QT_${basename}_INCLUDE_DIR}" ${QT_INCLUDES})
452   ENDIF (QT_${basename}_INCLUDE_DIR)
453
454   # Make variables changeble to the advanced user
455   MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR)
456 ENDMACRO (_QT4_ADJUST_LIB_VARS)
457
458 function(_QT4_QUERY_QMAKE VAR RESULT)
459   execute_process(COMMAND "${QT_QMAKE_EXECUTABLE}" -query ${VAR}
460     RESULT_VARIABLE return_code
461     OUTPUT_VARIABLE output ERROR_VARIABLE output
462     OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE)
463   if(NOT return_code)
464     file(TO_CMAKE_PATH "${output}" output)
465     set(${RESULT} ${output} PARENT_SCOPE)
466   endif(NOT return_code)
467 endfunction(_QT4_QUERY_QMAKE)
468
469
470 SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE)
471
472 GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME)
473 # check for qmake
474 # Debian uses qmake-qt4
475 # macports' Qt uses qmake-mac
476 FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 qmake-mac PATHS
477   "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
478   "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
479   "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]/bin"
480   $ENV{QTDIR}/bin
481   DOC "The qmake executable for the Qt installation to use"
482 )
483
484 # double check that it was a Qt4 qmake, if not, re-find with different names
485 IF (QT_QMAKE_EXECUTABLE)
486
487   IF(QT_QMAKE_EXECUTABLE_LAST)
488     STRING(COMPARE NOTEQUAL "${QT_QMAKE_EXECUTABLE_LAST}" "${QT_QMAKE_EXECUTABLE}" QT_QMAKE_CHANGED)
489   ENDIF(QT_QMAKE_EXECUTABLE_LAST)
490
491   SET(QT_QMAKE_EXECUTABLE_LAST "${QT_QMAKE_EXECUTABLE}" CACHE INTERNAL "" FORCE)
492
493   _qt4_query_qmake(QT_VERSION QTVERSION)
494
495   # check for qt3 qmake and then try and find qmake4 or qmake-qt4 in the path
496   IF(NOT QTVERSION)
497     SET(QT_QMAKE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE)
498     FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 PATHS
499       "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
500       "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
501       $ENV{QTDIR}/bin
502       DOC "The qmake executable for the Qt installation to use"
503       )
504     IF(QT_QMAKE_EXECUTABLE)
505       _qt4_query_qmake(QT_VERSION QTVERSION)
506     ENDIF(QT_QMAKE_EXECUTABLE)
507   ENDIF(NOT QTVERSION)
508
509 ENDIF (QT_QMAKE_EXECUTABLE)
510
511 IF (QT_QMAKE_EXECUTABLE AND QTVERSION)
512
513   # ask qmake for the mkspecs directory
514   # we do this first because QT_LIBINFIX might be set
515   IF (NOT QT_MKSPECS_DIR  OR  QT_QMAKE_CHANGED)
516     _qt4_query_qmake(QMAKE_MKSPECS qt_mkspecs_dirs)
517     # do not replace : on windows as it might be a drive letter
518     # and windows should already use ; as a separator
519     IF(NOT WIN32)
520       STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}")
521     ENDIF(NOT WIN32)
522     set(qt_cross_paths)
523     foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH})
524       set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/mkspecs")
525     endforeach(qt_cross_path)
526     SET(QT_MKSPECS_DIR NOTFOUND)
527     FIND_PATH(QT_MKSPECS_DIR NAMES qconfig.pri
528       HINTS ${qt_cross_paths} ${qt_mkspecs_dirs}
529       DOC "The location of the Qt mkspecs containing qconfig.pri")
530   ENDIF()
531
532   IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
533     FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents)
534     STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG "${_qconfig_FILE_contents}")
535     STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG "${_qconfig_FILE_contents}")
536     STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION "${_qconfig_FILE_contents}")
537     STRING(REGEX MATCH "QT_LIBINFIX[^\n]+" _qconfig_qt_libinfix "${_qconfig_FILE_contents}")
538     STRING(REGEX REPLACE "QT_LIBINFIX *= *([^\n]*)" "\\1" QT_LIBINFIX "${_qconfig_qt_libinfix}")
539   ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
540   IF("${QT_EDITION}" MATCHES "DesktopLight")
541     SET(QT_EDITION_DESKTOPLIGHT 1)
542   ENDIF("${QT_EDITION}" MATCHES "DesktopLight")
543
544   # ask qmake for the library dir as a hint, then search for QtCore library and use that as a reference for finding the
545   # others and for setting QT_LIBRARY_DIR
546   IF (NOT (QT_QTCORE_LIBRARY_RELEASE OR QT_QTCORE_LIBRARY_DEBUG)  OR QT_QMAKE_CHANGED)
547     _qt4_query_qmake(QT_INSTALL_LIBS QT_LIBRARY_DIR_TMP)
548     SET(QT_QTCORE_LIBRARY_RELEASE NOTFOUND)
549     SET(QT_QTCORE_LIBRARY_DEBUG NOTFOUND)
550     FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE
551                  NAMES QtCore${QT_LIBINFIX} QtCore${QT_LIBINFIX}4
552                  HINTS ${QT_LIBRARY_DIR_TMP}
553                  NO_DEFAULT_PATH
554         )
555     FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG
556                  NAMES QtCore${QT_LIBINFIX}_debug QtCore${QT_LIBINFIX}d QtCore${QT_LIBINFIX}d4
557                  HINTS ${QT_LIBRARY_DIR_TMP}
558                  NO_DEFAULT_PATH
559         )
560
561     IF(NOT QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCORE_LIBRARY_DEBUG)
562       FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE
563                    NAMES QtCore${QT_LIBINFIX} QtCore${QT_LIBINFIX}4
564                    HINTS ${QT_LIBRARY_DIR_TMP}
565           )
566       FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG
567                    NAMES QtCore${QT_LIBINFIX}_debug QtCore${QT_LIBINFIX}d QtCore${QT_LIBINFIX}d4
568                    HINTS ${QT_LIBRARY_DIR_TMP}
569           )
570     ENDIF(NOT QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCORE_LIBRARY_DEBUG)
571
572     # try dropping a hint if trying to use Visual Studio with Qt built by mingw
573     IF(NOT QT_QTCORE_LIBRARY_RELEASE AND MSVC)
574       IF(EXISTS ${QT_LIBRARY_DIR_TMP}/libqtmain.a)
575         MESSAGE( FATAL_ERROR "It appears you're trying to use Visual Studio with Qt built by mingw.  Those compilers do not produce code compatible with each other.")
576       ENDIF(EXISTS ${QT_LIBRARY_DIR_TMP}/libqtmain.a)
577     ENDIF(NOT QT_QTCORE_LIBRARY_RELEASE AND MSVC)
578
579   ENDIF ()
580
581   # set QT_LIBRARY_DIR based on location of QtCore found.
582   IF(QT_QTCORE_LIBRARY_RELEASE)
583     GET_FILENAME_COMPONENT(QT_LIBRARY_DIR_TMP "${QT_QTCORE_LIBRARY_RELEASE}" PATH)
584     SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE)
585     SET(QT_QTCORE_FOUND 1)
586   ELSEIF(QT_QTCORE_LIBRARY_DEBUG)
587     GET_FILENAME_COMPONENT(QT_LIBRARY_DIR_TMP "${QT_QTCORE_LIBRARY_DEBUG}" PATH)
588     SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE)
589     SET(QT_QTCORE_FOUND 1)
590   ELSE()
591     MESSAGE(WARNING "${QT_QMAKE_EXECUTABLE} reported QT_INSTALL_LIBS as \"${QT_LIBRARY_DIR_TMP}\" "
592                     "but QtCore could not be found there.  "
593                     "Qt is NOT installed correctly for the target build environment.")
594     IF(Qt4_FIND_REQUIRED)
595       MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.")
596     ENDIF(Qt4_FIND_REQUIRED)
597   ENDIF()
598
599   # ask qmake for the binary dir
600   IF (NOT QT_BINARY_DIR  OR  QT_QMAKE_CHANGED)
601     _qt4_query_qmake(QT_INSTALL_BINS qt_bins)
602     SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "" FORCE)
603   ENDIF (NOT QT_BINARY_DIR  OR  QT_QMAKE_CHANGED)
604
605   IF (APPLE)
606     SET(CMAKE_FIND_FRAMEWORK_OLD ${CMAKE_FIND_FRAMEWORK})
607     IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
608       SET(QT_USE_FRAMEWORKS ON CACHE INTERNAL "" FORCE)
609       SET(CMAKE_FIND_FRAMEWORK FIRST)
610     ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
611       SET(QT_USE_FRAMEWORKS OFF CACHE INTERNAL "" FORCE)
612       SET(CMAKE_FIND_FRAMEWORK LAST)
613     ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
614   ENDIF (APPLE)
615
616   # ask qmake for the include dir
617   IF (QT_LIBRARY_DIR AND (NOT QT_QTCORE_INCLUDE_DIR OR NOT QT_HEADERS_DIR OR  QT_QMAKE_CHANGED))
618       _qt4_query_qmake(QT_INSTALL_HEADERS qt_headers)
619       SET(QT_QTCORE_INCLUDE_DIR NOTFOUND)
620       FIND_PATH(QT_QTCORE_INCLUDE_DIR QtCore
621                 HINTS ${qt_headers} ${QT_LIBRARY_DIR}
622                 PATH_SUFFIXES QtCore qt4/QtCore
623         )
624
625       # Set QT_HEADERS_DIR based on finding QtCore header
626       IF(QT_QTCORE_INCLUDE_DIR)
627         IF(QT_USE_FRAMEWORKS)
628           SET(QT_HEADERS_DIR "${qt_headers}" CACHE INTERNAL "" FORCE)
629         ELSE(QT_USE_FRAMEWORKS)
630           GET_FILENAME_COMPONENT(qt_headers "${QT_QTCORE_INCLUDE_DIR}/../" ABSOLUTE)
631           SET(QT_HEADERS_DIR "${qt_headers}" CACHE INTERNAL "" FORCE)
632         ENDIF(QT_USE_FRAMEWORKS)
633       ELSEIF()
634         MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_HEADERS as ${qt_headers}")
635         MESSAGE("Warning: But QtCore couldn't be found.  Qt must NOT be installed correctly.")
636       ENDIF()
637   ENDIF()
638
639   IF(APPLE)
640     SET(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_OLD})
641   ENDIF(APPLE)
642
643   # Set QT_INCLUDE_DIR based on QT_HEADERS_DIR
644   IF(QT_HEADERS_DIR)
645     IF(QT_USE_FRAMEWORKS)
646       # Qt/Mac frameworks has two include dirs.
647       # One is the framework include for which CMake will add a -F flag
648       # and the other is an include dir for non-framework Qt modules
649       SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR} ${QT_QTCORE_LIBRARY_RELEASE} )
650     ELSE(QT_USE_FRAMEWORKS)
651       SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR})
652     ENDIF(QT_USE_FRAMEWORKS)
653   ENDIF(QT_HEADERS_DIR)
654
655   # Set QT_INCLUDES
656   SET( QT_INCLUDES ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR})
657
658
659   # ask qmake for the documentation directory
660   IF (QT_LIBRARY_DIR AND NOT QT_DOC_DIR  OR  QT_QMAKE_CHANGED)
661     _qt4_query_qmake(QT_INSTALL_DOCS qt_doc_dir)
662     SET(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs" FORCE)
663   ENDIF (QT_LIBRARY_DIR AND NOT QT_DOC_DIR  OR  QT_QMAKE_CHANGED)
664
665
666   # ask qmake for the plugins directory
667   IF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR  OR  QT_QMAKE_CHANGED)
668     _qt4_query_qmake(QT_INSTALL_PLUGINS qt_plugins_dir)
669     SET(QT_PLUGINS_DIR NOTFOUND)
670     foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH})
671       set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/plugins")
672     endforeach(qt_cross_path)
673     FIND_PATH(QT_PLUGINS_DIR NAMES accessible imageformats sqldrivers codecs designer
674       HINTS ${qt_cross_paths} ${qt_plugins_dir}
675       DOC "The location of the Qt plugins")
676   ENDIF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR  OR  QT_QMAKE_CHANGED)
677
678   # ask qmake for the translations directory
679   IF (QT_LIBRARY_DIR AND NOT QT_TRANSLATIONS_DIR  OR  QT_QMAKE_CHANGED)
680     _qt4_query_qmake(QT_INSTALL_TRANSLATIONS qt_translations_dir)
681     SET(QT_TRANSLATIONS_DIR ${qt_translations_dir} CACHE PATH "The location of the Qt translations" FORCE)
682   ENDIF (QT_LIBRARY_DIR AND NOT QT_TRANSLATIONS_DIR  OR  QT_QMAKE_CHANGED)
683
684   # ask qmake for the imports directory
685   IF (QT_LIBRARY_DIR AND NOT QT_IMPORTS_DIR OR QT_QMAKE_CHANGED)
686     _qt4_query_qmake(QT_INSTALL_IMPORTS qt_imports_dir)
687     if(qt_imports_dir)
688       SET(QT_IMPORTS_DIR NOTFOUND)
689       foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH})
690         set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/imports")
691       endforeach(qt_cross_path)
692       FIND_PATH(QT_IMPORTS_DIR NAMES Qt
693         HINTS ${qt_cross_paths} ${qt_imports_dir}
694         DOC "The location of the Qt imports"
695         NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH
696         NO_CMAKE_SYSTEM_PATH)
697       mark_as_advanced(QT_IMPORTS_DIR)
698     endif(qt_imports_dir)
699   ENDIF (QT_LIBRARY_DIR AND NOT QT_IMPORTS_DIR  OR  QT_QMAKE_CHANGED)
700
701   # Make variables changeble to the advanced user
702   MARK_AS_ADVANCED( QT_LIBRARY_DIR QT_DOC_DIR QT_MKSPECS_DIR
703                     QT_PLUGINS_DIR QT_TRANSLATIONS_DIR)
704
705
706
707
708   #############################################
709   #
710   # Find out what window system we're using
711   #
712   #############################################
713   # Save required variable
714   SET(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
715   SET(CMAKE_REQUIRED_FLAGS_SAVE    ${CMAKE_REQUIRED_FLAGS})
716   # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES
717   SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}")
718   # Check for Window system symbols (note: only one should end up being set)
719   CHECK_CXX_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11)
720   CHECK_CXX_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN)
721   CHECK_CXX_SYMBOL_EXISTS(Q_WS_QWS "QtCore/qglobal.h" Q_WS_QWS)
722   CHECK_CXX_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC)
723   IF(Q_WS_MAC)
724     IF(QT_QMAKE_CHANGED)
725       UNSET(QT_MAC_USE_COCOA CACHE)
726     ENDIF(QT_QMAKE_CHANGED)
727     CHECK_CXX_SYMBOL_EXISTS(QT_MAC_USE_COCOA "QtCore/qconfig.h" QT_MAC_USE_COCOA)
728   ENDIF(Q_WS_MAC)
729
730   IF (QT_QTCOPY_REQUIRED)
731      CHECK_CXX_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY)
732      IF (NOT QT_IS_QTCOPY)
733         MESSAGE(FATAL_ERROR "qt-copy is required, but hasn't been found")
734      ENDIF (NOT QT_IS_QTCOPY)
735   ENDIF (QT_QTCOPY_REQUIRED)
736
737   # Restore CMAKE_REQUIRED_INCLUDES and CMAKE_REQUIRED_FLAGS variables
738   SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
739   SET(CMAKE_REQUIRED_FLAGS    ${CMAKE_REQUIRED_FLAGS_SAVE})
740   #
741   #############################################
742
743
744
745   ########################################
746   #
747   #       Setting the INCLUDE-Variables
748   #
749   ########################################
750
751   SET(QT_MODULES QtGui Qt3Support QtSvg QtScript QtTest QtUiTools
752                  QtHelp QtWebKit QtXmlPatterns phonon QtNetwork QtMultimedia
753                  QtNsPlugin QtOpenGL QtSql QtXml QtDesigner QtDBus QtScriptTools
754                  QtDeclarative)
755   
756   IF(Q_WS_X11)
757     SET(QT_MODULES ${QT_MODULES} QtMotif)
758   ENDIF(Q_WS_X11)
759
760   IF(QT_QMAKE_CHANGED)
761     FOREACH(QT_MODULE ${QT_MODULES})
762       STRING(TOUPPER ${QT_MODULE} _upper_qt_module)
763       SET(QT_${_upper_qt_module}_INCLUDE_DIR NOTFOUND)
764       SET(QT_${_upper_qt_module}_LIBRARY_RELEASE NOTFOUND)
765       SET(QT_${_upper_qt_module}_LIBRARY_DEBUG NOTFOUND)
766     ENDFOREACH(QT_MODULE)
767     SET(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR NOTFOUND)
768     SET(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NOTFOUND)
769     SET(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NOTFOUND)
770     SET(QT_QTASSISTANTCLIENT_INCLUDE_DIR NOTFOUND)
771     SET(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NOTFOUND)
772     SET(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NOTFOUND)
773     SET(QT_QTASSISTANT_INCLUDE_DIR NOTFOUND)
774     SET(QT_QTASSISTANT_LIBRARY_RELEASE NOTFOUND)
775     SET(QT_QTASSISTANT_LIBRARY_DEBUG NOTFOUND)
776     SET(QT_QTCLUCENE_LIBRARY_RELEASE NOTFOUND)
777     SET(QT_QTCLUCENE_LIBRARY_DEBUG NOTFOUND)
778     SET(QT_QAXCONTAINER_INCLUDE_DIR NOTFOUND)
779     SET(QT_QAXCONTAINER_LIBRARY_RELEASE NOTFOUND)
780     SET(QT_QAXCONTAINER_LIBRARY_DEBUG NOTFOUND)
781     SET(QT_QAXSERVER_INCLUDE_DIR NOTFOUND)
782     SET(QT_QAXSERVER_LIBRARY_RELEASE NOTFOUND)
783     SET(QT_QAXSERVER_LIBRARY_DEBUG NOTFOUND)
784     IF(Q_WS_WIN)
785       SET(QT_QTMAIN_LIBRARY_DEBUG NOTFOUND)
786       SET(QT_QTMAIN_LIBRARY_RELEASE NOTFOUND)
787     ENDIF(Q_WS_WIN)
788   ENDIF(QT_QMAKE_CHANGED)
789
790   FOREACH(QT_MODULE ${QT_MODULES})
791     STRING(TOUPPER ${QT_MODULE} _upper_qt_module)
792     FIND_PATH(QT_${_upper_qt_module}_INCLUDE_DIR ${QT_MODULE}
793               PATHS
794               ${QT_HEADERS_DIR}/${QT_MODULE}
795               ${QT_LIBRARY_DIR}/${QT_MODULE}.framework/Headers
796               NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
797       )
798     # phonon doesn't seem consistent, let's try phonondefs.h for some
799     # installations
800     IF(${QT_MODULE} STREQUAL "phonon")
801       FIND_PATH(QT_${_upper_qt_module}_INCLUDE_DIR phonondefs.h
802                 PATHS
803                 ${QT_HEADERS_DIR}/${QT_MODULE}
804                 ${QT_LIBRARY_DIR}/${QT_MODULE}.framework/Headers
805                 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
806         )
807     ENDIF(${QT_MODULE} STREQUAL "phonon")
808   ENDFOREACH(QT_MODULE)
809
810   IF(Q_WS_WIN)
811     SET(QT_MODULES ${QT_MODULES} QAxContainer QAxServer)
812     # Set QT_AXCONTAINER_INCLUDE_DIR and QT_AXSERVER_INCLUDE_DIR
813     FIND_PATH(QT_QAXCONTAINER_INCLUDE_DIR ActiveQt
814       PATHS ${QT_HEADERS_DIR}/ActiveQt
815       NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
816       )
817     FIND_PATH(QT_QAXSERVER_INCLUDE_DIR ActiveQt
818       PATHS ${QT_HEADERS_DIR}/ActiveQt
819       NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
820       )
821   ENDIF(Q_WS_WIN)
822
823   # Set QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR
824   FIND_PATH(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR QDesignerComponents
825     PATHS
826     ${QT_HEADERS_DIR}/QtDesigner
827     ${QT_LIBRARY_DIR}/QtDesigner.framework/Headers
828     NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
829     )
830   
831   # Set QT_QTASSISTANT_INCLUDE_DIR
832   FIND_PATH(QT_QTASSISTANT_INCLUDE_DIR QtAssistant
833     PATHS
834     ${QT_HEADERS_DIR}/QtAssistant
835     ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers
836     NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
837     )
838   
839   # Set QT_QTASSISTANTCLIENT_INCLUDE_DIR
840   FIND_PATH(QT_QTASSISTANTCLIENT_INCLUDE_DIR QAssistantClient
841     PATHS
842     ${QT_HEADERS_DIR}/QtAssistant
843     ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers
844     NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
845     )
846
847   ########################################
848   #
849   #       Setting the LIBRARY-Variables
850   #
851   ########################################
852
853   # find the libraries
854   FOREACH(QT_MODULE ${QT_MODULES})
855     STRING(TOUPPER ${QT_MODULE} _upper_qt_module)
856     FIND_LIBRARY(QT_${_upper_qt_module}_LIBRARY_RELEASE 
857                  NAMES ${QT_MODULE}${QT_LIBINFIX} ${QT_MODULE}${QT_LIBINFIX}4
858                  PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
859         )
860     FIND_LIBRARY(QT_${_upper_qt_module}_LIBRARY_DEBUG 
861                  NAMES ${QT_MODULE}${QT_LIBINFIX}_debug ${QT_MODULE}${QT_LIBINFIX}d ${QT_MODULE}${QT_LIBINFIX}d4
862                  PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
863         )
864   ENDFOREACH(QT_MODULE)
865
866   # QtUiTools is sometimes not in the same directory as the other found libraries
867   # e.g. on Mac, its never a framework like the others are
868   IF(QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE)
869     FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR})
870   ENDIF(QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE)
871
872   # Set QT_QTDESIGNERCOMPONENTS_LIBRARY
873   FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents${QT_LIBINFIX} QtDesignerComponents${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
874   FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG   NAMES QtDesignerComponents${QT_LIBINFIX}_debug QtDesignerComponents${QT_LIBINFIX}d QtDesignerComponents${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
875
876   # Set QT_QTMAIN_LIBRARY
877   IF(Q_WS_WIN)
878     FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
879     FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmain${QT_LIBINFIX}d PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
880   ENDIF(Q_WS_WIN)
881   
882   # Set QT_QTASSISTANTCLIENT_LIBRARY
883   FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
884   FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG   NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR}  NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
885   
886   # Set QT_QTASSISTANT_LIBRARY
887   FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 QtAssistant${QT_LIBINFIX} QtAssistant${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
888   FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG   NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 QtAssistant${QT_LIBINFIX}_debug QtAssistant${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
889
890   # Set QT_QTHELP_LIBRARY
891   FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} QtCLucene${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
892   FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_DEBUG   NAMES QtCLucene${QT_LIBINFIX}_debug QtCLucene${QT_LIBINFIX}d QtCLucene${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
893   IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE)
894     FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR})
895   ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE)
896
897
898   ############################################
899   #
900   # Check the existence of the libraries.
901   #
902   ############################################
903
904
905   # Set QT_xyz_LIBRARY variable and add 
906   # library include path to QT_INCLUDES
907   _QT4_ADJUST_LIB_VARS(QtCore)
908
909   FOREACH(QT_MODULE ${QT_MODULES})
910     _QT4_ADJUST_LIB_VARS(${QT_MODULE})
911   ENDFOREACH(QT_MODULE)
912
913   _QT4_ADJUST_LIB_VARS(QtAssistant)
914   _QT4_ADJUST_LIB_VARS(QtAssistantClient)
915   _QT4_ADJUST_LIB_VARS(QtCLucene)
916   _QT4_ADJUST_LIB_VARS(QtDesignerComponents)
917
918   # platform dependent libraries
919   IF(Q_WS_WIN)
920     _QT4_ADJUST_LIB_VARS(qtmain)
921     _QT4_ADJUST_LIB_VARS(QAxServer)
922     _QT4_ADJUST_LIB_VARS(QAxContainer)
923   ENDIF(Q_WS_WIN)
924
925
926   #######################################
927   #
928   #       Check the executables of Qt 
929   #          ( moc, uic, rcc )
930   #
931   #######################################
932
933
934   IF(QT_QMAKE_CHANGED)
935     SET(QT_UIC_EXECUTABLE NOTFOUND)
936     SET(QT_MOC_EXECUTABLE NOTFOUND)
937     SET(QT_UIC3_EXECUTABLE NOTFOUND)
938     SET(QT_RCC_EXECUTABLE NOTFOUND)
939     SET(QT_DBUSCPP2XML_EXECUTABLE NOTFOUND)
940     SET(QT_DBUSXML2CPP_EXECUTABLE NOTFOUND)
941     SET(QT_LUPDATE_EXECUTABLE NOTFOUND)
942     SET(QT_LRELEASE_EXECUTABLE NOTFOUND)
943     SET(QT_QCOLLECTIONGENERATOR_EXECUTABLE NOTFOUND)
944     SET(QT_DESIGNER_EXECUTABLE NOTFOUND)
945     SET(QT_LINGUIST_EXECUTABLE NOTFOUND)
946   ENDIF(QT_QMAKE_CHANGED)
947   
948   FIND_PROGRAM(QT_MOC_EXECUTABLE
949     NAMES moc-qt4 moc
950     PATHS ${QT_BINARY_DIR}
951     NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
952     )
953
954   FIND_PROGRAM(QT_UIC_EXECUTABLE
955     NAMES uic-qt4 uic
956     PATHS ${QT_BINARY_DIR}
957     NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
958     )
959
960   FIND_PROGRAM(QT_UIC3_EXECUTABLE
961     NAMES uic3
962     PATHS ${QT_BINARY_DIR}
963     NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
964     )
965
966   FIND_PROGRAM(QT_RCC_EXECUTABLE 
967     NAMES rcc
968     PATHS ${QT_BINARY_DIR}
969     NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
970     )
971
972   FIND_PROGRAM(QT_DBUSCPP2XML_EXECUTABLE 
973     NAMES qdbuscpp2xml
974     PATHS ${QT_BINARY_DIR}
975     NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
976     )
977
978   FIND_PROGRAM(QT_DBUSXML2CPP_EXECUTABLE 
979     NAMES qdbusxml2cpp
980     PATHS ${QT_BINARY_DIR}
981     NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
982     )
983
984   FIND_PROGRAM(QT_LUPDATE_EXECUTABLE
985     NAMES lupdate-qt4 lupdate
986     PATHS ${QT_BINARY_DIR}
987     NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
988     )
989
990   FIND_PROGRAM(QT_LRELEASE_EXECUTABLE
991     NAMES lrelease-qt4 lrelease
992     PATHS ${QT_BINARY_DIR}
993     NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
994     )
995
996   FIND_PROGRAM(QT_QCOLLECTIONGENERATOR_EXECUTABLE
997     NAMES qcollectiongenerator-qt4 qcollectiongenerator
998     PATHS ${QT_BINARY_DIR}
999     NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
1000     )
1001
1002   FIND_PROGRAM(QT_DESIGNER_EXECUTABLE
1003     NAMES designer-qt4 designer
1004     PATHS ${QT_BINARY_DIR}
1005     NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
1006     )
1007
1008   FIND_PROGRAM(QT_LINGUIST_EXECUTABLE
1009     NAMES linguist-qt4 linguist
1010     PATHS ${QT_BINARY_DIR}
1011     NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
1012     )
1013
1014   IF (QT_MOC_EXECUTABLE)
1015      SET(QT_WRAP_CPP "YES")
1016   ENDIF (QT_MOC_EXECUTABLE)
1017
1018   IF (QT_UIC_EXECUTABLE)
1019      SET(QT_WRAP_UI "YES")
1020   ENDIF (QT_UIC_EXECUTABLE)
1021
1022
1023
1024   MARK_AS_ADVANCED( QT_UIC_EXECUTABLE QT_UIC3_EXECUTABLE QT_MOC_EXECUTABLE
1025     QT_RCC_EXECUTABLE QT_DBUSXML2CPP_EXECUTABLE QT_DBUSCPP2XML_EXECUTABLE
1026     QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE QT_QCOLLECTIONGENERATOR_EXECUTABLE
1027     QT_DESIGNER_EXECUTABLE QT_LINGUIST_EXECUTABLE)
1028
1029
1030   # get the directory of the current file, used later on in the file
1031   GET_FILENAME_COMPONENT( _qt4_current_dir  "${CMAKE_CURRENT_LIST_FILE}" PATH)
1032
1033   
1034   ###############################################
1035   #
1036   #       configuration/system dependent settings  
1037   #
1038   ###############################################
1039
1040   INCLUDE("${_qt4_current_dir}/Qt4ConfigDependentSettings.cmake")
1041
1042
1043   #######################################
1044   #
1045   #       Check the plugins of Qt
1046   #
1047   #######################################
1048
1049   SET( QT_PLUGIN_TYPES accessible bearer codecs decorations designer gfxdrivers graphicssystems iconengines imageformats inputmethods mousedrivers phonon_backend script sqldrivers )
1050
1051   SET( QT_ACCESSIBLE_PLUGINS qtaccessiblecompatwidgets qtaccessiblewidgets )
1052   SET( QT_BEARER_PLUGINS qcorewlanbearer qgenericbearer )
1053   SET( QT_CODECS_PLUGINS qcncodecs qjpcodecs qkrcodecs qtwcodecs )
1054   SET( QT_DECORATIONS_PLUGINS qdecorationdefault qdecorationwindows )
1055   SET( QT_DESIGNER_PLUGINS arthurplugin containerextension customwidgetplugin phononwidgets qdeclarativeview qt3supportwidgets qwebview taskmenuextension worldtimeclockplugin )
1056   SET( QT_GRAPHICSDRIVERS_PLUGINS qgfxtransformed qgfxvnc qscreenvfb )
1057   SET( QT_GRAPHICSSYSTEMS_PLUGINS qglgraphicssystem qtracegraphicssystem )
1058   SET( QT_ICONENGINES_PLUGINS qsvgicon )
1059   SET( QT_IMAGEFORMATS_PLUGINS qgif qjpeg qmng qico qsvg qtiff  )
1060   SET( QT_INPUTMETHODS_PLUGINS qimsw_multi )
1061   SET( QT_MOUSEDRIVERS_PLUGINS qwstslibmousehandler )
1062   SET( QT_PHONON_BACKEND_PLUGINS phonon_qt7 )
1063   SET( QT_SCRIPT_PLUGINS qtscriptdbus )
1064   SET( QT_SQLDRIVERS_PLUGINS qsqldb2 qsqlibase qsqlite qsqlite2 qsqlmysql qsqloci qsqlodbc qsqlpsql qsqltds )
1065
1066   SET( QT_PHONON_PLUGINS ${QT_PHONON_BACKEND_PLUGINS} )
1067   SET( QT_QT3SUPPORT_PLUGINS qtaccessiblecompatwidgets )
1068   SET( QT_QTCORE_PLUGINS ${QT_BEARER_PLUGINS} ${QT_CODECS_PLUGINS} )
1069   SET( QT_QTGUI_PLUGINS qtaccessiblewidgets qgif qjpeg qmng qico qtiff ${QT_DECORATIONS_PLUGINS} ${QT_GRAPHICSDRIVERS_PLUGINS} ${QT_GRAPHICSSYSTEMS_PLUGINS} ${QT_INPUTMETHODS_PLUGINS} ${QT_MOUSEDRIVERS_PLUGINS} )
1070   SET( QT_QTSCRIPT_PLUGINS ${QT_SCRIPT_PLUGINS} )
1071   SET( QT_QTSQL_PLUGINS ${QT_SQLDRIVERS_PLUGINS} )
1072   SET( QT_QTSVG_PLUGINS qsvg qsvgicon )
1073
1074   IF(QT_QMAKE_CHANGED)
1075     FOREACH(QT_PLUGIN_TYPE ${QT_PLUGIN_TYPES})
1076       STRING(TOUPPER ${QT_PLUGIN_TYPE} _upper_qt_plugin_type)
1077       SET(QT_${_upper_qt_plugin_type}_PLUGINS_DIR ${QT_PLUGINS_DIR}/${QT_PLUGIN_TYPE})
1078       FOREACH(QT_PLUGIN ${QT_${_upper_qt_plugin_type}_PLUGINS})
1079         STRING(TOUPPER ${QT_PLUGIN} _upper_qt_plugin)
1080         UNSET(QT_${_upper_qt_plugin}_LIBRARY_RELEASE CACHE)
1081         UNSET(QT_${_upper_qt_plugin}_LIBRARY_DEBUG CACHE)
1082         UNSET(QT_${_upper_qt_plugin}_LIBRARY CACHE)
1083         UNSET(QT_${_upper_qt_plugin}_PLUGIN_RELEASE CACHE)
1084         UNSET(QT_${_upper_qt_plugin}_PLUGIN_DEBUG CACHE)
1085         UNSET(QT_${_upper_qt_plugin}_PLUGIN CACHE)
1086       ENDFOREACH(QT_PLUGIN)
1087     ENDFOREACH(QT_PLUGIN_TYPE)
1088   ENDIF(QT_QMAKE_CHANGED)
1089
1090   # find_library works better than find_file but we need to set prefixes to only match plugins
1091   FOREACH(QT_PLUGIN_TYPE ${QT_PLUGIN_TYPES})
1092     STRING(TOUPPER ${QT_PLUGIN_TYPE} _upper_qt_plugin_type)
1093     SET(QT_${_upper_qt_plugin_type}_PLUGINS_DIR ${QT_PLUGINS_DIR}/${QT_PLUGIN_TYPE})
1094     FOREACH(QT_PLUGIN ${QT_${_upper_qt_plugin_type}_PLUGINS})
1095       STRING(TOUPPER ${QT_PLUGIN} _upper_qt_plugin)
1096       IF(QT_IS_STATIC)
1097         FIND_LIBRARY(QT_${_upper_qt_plugin}_LIBRARY_RELEASE
1098                      NAMES ${QT_PLUGIN}${QT_LIBINFIX} ${QT_PLUGIN}${QT_LIBINFIX}4
1099                      PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
1100             )
1101         FIND_LIBRARY(QT_${_upper_qt_plugin}_LIBRARY_DEBUG
1102                      NAMES ${QT_PLUGIN}${QT_LIBINFIX}_debug ${QT_PLUGIN}${QT_LIBINFIX}d ${QT_PLUGIN}${QT_LIBINFIX}d4
1103                      PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
1104             )
1105         _QT4_ADJUST_LIB_VARS(${QT_PLUGIN})
1106       ELSE(QT_IS_STATIC)
1107         # find_library works easier/better than find_file but we need to set suffixes to only match plugins
1108         SET(CMAKE_FIND_LIBRARY_SUFFIXES_DEFAULT ${CMAKE_FIND_LIBRARY_SUFFIXES})
1109         SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_MODULE_SUFFIX} ${CMAKE_SHARED_LIBRARY_SUFFIX})
1110         FIND_LIBRARY(QT_${_upper_qt_plugin}_PLUGIN_RELEASE
1111                      NAMES ${QT_PLUGIN}${QT_LIBINFIX} ${QT_PLUGIN}${QT_LIBINFIX}4
1112                      PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
1113             )
1114         FIND_LIBRARY(QT_${_upper_qt_plugin}_PLUGIN_DEBUG
1115                      NAMES ${QT_PLUGIN}${QT_LIBINFIX}_debug ${QT_PLUGIN}${QT_LIBINFIX}d ${QT_PLUGIN}${QT_LIBINFIX}d4
1116                      PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
1117             )
1118         MARK_AS_ADVANCED(QT_${_upper_qt_plugin}_PLUGIN_RELEASE QT_${_upper_qt_plugin}_PLUGIN_DEBUG)
1119         SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_DEFAULT})
1120       ENDIF(QT_IS_STATIC)
1121     ENDFOREACH(QT_PLUGIN)
1122   ENDFOREACH(QT_PLUGIN_TYPE)
1123
1124
1125   ######################################
1126   #
1127   #       Macros for building Qt files
1128   #
1129   ######################################
1130
1131   INCLUDE("${_qt4_current_dir}/Qt4Macros.cmake")
1132
1133   # set version variables
1134   STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" QT_VERSION_MAJOR "${QTVERSION}")
1135   STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" QT_VERSION_MINOR "${QTVERSION}")
1136   STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" QT_VERSION_PATCH "${QTVERSION}")
1137
1138 ENDIF(QT_QMAKE_EXECUTABLE AND QTVERSION)
1139
1140 #support old QT_MIN_VERSION if set, but not if version is supplied by find_package()
1141 IF(NOT Qt4_FIND_VERSION AND QT_MIN_VERSION)
1142   SET(Qt4_FIND_VERSION ${QT_MIN_VERSION})
1143 ENDIF(NOT Qt4_FIND_VERSION AND QT_MIN_VERSION)
1144
1145 IF( Qt4_FIND_COMPONENTS )
1146
1147   # if components specified in find_package(), make sure each of those pieces were found
1148   SET(_QT4_FOUND_REQUIRED_VARS QT_QMAKE_EXECUTABLE QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE QT_INCLUDE_DIR QT_LIBRARY_DIR)
1149   FOREACH( component ${Qt4_FIND_COMPONENTS} )
1150     STRING( TOUPPER ${component} _COMPONENT )
1151     if(${_COMPONENT} STREQUAL "QTMAIN")
1152       IF(Q_WS_WIN)
1153         SET(_QT4_FOUND_REQUIRED_VARS ${_QT4_FOUND_REQUIRED_VARS} QT_${_COMPONENT}_LIBRARY)
1154       ENDIF(Q_WS_WIN)
1155     else(${_COMPONENT} STREQUAL "QTMAIN")
1156       SET(_QT4_FOUND_REQUIRED_VARS ${_QT4_FOUND_REQUIRED_VARS} QT_${_COMPONENT}_INCLUDE_DIR QT_${_COMPONENT}_LIBRARY)
1157     endif(${_COMPONENT} STREQUAL "QTMAIN")
1158   ENDFOREACH( component )
1159
1160   if(Qt4_FIND_COMPONENTS MATCHES QtGui)
1161     SET(_QT4_FOUND_REQUIRED_VARS ${_QT4_FOUND_REQUIRED_VARS} QT_UIC_EXECUTABLE)
1162   endif(Qt4_FIND_COMPONENTS MATCHES QtGui)
1163
1164 ELSE( Qt4_FIND_COMPONENTS )
1165
1166   # if no components specified, we'll make a default set of required variables to say Qt is found
1167   SET(_QT4_FOUND_REQUIRED_VARS QT_QMAKE_EXECUTABLE QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE QT_UIC_EXECUTABLE QT_INCLUDE_DIR
1168     QT_LIBRARY_DIR QT_QTCORE_LIBRARY)
1169
1170 ENDIF( Qt4_FIND_COMPONENTS )
1171
1172 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Qt4
1173   REQUIRED_VARS ${_QT4_FOUND_REQUIRED_VARS}
1174   VERSION_VAR QTVERSION
1175   )
1176
1177 #######################################
1178 #
1179 #       compatibility settings
1180 #
1181 #######################################
1182 # Backwards compatibility for CMake1.4 and 1.2
1183 SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} )
1184 SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} )
1185 SET( QT_QT_LIBRARY "")
1186 SET(QT_FOUND ${QT4_FOUND})
1187