BUG: Fix find of dbus dependency in Qt 4.4
[cmake.git] / Modules / FindQt4.cmake
blobab1de994402d28fe9216c52042141a3a20d69bfe
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 # First is QT_USE_FILE which is the path to a CMake file that can be included 
7 # to compile Qt 4 applications and libraries.  By default, the QtCore and QtGui 
8 # libraries are loaded. This behavior can be changed by setting one or more 
9 # of the following variables to true before doing INCLUDE(${QT_USE_FILE}):
10 #                    QT_DONT_USE_QTCORE
11 #                    QT_DONT_USE_QTGUI
12 #                    QT_USE_QT3SUPPORT
13 #                    QT_USE_QTASSISTANT
14 #                    QT_USE_QTDESIGNER
15 #                    QT_USE_QTMOTIF
16 #                    QT_USE_QTMAIN
17 #                    QT_USE_QTNETWORK
18 #                    QT_USE_QTNSPLUGIN
19 #                    QT_USE_QTOPENGL
20 #                    QT_USE_QTSQL
21 #                    QT_USE_QTXML
22 #                    QT_USE_QTSVG
23 #                    QT_USE_QTTEST
24 #                    QT_USE_QTUITOOLS
25 #                    QT_USE_QTDBUS
26 #                    QT_USE_QTSCRIPT
27 #                    QT_USE_QTASSISTANTCLIENT
28 #                    QT_USE_QTHELP
29 #                    QT_USE_QTWEBKIT
30 #                    QT_USE_QTXMLPATTERNS
31 #                    QT_USE_PHONON
33 # The file pointed to by QT_USE_FILE will set up your compile environment
34 # by adding include directories, preprocessor defines, and populate a
35 # QT_LIBRARIES variable containing all the Qt libraries and their dependencies.
36 # Add the QT_LIBRARIES variable to your TARGET_LINK_LIBRARIES.
38 # Typical usage could be something like:
39 #   FIND_PACKAGE(Qt4)
40 #   SET(QT_USE_QTXML 1)
41 #   INCLUDE(${QT_USE_FILE})
42 #   ADD_EXECUTABLE(myexe main.cpp)
43 #   TARGET_LINK_LIBRARIES(myexe ${QT_LIBRARIES})
46 # There are also some files that need processing by some Qt tools such as moc
47 # and uic.  Listed below are macros that may be used to process those files.
48 #  
49 #  macro QT4_WRAP_CPP(outfiles inputfile ... OPTIONS ...)
50 #        create moc code from a list of files containing Qt class with
51 #        the Q_OBJECT declaration.  Per-direcotry preprocessor definitions 
52 #        are also added.  Options may be given to moc, such as those found
53 #        when executing "moc -help".  
55 #  macro QT4_WRAP_UI(outfiles inputfile ... OPTIONS ...)
56 #        create code from a list of Qt designer ui files.
57 #        Options may be given to uic, such as those found
58 #        when executing "uic -help"
60 #  macro QT4_ADD_RESOURCES(outfiles inputfile ... OPTIONS ...)
61 #        create code from a list of Qt resource files.
62 #        Options may be given to rcc, such as those found
63 #        when executing "rcc -help"
65 #  macro QT4_GENERATE_MOC(inputfile outputfile )
66 #        creates a rule to run moc on infile and create outfile.
67 #        Use this if for some reason QT4_WRAP_CPP() isn't appropriate, e.g.
68 #        because you need a custom filename for the moc file or something similar.
70 #  macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... )
71 #        This macro is still experimental.
72 #        It can be used to have moc automatically handled.
73 #        So if you have the files foo.h and foo.cpp, and in foo.h a 
74 #        a class uses the Q_OBJECT macro, moc has to run on it. If you don't
75 #        want to use QT4_WRAP_CPP() (which is reliable and mature), you can insert
76 #        #include "foo.moc"
77 #        in foo.cpp and then give foo.cpp as argument to QT4_AUTOMOC(). This will the
78 #        scan all listed files at cmake-time for such included moc files and if it finds
79 #        them cause a rule to be generated to run moc at build time on the 
80 #        accompanying header file foo.h.
81 #        If a source file has the SKIP_AUTOMOC property set it will be ignored by this macro.
83 #  macro QT4_ADD_DBUS_INTERFACE(outfiles interface basename)
84 #        create a the interface header and implementation files with the 
85 #        given basename from the given interface xml file and add it to 
86 #        the list of sources
88 #  macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... )
89 #        create the interface header and implementation files 
90 #        for all listed interface xml files
91 #        the name will be automatically determined from the name of the xml file
93 #  macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname [basename] )
94 #        create a dbus adaptor (header and implementation file) from the xml file
95 #        describing the interface, and add it to the list of sources. The adaptor
96 #        forwards the calls to a parent class, defined in parentheader and named
97 #        parentclassname. The name of the generated files will be
98 #        <basename>adaptor.{cpp,h} where basename is the basename of the xml file.
100 #  macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] )
101 #        generate the xml interface file from the given header.
102 #        If the optional argument interfacename is omitted, the name of the 
103 #        interface file is constructed from the basename of the header with
104 #        the suffix .xml appended.
106 #  macro QT4_CREATE_TRANSLATION( qm_files directories ... sources ... 
107 #                                ts_files ... OPTIONS ...)
108 #        out: qm_files
109 #        in:  directories sources ts_files
110 #        options: flags to pass to lupdate, such as -extensions to specify
111 #        extensions for a directory scan.
112 #        generates commands to create .ts (vie lupdate) and .qm
113 #        (via lrelease) - files from directories and/or sources. The ts files are 
114 #        created and/or updated in the source tree (unless given with full paths).
115 #        The qm files are generated in the build tree.
116 #        Updating the translations can be done by adding the qm_files
117 #        to the source list of your library/executable, so they are
118 #        always updated, or by adding a custom target to control when
119 #        they get updated/generated.
121 #  macro QT4_ADD_TRANSLATION( qm_files ts_files ... )
122 #        out: qm_files
123 #        in:  ts_files
124 #        generates commands to create .qm from .ts - files. The generated
125 #        filenames can be found in qm_files. The ts_files
126 #        must exists and are not updated in any way.
129 #  QT_FOUND         If false, don't try to use Qt.
130 #  QT4_FOUND        If false, don't try to use Qt 4.
132 #  QT_VERSION_MAJOR The major version of Qt found.
133 #  QT_VERSION_MINOR The minor version of Qt found.
134 #  QT_VERSION_PATCH The patch version of Qt found.
136 #  QT_EDITION               Set to the edition of Qt (i.e. DesktopLight)
137 #  QT_EDITION_DESKTOPLIGHT  True if QT_EDITION == DesktopLight
138 #  QT_QTCORE_FOUND          True if QtCore was found.
139 #  QT_QTGUI_FOUND           True if QtGui was found.
140 #  QT_QT3SUPPORT_FOUND      True if Qt3Support was found.
141 #  QT_QTASSISTANT_FOUND     True if QtAssistant was found.
142 #  QT_QTDBUS_FOUND          True if QtDBus was found.
143 #  QT_QTDESIGNER_FOUND      True if QtDesigner was found.
144 #  QT_QTDESIGNERCOMPONENTS  True if QtDesignerComponents was found.
145 #  QT_QTMOTIF_FOUND         True if QtMotif was found.
146 #  QT_QTNETWORK_FOUND       True if QtNetwork was found.
147 #  QT_QTNSPLUGIN_FOUND      True if QtNsPlugin was found.
148 #  QT_QTOPENGL_FOUND        True if QtOpenGL was found.
149 #  QT_QTSQL_FOUND           True if QtSql was found.
150 #  QT_QTXML_FOUND           True if QtXml was found.
151 #  QT_QTSVG_FOUND           True if QtSvg was found.
152 #  QT_QTSCRIPT_FOUND        True if QtScript was found.
153 #  QT_QTTEST_FOUND          True if QtTest was found.
154 #  QT_QTUITOOLS_FOUND       True if QtUiTools was found.
155 #  QT_QTASSISTANTCLIENT_FOUND  True if QtAssistantClient was found.
156 #  QT_QTHELP_FOUND          True if QtHelp was found.
157 #  QT_QTWEBKIT_FOUND        True if QtWebKit was found.
158 #  QT_QTXMLPATTERNS_FOUND   True if QtXmlPatterns was found.
159 #  QT_PHONON_FOUND          True if phonon was found.
162 #  QT_DEFINITIONS   Definitions to use when compiling code that uses Qt.
163 #                   You do not need to use this if you include QT_USE_FILE.
164 #                   The QT_USE_FILE will also define QT_DEBUG and QT_NO_DEBUG
165 #                   to fit your current build type.  Those are not contained
166 #                   in QT_DEFINITIONS.
167 #                  
168 #  QT_INCLUDES      List of paths to all include directories of 
169 #                   Qt4 QT_INCLUDE_DIR and QT_QTCORE_INCLUDE_DIR are
170 #                   always in this variable even if NOTFOUND,
171 #                   all other INCLUDE_DIRS are
172 #                   only added if they are found.
173 #                   You do not need to use this if you include QT_USE_FILE.
174 #   
176 #  Include directories for the Qt modules are listed here.
177 #  You do not need to use these variables if you include QT_USE_FILE.
179 #  QT_INCLUDE_DIR              Path to "include" of Qt4
180 #  QT_QT_INCLUDE_DIR           Path to "include/Qt" 
181 #  QT_QT3SUPPORT_INCLUDE_DIR   Path to "include/Qt3Support" 
182 #  QT_QTASSISTANT_INCLUDE_DIR  Path to "include/QtAssistant" 
183 #  QT_QTCORE_INCLUDE_DIR       Path to "include/QtCore"         
184 #  QT_QTDESIGNER_INCLUDE_DIR   Path to "include/QtDesigner" 
185 #  QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR   Path to "include/QtDesigner"
186 #  QT_QTDBUS_INCLUDE_DIR       Path to "include/QtDBus" 
187 #  QT_QTGUI_INCLUDE_DIR        Path to "include/QtGui" 
188 #  QT_QTMOTIF_INCLUDE_DIR      Path to "include/QtMotif" 
189 #  QT_QTNETWORK_INCLUDE_DIR    Path to "include/QtNetwork" 
190 #  QT_QTNSPLUGIN_INCLUDE_DIR   Path to "include/QtNsPlugin" 
191 #  QT_QTOPENGL_INCLUDE_DIR     Path to "include/QtOpenGL" 
192 #  QT_QTSQL_INCLUDE_DIR        Path to "include/QtSql" 
193 #  QT_QTXML_INCLUDE_DIR        Path to "include/QtXml" 
194 #  QT_QTSVG_INCLUDE_DIR        Path to "include/QtSvg"
195 #  QT_QTSCRIPT_INCLUDE_DIR     Path to "include/QtScript"
196 #  QT_QTTEST_INCLUDE_DIR       Path to "include/QtTest"
197 #  QT_QTASSISTANTCLIENT_INCLUDE_DIR       Path to "include/QtAssistant"
198 #  QT_QTHELP_INCLUDE_DIR       Path to "include/QtHelp"
199 #  QT_QTWEBKIT_INCLUDE_DIR     Path to "include/QtWebKit"
200 #  QT_QTXMLPATTERNS_INCLUDE_DIR  Path to "include/QtXmlPatterns"
201 #  QT_PHONON_INCLUDE_DIR       Path to "include/phonon"
202 #                            
203 #  QT_LIBRARY_DIR              Path to "lib" of Qt4
205 #  QT_PLUGINS_DIR              Path to "plugins" for Qt4
206 #                            
208 # The Qt toolkit may contain both debug and release libraries.
209 # In that case, the following library variables will contain both.
210 # You do not need to use these variables if you include QT_USE_FILE,
211 # and use QT_LIBRARIES.
213 #  QT_QT3SUPPORT_LIBRARY            The Qt3Support library
214 #  QT_QTASSISTANT_LIBRARY           The QtAssistant library
215 #  QT_QTCORE_LIBRARY                The QtCore library
216 #  QT_QTDBUS_LIBRARY                The QtDBus library
217 #  QT_QTDESIGNER_LIBRARY            The QtDesigner library
218 #  QT_QTDESIGNERCOMPONENTS_LIBRARY  The QtDesignerComponents library
219 #  QT_QTGUI_LIBRARY                 The QtGui library
220 #  QT_QTMOTIF_LIBRARY               The QtMotif library
221 #  QT_QTNETWORK_LIBRARY             The QtNetwork library
222 #  QT_QTNSPLUGIN_LIBRARY            The QtNsPLugin library
223 #  QT_QTOPENGL_LIBRARY              The QtOpenGL library
224 #  QT_QTSQL_LIBRARY                 The QtSql library
225 #  QT_QTXML_LIBRARY                 The QtXml library
226 #  QT_QTSVG_LIBRARY                 The QtSvg library
227 #  QT_QTSCRIPT_LIBRARY              The QtScript library
228 #  QT_QTTEST_LIBRARY                The QtTest library
229 #  QT_QTMAIN_LIBRARY                The qtmain library for Windows
230 #  QT_QTUITOOLS_LIBRARY             The QtUiTools library
231 #  QT_QTASSISTANTCLIENT_LIBRARY     The QtAssistantClient library
232 #  QT_QTHELP_LIBRARY                The QtHelp library
233 #  QT_QTWEBKIT_LIBRARY              The QtWebKit library
234 #  QT_QTXMLPATTERNS_LIBRARY         The QtXmlPatterns library
235 #  QT_PHONON_LIBRARY                The phonon library
236 #  
237 # also defined, but NOT for general use are
238 #  QT_MOC_EXECUTABLE          Where to find the moc tool.
239 #  QT_UIC_EXECUTABLE          Where to find the uic tool.
240 #  QT_UIC3_EXECUTABLE         Where to find the uic3 tool.
241 #  QT_RCC_EXECUTABLE          Where to find the rcc tool
242 #  QT_DBUSCPP2XML_EXECUTABLE  Where to find the qdbuscpp2xml tool.
243 #  QT_DBUSXML2CPP_EXECUTABLE  Where to find the qdbusxml2cpp tool.
244 #  QT_LUPDATE_EXECUTABLE      Where to find the lupdate tool.
245 #  QT_LRELEASE_EXECUTABLE     Where to find the lrelease tool.
246 #  
247 #  QT_DOC_DIR                 Path to "doc" of Qt4
248 #  QT_MKSPECS_DIR             Path to "mkspecs" of Qt4
251 # These are around for backwards compatibility 
252 # they will be set
253 #  QT_WRAP_CPP  Set true if QT_MOC_EXECUTABLE is found
254 #  QT_WRAP_UI   Set true if QT_UIC_EXECUTABLE is found
255 #  
256 # These variables do _NOT_ have any effect anymore (compared to FindQt.cmake)
257 #  QT_MT_REQUIRED         Qt4 is now always multithreaded
258 #  
259 # These variables are set to "" Because Qt structure changed 
260 # (They make no sense in Qt4)
261 #  QT_QT_LIBRARY        Qt-Library is now split
263 # If Qt3 has already been found, fail.
264 IF(QT_QT_LIBRARY)
265   IF(Qt4_FIND_REQUIRED)
266     MESSAGE( FATAL_ERROR "Qt3 and Qt4 cannot be used together in one project.")
267   ELSE(Qt4_FIND_REQUIRED)
268     IF(NOT Qt4_FIND_QUIETLY)
269       MESSAGE( STATUS    "Qt3 and Qt4 cannot be used together in one project.")
270     ENDIF(NOT Qt4_FIND_QUIETLY)
271     RETURN()
272   ENDIF(Qt4_FIND_REQUIRED)
273 ENDIF(QT_QT_LIBRARY)
276 INCLUDE(CheckSymbolExists)
277 INCLUDE(MacroAddFileDependencies)
279 SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake)
281 SET( QT_DEFINITIONS "")
283 SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE)
285 #  macro for asking qmake to process pro files
286 MACRO(QT_QUERY_QMAKE outvar invar)
287   IF(QT_QMAKE_EXECUTABLE)
288   FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake/tmp.pro
289     "message(CMAKE_MESSAGE<$$${invar}>)")
291   # Invoke qmake with the tmp.pro program to get the desired
292   # information.  Use the same variable for both stdout and stderr
293   # to make sure we get the output on all platforms.
294   EXECUTE_PROCESS(COMMAND ${QT_QMAKE_EXECUTABLE}
295     WORKING_DIRECTORY  
296     ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake
297     OUTPUT_VARIABLE _qmake_query_output
298     RESULT_VARIABLE _qmake_result
299     ERROR_VARIABLE _qmake_query_output )
300   
301   FILE(REMOVE_RECURSE 
302     "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake")
304   IF(_qmake_result)
305     MESSAGE(WARNING " querying qmake for ${invar}.  qmake reported:\n${_qmake_query_output}")
306   ELSE(_qmake_result)
307     STRING(REGEX REPLACE ".*CMAKE_MESSAGE<([^>]*).*" "\\1" ${outvar} "${_qmake_query_output}")
308   ENDIF(_qmake_result)
310   ENDIF(QT_QMAKE_EXECUTABLE)
311 ENDMACRO(QT_QUERY_QMAKE)
313 GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME)
314 # check for qmake
315 FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 PATHS
316   "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
317   "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
318   "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]/bin"
319   $ENV{QTDIR}/bin
322 IF (QT_QMAKE_EXECUTABLE)
324   SET(QT4_QMAKE_FOUND FALSE)
325   
326   EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
328   # check for qt3 qmake and then try and find qmake4 or qmake-qt4 in the path
329   IF("${QTVERSION}" MATCHES "Unknown")
330     SET(QT_QMAKE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE)
331     FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 PATHS
332       "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
333       "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
334       $ENV{QTDIR}/bin
335       )
336     IF(QT_QMAKE_EXECUTABLE)
337       EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} 
338         ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
339     ENDIF(QT_QMAKE_EXECUTABLE)
340   ENDIF("${QTVERSION}" MATCHES "Unknown")
342   # check that we found the Qt4 qmake, Qt3 qmake output won't match here
343   STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" qt_version_tmp "${QTVERSION}")
344   IF (qt_version_tmp)
346     # we need at least version 4.0.0
347     IF (NOT QT_MIN_VERSION)
348       SET(QT_MIN_VERSION "4.0.0")
349     ENDIF (NOT QT_MIN_VERSION)
351     #now parse the parts of the user given version string into variables
352     STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" req_qt_major_vers "${QT_MIN_VERSION}")
353     IF (NOT req_qt_major_vers)
354       MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"4.0.1\"")
355     ENDIF (NOT req_qt_major_vers)
357     # now parse the parts of the user given version string into variables
358     STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}")
359     STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers "${QT_MIN_VERSION}")
360     STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}")
362     IF (NOT req_qt_major_vers EQUAL 4)
363       MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", major version 4 is required, e.g. \"4.0.1\"")
364     ENDIF (NOT req_qt_major_vers EQUAL 4)
366     # and now the version string given by qmake
367     STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" QT_VERSION_MAJOR "${QTVERSION}")
368     STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" QT_VERSION_MINOR "${QTVERSION}")
369     STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" QT_VERSION_PATCH "${QTVERSION}")
371     # compute an overall version number which can be compared at once
372     MATH(EXPR req_vers "${req_qt_major_vers}*10000 + ${req_qt_minor_vers}*100 + ${req_qt_patch_vers}")
373     MATH(EXPR found_vers "${QT_VERSION_MAJOR}*10000 + ${QT_VERSION_MINOR}*100 + ${QT_VERSION_PATCH}")
375     IF (found_vers LESS req_vers)
376       SET(QT4_QMAKE_FOUND FALSE)
377       SET(QT4_INSTALLED_VERSION_TOO_OLD TRUE)
378     ELSE (found_vers LESS req_vers)
379       SET(QT4_QMAKE_FOUND TRUE)
380     ENDIF (found_vers LESS req_vers)
381   ENDIF (qt_version_tmp)
383 ENDIF (QT_QMAKE_EXECUTABLE)
385 IF (QT4_QMAKE_FOUND)
387   # ask qmake for the library dir
388   # Set QT_LIBRARY_DIR
389   IF (NOT QT_LIBRARY_DIR)
390     EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
391       ARGS "-query QT_INSTALL_LIBS"
392       OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP )
393     # make sure we have / and not \ as qmake gives on windows
394     FILE(TO_CMAKE_PATH "${QT_LIBRARY_DIR_TMP}" QT_LIBRARY_DIR_TMP)
395     IF(EXISTS "${QT_LIBRARY_DIR_TMP}")
396       SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir")
397     ELSE(EXISTS "${QT_LIBRARY_DIR_TMP}")
398       MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}")
399       MESSAGE("Warning: ${QT_LIBRARY_DIR_TMP} does NOT exist, Qt must NOT be installed correctly.")
400     ENDIF(EXISTS "${QT_LIBRARY_DIR_TMP}")
401   ENDIF(NOT QT_LIBRARY_DIR)
402   
403   IF (APPLE)
404     IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
405       SET(QT_USE_FRAMEWORKS ON
406         CACHE BOOL "Set to ON if Qt build uses frameworks.")
407     ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
408       SET(QT_USE_FRAMEWORKS OFF
409         CACHE BOOL "Set to ON if Qt build uses frameworks.")
410     ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
411     
412     MARK_AS_ADVANCED(QT_USE_FRAMEWORKS)
413   ENDIF (APPLE)
414   
415   # ask qmake for the binary dir
416   IF (QT_LIBRARY_DIR AND NOT QT_BINARY_DIR)
417      EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE}
418        ARGS "-query QT_INSTALL_BINS"
419        OUTPUT_VARIABLE qt_bins )
420      # make sure we have / and not \ as qmake gives on windows
421      FILE(TO_CMAKE_PATH "${qt_bins}" qt_bins)
422      SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "")
423   ENDIF (QT_LIBRARY_DIR AND NOT QT_BINARY_DIR)
425   # ask qmake for the include dir
426   IF (QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR)
427       EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
428         ARGS "-query QT_INSTALL_HEADERS" 
429         OUTPUT_VARIABLE qt_headers ) 
430       # make sure we have / and not \ as qmake gives on windows
431       FILE(TO_CMAKE_PATH "${qt_headers}" qt_headers)
432       SET(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "")
433   ENDIF(QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR)
436   # ask qmake for the documentation directory
437   IF (QT_LIBRARY_DIR AND NOT QT_DOC_DIR)
438     EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
439       ARGS "-query QT_INSTALL_DOCS"
440       OUTPUT_VARIABLE qt_doc_dir )
441     # make sure we have / and not \ as qmake gives on windows
442     FILE(TO_CMAKE_PATH "${qt_doc_dir}" qt_doc_dir)
443     SET(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs")
444   ENDIF (QT_LIBRARY_DIR AND NOT QT_DOC_DIR)
446   # ask qmake for the mkspecs directory
447   IF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR)
448     EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
449       ARGS "-query QMAKE_MKSPECS"
450       OUTPUT_VARIABLE qt_mkspecs_dirs )
451     # do not replace : on windows as it might be a drive letter
452     # and windows should already use ; as a separator
453     IF(UNIX)
454       STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}")
455     ENDIF(UNIX)
456     FIND_PATH(QT_MKSPECS_DIR qconfig.pri PATHS ${qt_mkspecs_dirs}
457       DOC "The location of the Qt mkspecs containing qconfig.pri"
458       NO_DEFAULT_PATH )
459   ENDIF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR)
461   # ask qmake for the plugins directory
462   IF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR)
463     EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
464       ARGS "-query QT_INSTALL_PLUGINS"
465       OUTPUT_VARIABLE qt_plugins_dir )
466     # make sure we have / and not \ as qmake gives on windows
467     FILE(TO_CMAKE_PATH "${qt_plugins_dir}" qt_plugins_dir)
468     SET(QT_PLUGINS_DIR ${qt_plugins_dir} CACHE PATH "The location of the Qt plugins")
469   ENDIF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR)
470   ########################################
471   #
472   #       Setting the INCLUDE-Variables
473   #
474   ########################################
476   FIND_PATH(QT_QTCORE_INCLUDE_DIR QtGlobal
477     PATHS
478     ${QT_HEADERS_DIR}/QtCore
479     ${QT_LIBRARY_DIR}/QtCore.framework/Headers
480     NO_DEFAULT_PATH
481     )
483   # Set QT_INCLUDE_DIR by removine "/QtCore" in the string ${QT_QTCORE_INCLUDE_DIR}
484   IF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
485     IF (QT_USE_FRAMEWORKS)
486       SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR})
487     ELSE (QT_USE_FRAMEWORKS)
488       STRING( REGEX REPLACE "/QtCore$" "" qt4_include_dir ${QT_QTCORE_INCLUDE_DIR})
489       SET( QT_INCLUDE_DIR ${qt4_include_dir} CACHE PATH "")
490     ENDIF (QT_USE_FRAMEWORKS)
491   ENDIF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
493   IF( NOT QT_INCLUDE_DIR)
494     IF(Qt4_FIND_REQUIRED)
495       MESSAGE( FATAL_ERROR "Could NOT find QtGlobal header")
496     ENDIF(Qt4_FIND_REQUIRED)
497   ENDIF( NOT QT_INCLUDE_DIR)
499   #############################################
500   #
501   # Find out what window system we're using
502   #
503   #############################################
504   # Save required variable
505   SET(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
506   SET(CMAKE_REQUIRED_FLAGS_SAVE    ${CMAKE_REQUIRED_FLAGS})
507   # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES
508   SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}")
509   # On Mac OS X when Qt has framework support, also add the framework path
510   IF( QT_USE_FRAMEWORKS )
511     SET(CMAKE_REQUIRED_FLAGS "-F${QT_LIBRARY_DIR} ")
512   ENDIF( QT_USE_FRAMEWORKS )
513   # Check for Window system symbols (note: only one should end up being set)
514   CHECK_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11)
515   CHECK_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN)
516   CHECK_SYMBOL_EXISTS(Q_WS_QWS "QtCore/qglobal.h" Q_WS_QWS)
517   CHECK_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC)
519   IF (QT_QTCOPY_REQUIRED)
520      CHECK_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY)
521      IF (NOT QT_IS_QTCOPY)
522         MESSAGE(FATAL_ERROR "qt-copy is required, but hasn't been found")
523      ENDIF (NOT QT_IS_QTCOPY)
524   ENDIF (QT_QTCOPY_REQUIRED)
526   # Restore CMAKE_REQUIRED_INCLUDES and CMAKE_REQUIRED_FLAGS variables
527   SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
528   SET(CMAKE_REQUIRED_FLAGS    ${CMAKE_REQUIRED_FLAGS_SAVE})
529   #
530   #############################################
532   # Set QT_QT3SUPPORT_INCLUDE_DIR
533   FIND_PATH(QT_QT3SUPPORT_INCLUDE_DIR Qt3Support
534     PATHS
535     ${QT_INCLUDE_DIR}/Qt3Support
536     ${QT_LIBRARY_DIR}/Qt3Support.framework/Headers
537     NO_DEFAULT_PATH
538     )
540   # Set QT_QT_INCLUDE_DIR
541   FIND_PATH(QT_QT_INCLUDE_DIR qglobal.h
542     PATHS
543     ${QT_INCLUDE_DIR}/Qt
544     ${QT_LIBRARY_DIR}/QtCore.framework/Headers
545     NO_DEFAULT_PATH
546     )
548   # Set QT_QTGUI_INCLUDE_DIR
549   FIND_PATH(QT_QTGUI_INCLUDE_DIR QtGui
550     PATHS
551     ${QT_INCLUDE_DIR}/QtGui
552     ${QT_LIBRARY_DIR}/QtGui.framework/Headers
553     NO_DEFAULT_PATH
554     )
556   # Set QT_QTSVG_INCLUDE_DIR
557   FIND_PATH(QT_QTSVG_INCLUDE_DIR QtSvg
558     PATHS
559     ${QT_INCLUDE_DIR}/QtSvg
560     ${QT_LIBRARY_DIR}/QtSvg.framework/Headers
561     NO_DEFAULT_PATH
562     )
564   # Set QT_QTSCRIPT_INCLUDE_DIR
565   FIND_PATH(QT_QTSCRIPT_INCLUDE_DIR QtScript
566     PATHS
567     ${QT_INCLUDE_DIR}/QtScript
568     ${QT_LIBRARY_DIR}/QtScript.framework/Headers
569     NO_DEFAULT_PATH
570     )
572   # Set QT_QTTEST_INCLUDE_DIR
573   FIND_PATH(QT_QTTEST_INCLUDE_DIR QtTest
574     PATHS
575     ${QT_INCLUDE_DIR}/QtTest
576     ${QT_LIBRARY_DIR}/QtTest.framework/Headers
577     NO_DEFAULT_PATH
578     )
580   # Set QT_QTUITOOLS_INCLUDE_DIR
581   FIND_PATH(QT_QTUITOOLS_INCLUDE_DIR QtUiTools
582     PATHS
583     ${QT_INCLUDE_DIR}/QtUiTools
584     ${QT_LIBRARY_DIR}/QtUiTools.framework/Headers
585     NO_DEFAULT_PATH
586     )
588   # Set QT_QTMOTIF_INCLUDE_DIR
589   IF(Q_WS_X11)
590     FIND_PATH(QT_QTMOTIF_INCLUDE_DIR QtMotif 
591       PATHS 
592       ${QT_INCLUDE_DIR}/QtMotif 
593       NO_DEFAULT_PATH )
594   ENDIF(Q_WS_X11)
596   # Set QT_QTNETWORK_INCLUDE_DIR
597   FIND_PATH(QT_QTNETWORK_INCLUDE_DIR QtNetwork
598     PATHS
599     ${QT_INCLUDE_DIR}/QtNetwork
600     ${QT_LIBRARY_DIR}/QtNetwork.framework/Headers
601     NO_DEFAULT_PATH
602     )
604   # Set QT_QTNSPLUGIN_INCLUDE_DIR
605   FIND_PATH(QT_QTNSPLUGIN_INCLUDE_DIR QtNsPlugin
606     PATHS
607     ${QT_INCLUDE_DIR}/QtNsPlugin
608     ${QT_LIBRARY_DIR}/QtNsPlugin.framework/Headers
609     NO_DEFAULT_PATH
610     )
612   # Set QT_QTOPENGL_INCLUDE_DIR
613   FIND_PATH(QT_QTOPENGL_INCLUDE_DIR QtOpenGL
614     PATHS
615     ${QT_INCLUDE_DIR}/QtOpenGL
616     ${QT_LIBRARY_DIR}/QtOpenGL.framework/Headers
617     NO_DEFAULT_PATH
618     )
620   # Set QT_QTSQL_INCLUDE_DIR
621   FIND_PATH(QT_QTSQL_INCLUDE_DIR QtSql
622     PATHS
623     ${QT_INCLUDE_DIR}/QtSql
624     ${QT_LIBRARY_DIR}/QtSql.framework/Headers
625     NO_DEFAULT_PATH
626     )
628   # Set QT_QTXML_INCLUDE_DIR
629   FIND_PATH(QT_QTXML_INCLUDE_DIR QtXml
630     PATHS
631     ${QT_INCLUDE_DIR}/QtXml
632     ${QT_LIBRARY_DIR}/QtXml.framework/Headers
633     NO_DEFAULT_PATH
634     )
636   # Set QT_QTASSISTANT_INCLUDE_DIR
637   FIND_PATH(QT_QTASSISTANT_INCLUDE_DIR QtAssistant
638     PATHS
639     ${QT_INCLUDE_DIR}/QtAssistant
640     ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers
641     NO_DEFAULT_PATH
642     )
644   # Set QT_QTDESIGNER_INCLUDE_DIR
645   FIND_PATH(QT_QTDESIGNER_INCLUDE_DIR QDesignerComponents
646     PATHS
647     ${QT_INCLUDE_DIR}/QtDesigner
648     ${QT_LIBRARY_DIR}/QtDesigner.framework/Headers
649     NO_DEFAULT_PATH
650     )
652   # Set QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR
653   FIND_PATH(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR QDesignerComponents
654     PATHS
655     ${QT_INCLUDE_DIR}/QtDesigner
656     ${QT_LIBRARY_DIR}/QtDesigner.framework/Headers
657     NO_DEFAULT_PATH
658     )
660   # Set QT_QTDBUS_INCLUDE_DIR
661   FIND_PATH(QT_QTDBUS_INCLUDE_DIR QtDBus
662     PATHS
663     ${QT_INCLUDE_DIR}/QtDBus
664     ${QT_LIBRARY_DIR}/QtDBus.framework/Headers
665     NO_DEFAULT_PATH
666     )
667   
668   # Set QT_QTASSISTANTCLIENT_INCLUDE_DIR
669   FIND_PATH(QT_QTASSISTANTCLIENT_INCLUDE_DIR QAssistantClient
670     PATHS
671     ${QT_INCLUDE_DIR}/QtAssistant
672     ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers
673     NO_DEFAULT_PATH
674     )
675   
676   # Set QT_QTHELP_INCLUDE_DIR
677   FIND_PATH(QT_QTHELP_INCLUDE_DIR QtHelp
678     PATHS
679     ${QT_INCLUDE_DIR}/QtHelp
680     ${QT_LIBRARY_DIR}/QtHelp.framework/Headers
681     NO_DEFAULT_PATH
682     )
683   
684   # Set QT_QTWEBKIT_INCLUDE_DIR
685   FIND_PATH(QT_QTWEBKIT_INCLUDE_DIR QtWebKit
686     PATHS
687     ${QT_INCLUDE_DIR}/QtWebKit
688     ${QT_LIBRARY_DIR}/QtWebKit.framework/Headers
689     NO_DEFAULT_PATH
690     )
691   
692   # Set QT_QTXMLPATTERNS_INCLUDE_DIR
693   FIND_PATH(QT_QTXMLPATTERNS_INCLUDE_DIR QtXmlPatterns
694     PATHS
695     ${QT_INCLUDE_DIR}/QtXmlPatterns
696     ${QT_LIBRARY_DIR}/QtXmlPatterns.framework/Headers
697     NO_DEFAULT_PATH
698     )
699   
700   # Set QT_PHONON_INCLUDE_DIR
701   FIND_PATH(QT_PHONON_INCLUDE_DIR phonon
702     PATHS
703     ${QT_INCLUDE_DIR}/phonon
704     ${QT_LIBRARY_DIR}/phonon.framework/Headers
705     NO_DEFAULT_PATH
706     )
708   # Make variables changeble to the advanced user
709   MARK_AS_ADVANCED( QT_LIBRARY_DIR QT_INCLUDE_DIR QT_QT_INCLUDE_DIR QT_DOC_DIR QT_MKSPECS_DIR QT_PLUGINS_DIR)
711   # Set QT_INCLUDES
712   SET( QT_INCLUDES ${QT_QT_INCLUDE_DIR} ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} )
714   # Set QT_QTCORE_LIBRARY by searching for a lib with "QtCore."  as part of the filename
715   FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE NAMES QtCore QtCore4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH )
716   FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG NAMES QtCore_debug QtCored QtCored4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
718   # Set QT_QT3SUPPORT_LIBRARY
719   FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_RELEASE NAMES Qt3Support Qt3Support4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
720   FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG   NAMES Qt3Support_debug Qt3Supportd Qt3Supportd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
722   # Set QT_QTGUI_LIBRARY
723   FIND_LIBRARY(QT_QTGUI_LIBRARY_RELEASE NAMES QtGui QtGui4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
724   FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG   NAMES QtGui_debug QtGuid QtGuid4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
726   # Set QT_QTMOTIF_LIBRARY
727   IF(Q_WS_X11)
728     FIND_LIBRARY(QT_QTMOTIF_LIBRARY_RELEASE NAMES QtMotif PATHS ${QT_LIBRARY_DIR}       NO_DEFAULT_PATH)
729     FIND_LIBRARY(QT_QTMOTIF_LIBRARY_DEBUG   NAMES QtMotif_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
730   ENDIF(Q_WS_X11)
732   # Set QT_QTNETWORK_LIBRARY
733   FIND_LIBRARY(QT_QTNETWORK_LIBRARY_RELEASE NAMES QtNetwork QtNetwork4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
734   FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG   NAMES QtNetwork_debug QtNetworkd QtNetworkd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
736   # Set QT_QTNSPLUGIN_LIBRARY
737   FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_RELEASE NAMES QtNsPlugin PATHS ${QT_LIBRARY_DIR}       NO_DEFAULT_PATH)
738   FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_DEBUG   NAMES QtNsPlugin_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
740   # Set QT_QTOPENGL_LIBRARY
741   FIND_LIBRARY(QT_QTOPENGL_LIBRARY_RELEASE NAMES QtOpenGL QtOpenGL4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
742   FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG   NAMES QtOpenGL_debug QtOpenGLd QtOpenGLd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
744   # Set QT_QTSQL_LIBRARY
745   FIND_LIBRARY(QT_QTSQL_LIBRARY_RELEASE NAMES QtSql QtSql4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
746   FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG   NAMES QtSql_debug QtSqld QtSqld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
748   # Set QT_QTXML_LIBRARY
749   FIND_LIBRARY(QT_QTXML_LIBRARY_RELEASE NAMES QtXml QtXml4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
750   FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG   NAMES QtXml_debug QtXmld QtXmld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
752   # Set QT_QTSVG_LIBRARY
753   FIND_LIBRARY(QT_QTSVG_LIBRARY_RELEASE NAMES QtSvg QtSvg4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
754   FIND_LIBRARY(QT_QTSVG_LIBRARY_DEBUG   NAMES QtSvg_debug QtSvgd QtSvgd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
756   # Set QT_QTUITOOLS_LIBRARY
757   FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools QtUiTools4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
758   FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_DEBUG   NAMES QtUiTools_debug QtUiToolsd QtUiToolsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
759   # QtUiTools not with other frameworks with binary installation (in /usr/lib)
760   IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE)
761     FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools PATHS ${QT_LIBRARY_DIR})
762   ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE)
764   # Set QT_QTTEST_LIBRARY
765   FIND_LIBRARY(QT_QTTEST_LIBRARY_RELEASE NAMES QtTest QtTest4 PATHS ${QT_LIBRARY_DIR}                      NO_DEFAULT_PATH)
766   FIND_LIBRARY(QT_QTTEST_LIBRARY_DEBUG   NAMES QtTest_debug QtTestd QtTestd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
768   # Set QT_QTDBUS_LIBRARY
769   # This was introduced with Qt 4.2, where also the naming scheme for debug libs was changed
770   # So does any of the debug lib names listed here actually exist ?
771   FIND_LIBRARY(QT_QTDBUS_LIBRARY_RELEASE NAMES QtDBus QtDBus4 PATHS ${QT_LIBRARY_DIR}                       NO_DEFAULT_PATH)
772   FIND_LIBRARY(QT_QTDBUS_LIBRARY_DEBUG   NAMES QtDBus_debug QtDBusd QtDBusd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
774   # Set QT_QTSCRIPT_LIBRARY
775   FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_RELEASE NAMES QtScript QtScript4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
776   FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_DEBUG   NAMES QtScript_debug QtScriptd QtScriptd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
778   IF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE )
779     
780     # try dropping a hint if trying to use Visual Studio with Qt built by mingw
781     IF(QT_LIBRARY_DIR AND MSVC)
782       IF(EXISTS ${QT_LIBRARY_DIR}/libqtmain.a)
783         MESSAGE( FATAL_ERROR "It appears you're trying to use Visual Studio with Qt built by mingw")
784       ENDIF(EXISTS ${QT_LIBRARY_DIR}/libqtmain.a)
785     ENDIF(QT_LIBRARY_DIR AND MSVC)
787     IF(Qt4_FIND_REQUIRED)
788       MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.")
789     ENDIF(Qt4_FIND_REQUIRED)
790   ENDIF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE )
792   # Set QT_QTASSISTANT_LIBRARY
793   FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient QtAssistantClient4 QtAssistant QtAssistant4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
794   FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG   NAMES QtAssistantClientd QtAssistantClientd4 QtAssistantClient_debug QtAssistant_debug QtAssistantd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
796   # Set QT_QTDESIGNER_LIBRARY
797   FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_RELEASE NAMES QtDesigner QtDesigner4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
798   FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_DEBUG   NAMES QtDesigner_debug QtDesignerd QtDesignerd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
800   # Set QT_QTDESIGNERCOMPONENTS_LIBRARY
801   FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents QtDesignerComponents4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
802   FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG   NAMES QtDesignerComponents_debug QtDesignerComponentsd QtDesignerComponentsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
804   # Set QT_QTMAIN_LIBRARY
805   IF(WIN32)
806     FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain PATHS ${QT_LIBRARY_DIR}
807       NO_DEFAULT_PATH)
808     FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmaind PATHS ${QT_LIBRARY_DIR}
809       NO_DEFAULT_PATH)
810   ENDIF(WIN32)
811   
812   # Set QT_QTASSISTANTCLIENT_LIBRARY
813   FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NAMES QtAssistantClient QtAssistantClient4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
814   FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG   NAMES QtAssistantClient_debug QtAssistantClientd QtAssistantClientd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
816   # Set QT_QTHELP_LIBRARY
817   FIND_LIBRARY(QT_QTHELP_LIBRARY_RELEASE NAMES QtHelp QtHelp4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
818   FIND_LIBRARY(QT_QTHELP_LIBRARY_DEBUG   NAMES QtHelp_debug QtHelpd QtHelpd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
819   FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene QtCLucene4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
820   FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_DEBUG   NAMES QtCLucene_debug QtCLucened QtCLucened4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
821   # QtCLucene not with other frameworks with binary installation (in /usr/lib)
822   IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE)
823     FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene PATHS ${QT_LIBRARY_DIR})
824   ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE)
826   # Set QT_QTWEBKIT_LIBRARY
827   FIND_LIBRARY(QT_QTWEBKIT_LIBRARY_RELEASE NAMES QtWebKit QtWebKit4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
828   FIND_LIBRARY(QT_QTWEBKIT_LIBRARY_DEBUG   NAMES QtWebKit_debug QtWebKitd QtWebKitd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
830   # Set QT_QTXMLPATTERNS_LIBRARY
831   FIND_LIBRARY(QT_QTXMLPATTERNS_LIBRARY_RELEASE NAMES QtXmlPatterns QtXmlPatterns4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
832   FIND_LIBRARY(QT_QTXMLPATTERNS_LIBRARY_DEBUG   NAMES QtXmlPatterns_debug QtXmlPatternsd QtXmlPatternsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
833   
834   # Set QT_PHONON_LIBRARY
835   FIND_LIBRARY(QT_PHONON_LIBRARY_RELEASE NAMES phonon phonon4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
836   FIND_LIBRARY(QT_PHONON_LIBRARY_DEBUG   NAMES phonon_debug phonond phonond4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
838   ############################################
839   #
840   # Check the existence of the libraries.
841   #
842   ############################################
844   MACRO (_QT4_ADJUST_LIB_VARS basename)
845     IF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG)
847       # if only the release version was found, set the debug variable also to the release version
848       IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
849         SET(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE})
850         SET(QT_${basename}_LIBRARY       ${QT_${basename}_LIBRARY_RELEASE})
851         SET(QT_${basename}_LIBRARIES     ${QT_${basename}_LIBRARY_RELEASE})
852       ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
854       # if only the debug version was found, set the release variable also to the debug version
855       IF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE)
856         SET(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG})
857         SET(QT_${basename}_LIBRARY         ${QT_${basename}_LIBRARY_DEBUG})
858         SET(QT_${basename}_LIBRARIES       ${QT_${basename}_LIBRARY_DEBUG})
859       ENDIF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE)
861       IF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
862         # if the generator supports configuration types then set
863         # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
864         IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
865           SET(QT_${basename}_LIBRARY       optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
866         ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
867           # if there are no configuration types and CMAKE_BUILD_TYPE has no value
868           # then just use the release libraries
869           SET(QT_${basename}_LIBRARY       ${QT_${basename}_LIBRARY_RELEASE} )
870         ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
871         SET(QT_${basename}_LIBRARIES       optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
872       ENDIF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
874       SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE FILEPATH "The Qt ${basename} library")
876       IF (QT_${basename}_LIBRARY)
877         SET(QT_${basename}_FOUND 1)
878       ENDIF (QT_${basename}_LIBRARY)
880     ENDIF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG)
882     IF (QT_${basename}_INCLUDE_DIR)
883       #add the include directory to QT_INCLUDES
884       SET(QT_INCLUDES "${QT_${basename}_INCLUDE_DIR}" ${QT_INCLUDES})
885     ENDIF (QT_${basename}_INCLUDE_DIR)
887     # Make variables changeble to the advanced user
888     MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR)
889   ENDMACRO (_QT4_ADJUST_LIB_VARS)
892   # Set QT_xyz_LIBRARY variable and add 
893   # library include path to QT_INCLUDES
894   _QT4_ADJUST_LIB_VARS(QTCORE)
895   _QT4_ADJUST_LIB_VARS(QTGUI)
896   _QT4_ADJUST_LIB_VARS(QT3SUPPORT)
897   _QT4_ADJUST_LIB_VARS(QTASSISTANT)
898   _QT4_ADJUST_LIB_VARS(QTDESIGNER)
899   _QT4_ADJUST_LIB_VARS(QTDESIGNERCOMPONENTS)
900   _QT4_ADJUST_LIB_VARS(QTNETWORK)
901   _QT4_ADJUST_LIB_VARS(QTNSPLUGIN)
902   _QT4_ADJUST_LIB_VARS(QTOPENGL)
903   _QT4_ADJUST_LIB_VARS(QTSQL)
904   _QT4_ADJUST_LIB_VARS(QTXML)
905   _QT4_ADJUST_LIB_VARS(QTSVG)
906   _QT4_ADJUST_LIB_VARS(QTSCRIPT)
907   _QT4_ADJUST_LIB_VARS(QTUITOOLS)
908   _QT4_ADJUST_LIB_VARS(QTTEST)
909   _QT4_ADJUST_LIB_VARS(QTDBUS)
910   _QT4_ADJUST_LIB_VARS(QTASSISTANTCLIENT)
911   _QT4_ADJUST_LIB_VARS(QTHELP)
912   _QT4_ADJUST_LIB_VARS(QTWEBKIT)
913   _QT4_ADJUST_LIB_VARS(QTXMLPATTERNS)
914   _QT4_ADJUST_LIB_VARS(PHONON)
915   _QT4_ADJUST_LIB_VARS(QTCLUCENE)
917   # platform dependent libraries
918   IF(Q_WS_X11)
919     _QT4_ADJUST_LIB_VARS(QTMOTIF)
920   ENDIF(Q_WS_X11)
921   IF(WIN32)
922     _QT4_ADJUST_LIB_VARS(QTMAIN)
923   ENDIF(WIN32)
924   
926   #######################################
927   #
928   #       Check the executables of Qt 
929   #          ( moc, uic, rcc )
930   #
931   #######################################
934   # find moc and uic using qmake
935   QT_QUERY_QMAKE(QT_MOC_EXECUTABLE_INTERNAL "QMAKE_MOC")
936   QT_QUERY_QMAKE(QT_UIC_EXECUTABLE_INTERNAL "QMAKE_UIC")
938   # make sure we have / and not \ as qmake gives on windows
939   FILE(TO_CMAKE_PATH 
940     "${QT_MOC_EXECUTABLE_INTERNAL}" QT_MOC_EXECUTABLE_INTERNAL)
941   # make sure we have / and not \ as qmake gives on windows
942   FILE(TO_CMAKE_PATH 
943     "${QT_UIC_EXECUTABLE_INTERNAL}" QT_UIC_EXECUTABLE_INTERNAL)
945   SET(QT_MOC_EXECUTABLE 
946     ${QT_MOC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The moc executable")
947   SET(QT_UIC_EXECUTABLE 
948     ${QT_UIC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The uic executable")
950   FIND_PROGRAM(QT_UIC3_EXECUTABLE
951     NAMES uic3
952     PATHS ${QT_BINARY_DIR}
953     NO_DEFAULT_PATH
954     )
956   FIND_PROGRAM(QT_RCC_EXECUTABLE 
957     NAMES rcc
958     PATHS ${QT_BINARY_DIR}
959     NO_DEFAULT_PATH
960     )
962   FIND_PROGRAM(QT_DBUSCPP2XML_EXECUTABLE 
963     NAMES qdbuscpp2xml
964     PATHS ${QT_BINARY_DIR}
965     NO_DEFAULT_PATH
966     )
968   FIND_PROGRAM(QT_DBUSXML2CPP_EXECUTABLE 
969     NAMES qdbusxml2cpp
970     PATHS ${QT_BINARY_DIR}
971     NO_DEFAULT_PATH
972     )
974   FIND_PROGRAM(QT_LUPDATE_EXECUTABLE
975     NAMES lupdate
976     PATHS ${QT_BINARY_DIR}
977     NO_DEFAULT_PATH
978     )
980   FIND_PROGRAM(QT_LRELEASE_EXECUTABLE
981     NAMES lrelease
982     PATHS ${QT_BINARY_DIR}
983     NO_DEFAULT_PATH
984     )
986   IF (QT_MOC_EXECUTABLE)
987      SET(QT_WRAP_CPP "YES")
988   ENDIF (QT_MOC_EXECUTABLE)
990   IF (QT_UIC_EXECUTABLE)
991      SET(QT_WRAP_UI "YES")
992   ENDIF (QT_UIC_EXECUTABLE)
996   MARK_AS_ADVANCED( QT_UIC_EXECUTABLE QT_UIC3_EXECUTABLE QT_MOC_EXECUTABLE
997     QT_RCC_EXECUTABLE QT_DBUSXML2CPP_EXECUTABLE QT_DBUSCPP2XML_EXECUTABLE
998     QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE)
1000   ######################################
1001   #
1002   #       Macros for building Qt files
1003   #
1004   ######################################
1006   MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
1007     SET(${_qt4_files})
1008     SET(${_qt4_options})
1009     SET(_QT4_DOING_OPTIONS FALSE)
1010     FOREACH(_currentArg ${ARGN})
1011       IF ("${_currentArg}" STREQUAL "OPTIONS")
1012         SET(_QT4_DOING_OPTIONS TRUE)
1013       ELSE ("${_currentArg}" STREQUAL "OPTIONS")
1014         IF(_QT4_DOING_OPTIONS) 
1015           LIST(APPEND ${_qt4_options} "${_currentArg}")
1016         ELSE(_QT4_DOING_OPTIONS)
1017           LIST(APPEND ${_qt4_files} "${_currentArg}")
1018         ENDIF(_QT4_DOING_OPTIONS)
1019       ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
1020     ENDFOREACH(_currentArg) 
1021   ENDMACRO (QT4_EXTRACT_OPTIONS)
1022   
1023   # macro used to create the names of output files preserving relative dirs
1024   MACRO (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile )
1025     STRING(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
1026     STRING(LENGTH ${infile} _infileLength)
1027     SET(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
1028     IF(_infileLength GREATER _binlength)
1029       STRING(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
1030     ENDIF(_infileLength GREATER _binlength)
1031     IF(CMAKE_CURRENT_BINARY_DIR MATCHES "${_checkinfile}")
1032       FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
1033     ELSE(CMAKE_CURRENT_BINARY_DIR MATCHES "${_checkinfile}")
1034       FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
1035     ENDIF(CMAKE_CURRENT_BINARY_DIR MATCHES "${_checkinfile}")
1036     SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
1037     STRING(REPLACE ".." "__" _outfile ${_outfile})
1038     GET_FILENAME_COMPONENT(outpath ${_outfile} PATH)
1039     GET_FILENAME_COMPONENT(_outfile ${_outfile} NAME_WE)
1040     FILE(MAKE_DIRECTORY ${outpath})
1041     SET(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
1042   ENDMACRO (QT4_MAKE_OUTPUT_FILE )
1044   MACRO (QT4_GET_MOC_FLAGS _moc_flags)
1045      SET(${_moc_flags})
1046      GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES)
1048      FOREACH(_current ${_inc_DIRS})
1049         SET(${_moc_flags} ${${_moc_flags}} "-I${_current}")
1050      ENDFOREACH(_current ${_inc_DIRS})
1051      
1052      GET_DIRECTORY_PROPERTY(_defines COMPILE_DEFINITIONS)
1053      FOREACH(_current ${_defines})
1054         SET(${_moc_flags} ${${_moc_flags}} "-D${_current}")
1055      ENDFOREACH(_current ${_defines})
1057      IF(Q_WS_WIN)
1058        SET(${_moc_flags} ${${_moc_flags}} -DWIN32)
1059      ENDIF(Q_WS_WIN)
1061   ENDMACRO(QT4_GET_MOC_FLAGS)
1063   # helper macro to set up a moc rule
1064   MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options)
1065     # For Windows, create a parameters file to work around command line length limit
1066     IF (WIN32)
1067       # Pass the parameters in a file.  Set the working directory to
1068       # be that containing the parameters file and reference it by
1069       # just the file name.  This is necessary because the moc tool on
1070       # MinGW builds does not seem to handle spaces in the path to the
1071       # file given with the @ syntax.
1072       GET_FILENAME_COMPONENT(_moc_outfile_name "${outfile}" NAME)
1073       GET_FILENAME_COMPONENT(_moc_outfile_dir "${outfile}" PATH)
1074       IF(_moc_outfile_dir)
1075         SET(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
1076       ENDIF(_moc_outfile_dir)
1077       SET (_moc_parameters_file ${outfile}_parameters)
1078       SET (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}")
1079       FILE (REMOVE ${_moc_parameters_file})
1080       FOREACH(arg ${_moc_parameters})
1081         FILE (APPEND ${_moc_parameters_file} "${arg}\n")
1082       ENDFOREACH(arg)
1083       ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1084                          COMMAND ${QT_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters
1085                          DEPENDS ${infile}
1086                          ${_moc_working_dir}
1087                          VERBATIM)
1088     ELSE (WIN32)     
1089       ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1090                          COMMAND ${QT_MOC_EXECUTABLE}
1091                          ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile}
1092                          DEPENDS ${infile})     
1093     ENDIF (WIN32)
1094   ENDMACRO (QT4_CREATE_MOC_COMMAND)
1096   
1097   MACRO (QT4_GENERATE_MOC infile outfile )
1098      QT4_GET_MOC_FLAGS(moc_flags)
1099      GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE)
1100      QT4_CREATE_MOC_COMMAND(${abs_infile} ${outfile} "${moc_flags}" "")
1101      SET_SOURCE_FILES_PROPERTIES(${outfile} PROPERTIES SKIP_AUTOMOC TRUE)  # dont run automoc on this file
1102   ENDMACRO (QT4_GENERATE_MOC)
1105   # QT4_WRAP_CPP(outfiles inputfile ... )
1107   MACRO (QT4_WRAP_CPP outfiles )
1108     # get include dirs
1109     QT4_GET_MOC_FLAGS(moc_flags)
1110     QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
1112     FOREACH (it ${moc_files})
1113       GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
1114       QT4_MAKE_OUTPUT_FILE(${it} moc_ cxx outfile)
1115       QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_flags}" "${moc_options}")
1116       SET(${outfiles} ${${outfiles}} ${outfile})
1117     ENDFOREACH(it)
1119   ENDMACRO (QT4_WRAP_CPP)
1122   # QT4_WRAP_UI(outfiles inputfile ... )
1124   MACRO (QT4_WRAP_UI outfiles )
1125     QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
1127     FOREACH (it ${ui_files})
1128       GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
1129       GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
1130       SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
1131       ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1132         COMMAND ${QT_UIC_EXECUTABLE}
1133         ARGS ${ui_options} -o ${outfile} ${infile}
1134         MAIN_DEPENDENCY ${infile})
1135       SET(${outfiles} ${${outfiles}} ${outfile})
1136     ENDFOREACH (it)
1138   ENDMACRO (QT4_WRAP_UI)
1141   # QT4_ADD_RESOURCES(outfiles inputfile ... )
1143   MACRO (QT4_ADD_RESOURCES outfiles )
1144     QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN})
1146     FOREACH (it ${rcc_files})
1147       GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
1148       GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
1149       GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
1150       SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
1151       #  parse file for dependencies 
1152       #  all files are absolute paths or relative to the location of the qrc file
1153       FILE(READ "${infile}" _RC_FILE_CONTENTS)
1154       STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
1155       SET(_RC_DEPENDS)
1156       FOREACH(_RC_FILE ${_RC_FILES})
1157         STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
1158         STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}")
1159         IF(NOT _ABS_PATH_INDICATOR)
1160           SET(_RC_FILE "${rc_path}/${_RC_FILE}")
1161         ENDIF(NOT _ABS_PATH_INDICATOR)
1162         SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
1163       ENDFOREACH(_RC_FILE)
1164       ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1165         COMMAND ${QT_RCC_EXECUTABLE}
1166         ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
1167         MAIN_DEPENDENCY ${infile}
1168         DEPENDS ${_RC_DEPENDS})
1169       SET(${outfiles} ${${outfiles}} ${outfile})
1170     ENDFOREACH (it)
1172   ENDMACRO (QT4_ADD_RESOURCES)
1174   MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename)
1175     GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE)
1176     SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
1177     SET(_impl   ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
1178     SET(_moc    ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
1179   
1180     ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1181         COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -p ${_basename} ${_infile}
1182         DEPENDS ${_infile})
1183   
1184     SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
1185     
1186     QT4_GENERATE_MOC(${_header} ${_moc})
1187   
1188     SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
1189     MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
1190   
1191   ENDMACRO(QT4_ADD_DBUS_INTERFACE)
1192   
1193   
1194   MACRO(QT4_ADD_DBUS_INTERFACES _sources)
1195      FOREACH (_current_FILE ${ARGN})
1196         GET_FILENAME_COMPONENT(_infile ${_current_FILE} ABSOLUTE)
1197         # get the part before the ".xml" suffix
1198         STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2" _basename ${_current_FILE})
1199         STRING(TOLOWER ${_basename} _basename)
1200         QT4_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface)
1201      ENDFOREACH (_current_FILE)
1202   ENDMACRO(QT4_ADD_DBUS_INTERFACES)
1203   
1204   
1205   MACRO(QT4_GENERATE_DBUS_INTERFACE _header) # _customName )
1206     SET(_customName "${ARGV1}")
1207     GET_FILENAME_COMPONENT(_in_file ${_header} ABSOLUTE)
1208     GET_FILENAME_COMPONENT(_basename ${_header} NAME_WE)
1209     
1210     IF (_customName)
1211       SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName})
1212     ELSE (_customName)
1213       SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml)
1214     ENDIF (_customName)
1215   
1216     ADD_CUSTOM_COMMAND(OUTPUT ${_target}
1217         COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_in_file} > ${_target}
1218         DEPENDS ${_in_file}
1219     )
1220   ENDMACRO(QT4_GENERATE_DBUS_INTERFACE)
1221   
1222   
1223   MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename )
1224     GET_FILENAME_COMPONENT(_infile ${_xml_file} ABSOLUTE)
1225     
1226     SET(_optionalBasename "${ARGV4}")
1227     IF (_optionalBasename)
1228        SET(_basename ${_optionalBasename} )
1229     ELSE (_optionalBasename)
1230        STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile})
1231        STRING(TOLOWER ${_basename} _basename)
1232     ENDIF (_optionalBasename)
1234     SET(_optionalClassName "${ARGV5}")
1235     SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
1236     SET(_impl   ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
1237     SET(_moc    ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
1239     IF(_optionalClassName)
1240        ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1241           COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
1242           DEPENDS ${_infile}
1243         )
1244     ELSE(_optionalClassName)
1245        ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1246           COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
1247           DEPENDS ${_infile}
1248         )
1249     ENDIF(_optionalClassName)
1251     QT4_GENERATE_MOC(${_header} ${_moc})
1252     SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
1253     MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
1255     SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
1256   ENDMACRO(QT4_ADD_DBUS_ADAPTOR)
1258    MACRO(QT4_AUTOMOC)
1259       QT4_GET_MOC_FLAGS(_moc_INCS)
1261       SET(_matching_FILES )
1262       FOREACH (_current_FILE ${ARGN})
1264          GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
1265          # if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
1266          # This is required to make uic work correctly:
1267          # we need to add generated .cpp files to the sources (to compile them),
1268          # but we cannot let automoc handle them, as the .cpp files don't exist yet when
1269          # cmake is run for the very first time on them -> however the .cpp files might
1270          # exist at a later run. at that time we need to skip them, so that we don't add two
1271          # different rules for the same moc file
1272          GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC)
1274          IF ( NOT _skip AND EXISTS ${_abs_FILE} )
1276             FILE(READ ${_abs_FILE} _contents)
1278             GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH)
1280             STRING(REGEX MATCHALL "#include +[^ ]+\\.moc[\">]" _match "${_contents}")
1281             IF(_match)
1282                FOREACH (_current_MOC_INC ${_match})
1283                   STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
1284                   GET_FILENAME_COMPONENT(_basename ${_current_MOC} NAME_WE)
1285                   SET(_header ${_abs_PATH}/${_basename}.h)
1286                   SET(_moc    ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
1287                   QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${_moc_INCS}" "")
1288                   MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
1289                ENDFOREACH (_current_MOC_INC)
1290             ENDIF(_match)
1291          ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} )
1292       ENDFOREACH (_current_FILE)
1293    ENDMACRO(QT4_AUTOMOC)
1295    MACRO(QT4_CREATE_TRANSLATION _qm_files)
1296       QT4_EXTRACT_OPTIONS(_lupdate_files _lupdate_options ${ARGN})
1297       SET(_my_sources)
1298       SET(_my_dirs)
1299       SET(_my_tsfiles)
1300       SET(_ts_pro)
1301       FOREACH (_file ${_lupdate_files})
1302          GET_FILENAME_COMPONENT(_ext ${_file} EXT)
1303          GET_FILENAME_COMPONENT(_abs_FILE ${_file} ABSOLUTE)
1304          IF(_ext MATCHES "ts")
1305            LIST(APPEND _my_tsfiles ${_abs_FILE})
1306          ELSE(_ext MATCHES "ts")
1307            IF(NOT _ext)
1308              LIST(APPEND _my_dirs ${_abs_FILE})
1309            ELSE(NOT _ext)
1310              LIST(APPEND _my_sources ${_abs_FILE})
1311            ENDIF(NOT _ext)
1312          ENDIF(_ext MATCHES "ts")
1313       ENDFOREACH(_file)
1314       FOREACH(_ts_file ${_my_tsfiles})
1315         IF(_my_sources)
1316           # make a .pro file to call lupdate on, so we don't make our commands too
1317           # long for some systems
1318           GET_FILENAME_COMPONENT(_ts_name ${_ts_file} NAME_WE)
1319           SET(_ts_pro ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lupdate.pro)
1320           STRING(REPLACE ";" " " _pro_srcs "${_my_sources}")
1321           FILE(WRITE ${_ts_pro} "SOURCES = ${_pro_srcs}")
1322         ENDIF(_my_sources)
1323         ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file}
1324            COMMAND ${QT_LUPDATE_EXECUTABLE}
1325            ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file}
1326            DEPENDS ${_my_sources} ${_ts_pro})
1327       ENDFOREACH(_ts_file)
1328       QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles})
1329    ENDMACRO(QT4_CREATE_TRANSLATION)
1331    MACRO(QT4_ADD_TRANSLATION _qm_files)
1332       FOREACH (_current_FILE ${ARGN})
1333          GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
1334          GET_FILENAME_COMPONENT(qm ${_abs_FILE} NAME_WE)
1335          SET(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm")
1337          ADD_CUSTOM_COMMAND(OUTPUT ${qm}
1338             COMMAND ${QT_LRELEASE_EXECUTABLE}
1339             ARGS ${_abs_FILE} -qm ${qm}
1340             DEPENDS ${_abs_FILE}
1341          )
1342          SET(${_qm_files} ${${_qm_files}} ${qm})
1343       ENDFOREACH (_current_FILE)
1344    ENDMACRO(QT4_ADD_TRANSLATION)
1350   ######################################
1351   #
1352   #       decide if Qt got found
1353   #
1354   ######################################
1356   # if the includes,libraries,moc,uic and rcc are found then we have it
1357   IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND 
1358       QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE AND QT_QTCORE_LIBRARY)
1359     SET( QT4_FOUND "YES" )
1360     INCLUDE(FindPackageMessage)
1361     FIND_PACKAGE_MESSAGE(Qt4 "Found Qt-Version ${QTVERSION}"
1362       "[${QT_LIBRARY_DIR}][${QT_INCLUDE_DIR}][${QT_MOC_EXECUTABLE}][${QT_UIC_EXECUTABLE}][${QT_RCC_EXECUTABLE}]")
1363   ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND
1364         QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE AND QT_QTCORE_LIBRARY)
1365     SET( QT4_FOUND "NO")
1366     SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1367     IF( Qt4_FIND_REQUIRED)
1368       MESSAGE( FATAL_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!")
1369     ENDIF( Qt4_FIND_REQUIRED)
1370   ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND 
1371          QT_UIC_EXECUTABLE AND  QT_RCC_EXECUTABLE AND QT_QTCORE_LIBRARY)
1372   
1373   SET(QT_FOUND ${QT4_FOUND})
1376   #######################################
1377   #
1378   #       Qt configuration
1379   #
1380   #######################################
1381   IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
1382     FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents)
1383     STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG "${_qconfig_FILE_contents}")
1384     STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG "${_qconfig_FILE_contents}")
1385     STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION "${_qconfig_FILE_contents}")
1386   ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
1387   IF("${QT_EDITION}" MATCHES "DesktopLight")
1388     SET(QT_EDITION_DESKTOPLIGHT 1)
1389   ENDIF("${QT_EDITION}" MATCHES "DesktopLight")
1391   
1392   ###############################################
1393   #
1394   #       configuration/system dependent settings  
1395   #
1396   ###############################################
1397   
1398   # find dependencies for some Qt modules
1399   # when doing builds against a static Qt, they are required
1400   # when doing builds against a shared Qt, they are sometimes not required
1401   # even some Linux distros do not require these dependencies
1402   # if a user needs the dependencies, and they couldn't be found, they can set
1403   # the variables themselves.
1405   SET(QT_QTGUI_LIB_DEPENDENCIES "")
1406   SET(QT_QTCORE_LIB_DEPENDENCIES "")
1407   SET(QT_QTNETWORK_LIB_DEPENDENCIES "")
1408   SET(QT_QTOPENGL_LIB_DEPENDENCIES "")
1409   SET(QT_QTDBUS_LIB_DEPENDENCIES "")
1410   SET(QT_QTHELP_LIB_DEPENDENCIES ${QT_QTCLUCENE_LIBRARY})
1411   
1412   # build using shared Qt needs -DQT_DLL
1413   IF(NOT QT_CONFIG MATCHES "static")
1414     # warning currently only qconfig.pri on Windows potentially contains "static"
1415     # so QT_DLL might not get defined properly on other platforms.
1416     SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_DLL)
1417   ENDIF(NOT QT_CONFIG MATCHES "static")
1418   
1419   # QtOpenGL dependencies
1420   QT_QUERY_QMAKE(QMAKE_LIBS_OPENGL "QMAKE_LIBS_OPENGL")
1421   SET (QT_QTOPENGL_LIB_DEPENDENCIES ${QT_QTOPENGL_LIB_DEPENDENCIES} ${QMAKE_LIBS_OPENGL})
1422   
1423   ## system png
1424   IF(QT_QCONFIG MATCHES "system-png")
1425     FIND_LIBRARY(QT_PNG_LIBRARY NAMES png)
1426     MARK_AS_ADVANCED(QT_PNG_LIBRARY)
1427     IF(QT_PNG_LIBRARY)
1428       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY})
1429     ENDIF(QT_PNG_LIBRARY)
1430   ENDIF(QT_QCONFIG MATCHES "system-png")
1431   
1432   # for X11, get X11 library directory
1433   IF(Q_WS_X11)
1434     QT_QUERY_QMAKE(QMAKE_LIBDIR_X11 "QMAKE_LIBDIR_X11")
1435   ENDIF(Q_WS_X11)
1437   ## X11 SM
1438   IF(QT_QCONFIG MATCHES "x11sm")
1439     # ask qmake where the x11 libs are
1440     FIND_LIBRARY(QT_X11_SM_LIBRARY NAMES SM PATHS ${QMAKE_LIBDIR_X11})
1441     FIND_LIBRARY(QT_X11_ICE_LIBRARY NAMES ICE PATHS ${QMAKE_LIBDIR_X11})
1442     MARK_AS_ADVANCED(QT_X11_SM_LIBRARY)
1443     MARK_AS_ADVANCED(QT_X11_ICE_LIBRARY)
1444     IF(QT_X11_SM_LIBRARY AND QT_X11_ICE_LIBRARY)
1445       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_X11_SM_LIBRARY} ${QT_X11_ICE_LIBRARY})
1446     ENDIF(QT_X11_SM_LIBRARY AND QT_X11_ICE_LIBRARY)
1447   ENDIF(QT_QCONFIG MATCHES "x11sm")
1448   
1449   ## Xi
1450   IF(QT_QCONFIG MATCHES "tablet")
1451     FIND_LIBRARY(QT_XI_LIBRARY NAMES Xi PATHS ${QMAKE_LIBDIR_X11})
1452     MARK_AS_ADVANCED(QT_XI_LIBRARY)
1453     IF(QT_XI_LIBRARY)
1454       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XI_LIBRARY})
1455     ENDIF(QT_XI_LIBRARY)
1456   ENDIF(QT_QCONFIG MATCHES "tablet")
1458   ## Xrender
1459   IF(QT_QCONFIG MATCHES "xrender")
1460     FIND_LIBRARY(QT_XRENDER_LIBRARY NAMES Xrender PATHS ${QMAKE_LIBDIR_X11})
1461     MARK_AS_ADVANCED(QT_XRENDER_LIBRARY)
1462     IF(QT_XRENDER_LIBRARY)
1463       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRENDER_LIBRARY})
1464     ENDIF(QT_XRENDER_LIBRARY)
1465   ENDIF(QT_QCONFIG MATCHES "xrender")
1466   
1467   ## Xrandr
1468   IF(QT_QCONFIG MATCHES "xrandr")
1469     FIND_LIBRARY(QT_XRANDR_LIBRARY NAMES Xrandr PATHS ${QMAKE_LIBDIR_X11})
1470     MARK_AS_ADVANCED(QT_XRANDR_LIBRARY)
1471     IF(QT_XRANDR_LIBRARY)
1472       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRANDR_LIBRARY})
1473     ENDIF(QT_XRANDR_LIBRARY)
1474   ENDIF(QT_QCONFIG MATCHES "xrandr")
1475   
1476   ## Xcursor
1477   IF(QT_QCONFIG MATCHES "xcursor")
1478     FIND_LIBRARY(QT_XCURSOR_LIBRARY NAMES Xcursor PATHS ${QMAKE_LIBDIR_X11})
1479     MARK_AS_ADVANCED(QT_XCURSOR_LIBRARY)
1480     IF(QT_XCURSOR_LIBRARY)
1481       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XCURSOR_LIBRARY})
1482     ENDIF(QT_XCURSOR_LIBRARY)
1483   ENDIF(QT_QCONFIG MATCHES "xcursor")
1484   
1485   ## Xinerama
1486   IF(QT_QCONFIG MATCHES "xinerama")
1487     FIND_LIBRARY(QT_XINERAMA_LIBRARY NAMES Xinerama PATHS ${QMAKE_LIBDIR_X11})
1488     MARK_AS_ADVANCED(QT_XINERAMA_LIBRARY)
1489     IF(QT_XINERAMA_LIBRARY)
1490       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XINERAMA_LIBRARY})
1491     ENDIF(QT_XINERAMA_LIBRARY)
1492   ENDIF(QT_QCONFIG MATCHES "xinerama")
1493   
1494   ## Xfixes
1495   IF(QT_QCONFIG MATCHES "xfixes")
1496     FIND_LIBRARY(QT_XFIXES_LIBRARY NAMES Xfixes PATHS ${QMAKE_LIBDIR_X11})
1497     MARK_AS_ADVANCED(QT_XFIXES_LIBRARY)
1498     IF(QT_XFIXES_LIBRARY)
1499       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XFIXES_LIBRARY})
1500     ENDIF(QT_XFIXES_LIBRARY)
1501   ENDIF(QT_QCONFIG MATCHES "xfixes")
1502   
1503   ## system-freetype
1504   IF(QT_QCONFIG MATCHES "system-freetype")
1505     FIND_LIBRARY(QT_FREETYPE_LIBRARY NAMES freetype)
1506     MARK_AS_ADVANCED(QT_FREETYPE_LIBRARY)
1507     IF(QT_FREETYPE_LIBRARY)
1508       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY})
1509     ENDIF(QT_FREETYPE_LIBRARY)
1510   ENDIF(QT_QCONFIG MATCHES "system-freetype")
1511   
1512   ## fontconfig
1513   IF(QT_QCONFIG MATCHES "fontconfig")
1514     FIND_LIBRARY(QT_FONTCONFIG_LIBRARY NAMES fontconfig)
1515     MARK_AS_ADVANCED(QT_FONTCONFIG_LIBRARY)
1516     IF(QT_FONTCONFIG_LIBRARY)
1517       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY})
1518     ENDIF(QT_FONTCONFIG_LIBRARY)
1519   ENDIF(QT_QCONFIG MATCHES "fontconfig")
1520   
1521   ## system-zlib
1522   IF(QT_QCONFIG MATCHES "system-zlib")
1523     FIND_LIBRARY(QT_ZLIB_LIBRARY NAMES z)
1524     MARK_AS_ADVANCED(QT_ZLIB_LIBRARY)
1525     IF(QT_ZLIB_LIBRARY)
1526       SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY})
1527     ENDIF(QT_ZLIB_LIBRARY)
1528   ENDIF(QT_QCONFIG MATCHES "system-zlib")
1530   ## openssl
1531   IF(QT_QCONFIG MATCHES "openssl" AND NOT Q_WS_WIN)
1532     FIND_PACKAGE(OpenSSL)
1533     IF(OPENSSL_LIBRARIES)
1534       SET(QT_QTNETWORK_LIB_DEPENDENCIES ${QT_QTNETWORK_LIB_DEPENDENCIES} ${OPENSSL_LIBRARIES})
1535     ENDIF(OPENSSL_LIBRARIES)
1536   ENDIF(QT_QCONFIG MATCHES "openssl" AND NOT Q_WS_WIN)
1537   
1538   ## dbus
1539   IF(QT_QCONFIG MATCHES "dbus")
1541     # if the dbus library isn't found, we'll assume its not required to build
1542     # shared Qt on Linux doesn't require it
1543     IF(NOT QT_DBUS_LIBRARY)
1544       EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L dbus-1
1545         OUTPUT_VARIABLE _dbus_query_output
1546         RESULT_VARIABLE _dbus_result
1547         ERROR_VARIABLE _dbus_query_output )
1548       
1549       IF(_dbus_result MATCHES 0)
1550         STRING(REPLACE "-L" "" _dbus_query_output "${_dbus_query_output}")
1551         SEPARATE_ARGUMENTS(_dbus_query_output)
1552       ELSE(_dbus_result MATCHES 0)
1553         SET(_dbus_query_output)
1554       ENDIF(_dbus_result MATCHES 0)
1556       FIND_LIBRARY(QT_DBUS_LIBRARY NAMES dbus-1 PATHS ${_dbus_query_output} )
1558       IF(QT_DBUS_LIBRARY)
1559         SET(QT_QTDBUS_LIB_DEPENDENCIES ${QT_QTDBUS_LIB_DEPENDENCIES} ${QT_DBUS_LIBRARY})
1560       ENDIF(QT_DBUS_LIBRARY)
1562       MARK_AS_ADVANCED(QT_DBUS_LIBRARY)
1563     ENDIF(NOT QT_DBUS_LIBRARY)
1565   ENDIF(QT_QCONFIG MATCHES "dbus")
1566   
1567   ## glib
1568   IF(QT_QCONFIG MATCHES "glib")
1569     
1570     # if the glib libraries aren't found, we'll assume its not required to build
1571     # shared Qt on Linux doesn't require it
1573     # Qt 4.2.0+ uses glib-2.0
1574     IF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY)
1575       EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L glib-2.0 gthread-2.0
1576         OUTPUT_VARIABLE _glib_query_output
1577         RESULT_VARIABLE _glib_result
1578         ERROR_VARIABLE _glib_query_output )
1580       IF(_glib_result MATCHES 0)
1581         STRING(REPLACE "-L" "" _glib_query_output "${_glib_query_output}")
1582         SEPARATE_ARGUMENTS(_glib_query_output)
1583       ELSE(_glib_result MATCHES 0)
1584         SET(_glib_query_output)
1585       ENDIF(_glib_result MATCHES 0)
1587       FIND_LIBRARY(QT_GLIB_LIBRARY NAMES glib-2.0 PATHS ${_glib_query_output} )
1588       FIND_LIBRARY(QT_GTHREAD_LIBRARY NAMES gthread-2.0 PATHS ${_glib_query_output} )
1589     
1590       MARK_AS_ADVANCED(QT_GLIB_LIBRARY)
1591       MARK_AS_ADVANCED(QT_GTHREAD_LIBRARY)
1592     ENDIF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY)
1594     IF(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY)
1595       SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES}
1596           ${QT_GTHREAD_LIBRARY} ${QT_GLIB_LIBRARY})
1597     ENDIF(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY)
1599   ENDIF(QT_QCONFIG MATCHES "glib")
1600   
1601   ## clock-monotonic, just see if we need to link with rt
1602   IF(QT_QCONFIG MATCHES "clock-monotonic")
1603     SET(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
1604     SET(CMAKE_REQUIRED_LIBRARIES rt)
1605     CHECK_SYMBOL_EXISTS(_POSIX_TIMERS "unistd.h;time.h" QT_POSIX_TIMERS)
1606     SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
1607     IF(QT_POSIX_TIMERS)
1608       FIND_LIBRARY(QT_RT_LIBRARY NAMES rt)
1609       MARK_AS_ADVANCED(QT_RT_LIBRARY)
1610       IF(QT_RT_LIBRARY)
1611         SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_RT_LIBRARY})
1612       ENDIF(QT_RT_LIBRARY)
1613     ENDIF(QT_POSIX_TIMERS)
1614   ENDIF(QT_QCONFIG MATCHES "clock-monotonic")
1615     
1616   IF(Q_WS_X11)
1617     # X11 libraries Qt absolutely depends on
1618     QT_QUERY_QMAKE(QT_LIBS_X11 "QMAKE_LIBS_X11")
1619     SEPARATE_ARGUMENTS(QT_LIBS_X11)
1620     FOREACH(QT_X11_LIB ${QT_LIBS_X11})
1621       STRING(REGEX REPLACE "-l" "" QT_X11_LIB "${QT_X11_LIB}")
1622       SET(QT_TMP_STR "QT_X11_${QT_X11_LIB}_LIBRARY")
1623       FIND_LIBRARY(${QT_TMP_STR} NAMES "${QT_X11_LIB}" PATHS ${QMAKE_LIBDIR_X11})
1624       MARK_AS_ADVANCED(${QT_TMP_STR})
1625       IF(${QT_TMP_STR})
1626         SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${${QT_TMP_STR}})
1627       ENDIF(${QT_TMP_STR})
1628     ENDFOREACH(QT_X11_LIB)
1630     QT_QUERY_QMAKE(QT_LIBS_THREAD "QMAKE_LIBS_THREAD")
1631     SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_LIBS_THREAD})
1632     
1633     QT_QUERY_QMAKE(QMAKE_LIBS_DYNLOAD "QMAKE_LIBS_DYNLOAD")
1634     SET (QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QMAKE_LIBS_DYNLOAD})
1636   ENDIF(Q_WS_X11)
1637   
1638   IF(Q_WS_WIN)
1639     SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} imm32 winmm)
1640     SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ws2_32)
1641   ENDIF(Q_WS_WIN)
1642   
1643   IF(Q_WS_MAC)
1644     SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework Carbon")
1645     
1646     # Qt 4.0, 4.1, 4.2 use QuickTime
1647     IF(QT_VERSION_MINOR LESS 3)
1648       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework QuickTime")
1649     ENDIF(QT_VERSION_MINOR LESS 3)
1650     
1651     # Qt 4.2+ use AppKit
1652     IF(QT_VERSION_MINOR GREATER 1)
1653       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework AppKit")
1654     ENDIF(QT_VERSION_MINOR GREATER 1)
1656     SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} "-framework ApplicationServices")
1657   ENDIF(Q_WS_MAC)
1659   #######################################
1660   #
1661   #       compatibility settings 
1662   #
1663   #######################################
1664   # Backwards compatibility for CMake1.4 and 1.2
1665   SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} )
1666   SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} )
1668   SET( QT_QT_LIBRARY "")
1670 ELSE(QT4_QMAKE_FOUND)
1671    
1672    SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1673    IF(Qt4_FIND_REQUIRED)
1674       IF(QT4_INSTALLED_VERSION_TOO_OLD)
1675          MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1676       ELSE(QT4_INSTALLED_VERSION_TOO_OLD)
1677          MESSAGE( FATAL_ERROR "Qt qmake not found!")
1678       ENDIF(QT4_INSTALLED_VERSION_TOO_OLD)
1679    ELSE(Qt4_FIND_REQUIRED)
1680       IF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1681          MESSAGE(STATUS "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1682       ENDIF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1683    ENDIF(Qt4_FIND_REQUIRED)
1685 ENDIF (QT4_QMAKE_FOUND)