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