Fix vertical alignment and remove debug painting
[quassel.git] / cmake / 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 # 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
32 #
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.
37 #
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})
44 #
45 #
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.  Options may be given to moc, such as those found
52 #        when executing "moc -help"
53 #
54 #  macro QT4_WRAP_UI(outfiles inputfile ... OPTIONS ...)
55 #        create code from a list of Qt designer ui files.
56 #        Options may be given to uic, such as those found
57 #        when executing "uic -help"
58 #
59 #  macro QT4_ADD_RESOURCES(outfiles inputfile ... OPTIONS ...)
60 #        create code from a list of Qt resource files.
61 #        Options may be given to rcc, such as those found
62 #        when executing "rcc -help"
63 #
64 #  macro QT4_GENERATE_MOC(inputfile outputfile )
65 #        creates a rule to run moc on infile and create outfile.
66 #        Use this if for some reason QT4_WRAP_CPP() isn't appropriate, e.g.
67 #        because you need a custom filename for the moc file or something similar.
68 #
69 #  macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... )
70 #        This macro is still experimental.
71 #        It can be used to have moc automatically handled.
72 #        So if you have the files foo.h and foo.cpp, and in foo.h a 
73 #        a class uses the Q_OBJECT macro, moc has to run on it. If you don't
74 #        want to use QT4_WRAP_CPP() (which is reliable and mature), you can insert
75 #        #include "foo.moc"
76 #        in foo.cpp and then give foo.cpp as argument to QT4_AUTOMOC(). This will the
77 #        scan all listed files at cmake-time for such included moc files and if it finds
78 #        them cause a rule to be generated to run moc at build time on the 
79 #        accompanying header file foo.h.
80 #        If a source file has the SKIP_AUTOMOC property set it will be ignored by this macro.
81 #
82 #  macro QT4_ADD_DBUS_INTERFACE(outfiles interface basename)
83 #        create a the interface header and implementation files with the 
84 #        given basename from the given interface xml file and add it to 
85 #        the list of sources.
86 #        To disable generating a namespace header, set the source file property 
87 #        NO_NAMESPACE to TRUE on the interface file.
88 #
89 #  macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... )
90 #        create the interface header and implementation files 
91 #        for all listed interface xml files
92 #        the name will be automatically determined from the name of the xml file
93 #        To disable generating namespace headers, set the source file property 
94 #        NO_NAMESPACE to TRUE for these inputfiles.
95 #
96 #  macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname [basename] [classname])
97 #        create a dbus adaptor (header and implementation file) from the xml file
98 #        describing the interface, and add it to the list of sources. The adaptor
99 #        forwards the calls to a parent class, defined in parentheader and named
100 #        parentclassname. The name of the generated files will be
101 #        <basename>adaptor.{cpp,h} where basename defaults to the basename of the xml file.
102 #        If <classname> is provided, then it will be used as the classname of the
103 #        adaptor itself.
104 #
105 #  macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] OPTIONS ...)
106 #        generate the xml interface file from the given header.
107 #        If the optional argument interfacename is omitted, the name of the 
108 #        interface file is constructed from the basename of the header with
109 #        the suffix .xml appended.
110 #        Options may be given to qdbuscpp2xml, such as those found when executing "qdbuscpp2xml --help"
111 #
112 #  QT_FOUND         If false, don't try to use Qt.
113 #  QT4_FOUND        If false, don't try to use Qt 4.
114 #
115 #  QT_QTCORE_FOUND        True if QtCore was found.
116 #  QT_QTGUI_FOUND         True if QtGui was found.
117 #  QT_QT3SUPPORT_FOUND    True if Qt3Support was found.
118 #  QT_QTASSISTANT_FOUND   True if QtAssistant was found.
119 #  QT_QTDBUS_FOUND        True if QtDBus was found.
120 #  QT_QTDESIGNER_FOUND    True if QtDesigner was found.
121 #  QT_QTDESIGNERCOMPONENTS True if QtDesignerComponents was found.
122 #  QT_QTMOTIF_FOUND       True if QtMotif was found.
123 #  QT_QTNETWORK_FOUND     True if QtNetwork was found.
124 #  QT_QTNSPLUGIN_FOUND    True if QtNsPlugin was found.
125 #  QT_QTOPENGL_FOUND      True if QtOpenGL was found.
126 #  QT_QTSQL_FOUND         True if QtSql was found.
127 #  QT_QTXML_FOUND         True if QtXml was found.
128 #  QT_QTSVG_FOUND         True if QtSvg was found.
129 #  QT_QTSCRIPT_FOUND      True if QtScript was found.
130 #  QT_QTTEST_FOUND        True if QtTest was found.
131 #  QT_QTUITOOLS_FOUND     True if QtUiTools was found.
132 #  QT_QTASSISTANTCLIENT_FOUND         True if QtAssistantClient was found.
133 #  QT_QTHELP_FOUND      True if QtHelp was found.
134 #  QT_QTWEBKIT_FOUND        True if QtWebKit was found.
135 #  QT_QTXMLPATTERNS_FOUND   True if QtXmlPatterns was found.
136 #  QT_PHONON_FOUND          True if phonon was found.
137 #
138 #
139 #  QT_DEFINITIONS   Definitions to use when compiling code that uses Qt.
140 #                   You do not need to use this if you include QT_USE_FILE.
141 #                   The QT_USE_FILE will also define QT_DEBUG and QT_NO_DEBUG
142 #                   to fit your current build type.  Those are not contained
143 #                   in QT_DEFINITIONS.
144 #                  
145 #  QT_INCLUDES      List of paths to all include directories of 
146 #                   Qt4 QT_INCLUDE_DIR and QT_QTCORE_INCLUDE_DIR are
147 #                   always in this variable even if NOTFOUND,
148 #                   all other INCLUDE_DIRS are
149 #                   only added if they are found.
150 #                   You do not need to use this if you include QT_USE_FILE.
151 #   
152 #
153 #  Include directories for the Qt modules are listed here.
154 #  You do not need to use these variables if you include QT_USE_FILE.
155 #
156 #  QT_INCLUDE_DIR              Path to "include" of Qt4
157 #  QT_QT_INCLUDE_DIR           Path to "include/Qt" 
158 #  QT_QT3SUPPORT_INCLUDE_DIR   Path to "include/Qt3Support" 
159 #  QT_QTASSISTANT_INCLUDE_DIR  Path to "include/QtAssistant" 
160 #  QT_QTCORE_INCLUDE_DIR       Path to "include/QtCore"         
161 #  QT_QTDESIGNER_INCLUDE_DIR   Path to "include/QtDesigner" 
162 #  QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR   Path to "include/QtDesigner"
163 #  QT_QTDBUS_INCLUDE_DIR       Path to "include/QtDBus" 
164 #  QT_QTGUI_INCLUDE_DIR        Path to "include/QtGui" 
165 #  QT_QTMOTIF_INCLUDE_DIR      Path to "include/QtMotif" 
166 #  QT_QTNETWORK_INCLUDE_DIR    Path to "include/QtNetwork" 
167 #  QT_QTNSPLUGIN_INCLUDE_DIR   Path to "include/QtNsPlugin" 
168 #  QT_QTOPENGL_INCLUDE_DIR     Path to "include/QtOpenGL" 
169 #  QT_QTSQL_INCLUDE_DIR        Path to "include/QtSql" 
170 #  QT_QTXML_INCLUDE_DIR        Path to "include/QtXml" 
171 #  QT_QTSVG_INCLUDE_DIR        Path to "include/QtSvg"
172 #  QT_QTSCRIPT_INCLUDE_DIR     Path to "include/QtScript"
173 #  QT_QTTEST_INCLUDE_DIR       Path to "include/QtTest"
174 #  QT_QTASSISTANTCLIENT_INCLUDE_DIR       Path to "include/QtAssistant"
175 #  QT_QTHELP_INCLUDE_DIR       Path to "include/QtHelp"
176 #  QT_QTWEBKIT_INCLUDE_DIR     Path to "include/QtWebKit"
177 #  QT_QTXMLPATTERNS_INCLUDE_DIR  Path to "include/QtXmlPatterns"
178 #  QT_PHONON_INCLUDE_DIR       Path to "include/phonon"
179 #                            
180 #  QT_LIBRARY_DIR              Path to "lib" of Qt4
181
182 #  QT_PLUGINS_DIR              Path to "plugins" for Qt4
183 #                            
184 # For every library of Qt, a QT_QTFOO_LIBRARY variable is defined, with the full path to the library.
185 #
186 # So there are the following variables:
187 # The Qt3Support library:     QT_QT3SUPPORT_LIBRARY
188 #
189 # The QtAssistant library:    QT_QTASSISTANT_LIBRARY
190 #
191 # The QtCore library:         QT_QTCORE_LIBRARY
192 #
193 # The QtDBus library:         QT_QTDBUS_LIBRARY
194 #
195 # The QtDesigner library:     QT_QTDESIGNER_LIBRARY
196 #
197 # The QtDesignerComponents library:     QT_QTDESIGNERCOMPONENTS_LIBRARY
198 #
199 # The QtGui library:          QT_QTGUI_LIBRARY
200 #
201 # The QtMotif library:        QT_QTMOTIF_LIBRARY
202 #
203 # The QtNetwork library:      QT_QTNETWORK_LIBRARY
204 #
205 # The QtNsPLugin library:     QT_QTNSPLUGIN_LIBRARY
206 #
207 # The QtOpenGL library:       QT_QTOPENGL_LIBRARY
208 #
209 # The QtSql library:          QT_QTSQL_LIBRARY
210 #
211 # The QtXml library:          QT_QTXML_LIBRARY
212 #
213 # The QtSvg library:          QT_QTSVG_LIBRARY
214 #
215 # The QtScript library:       QT_QTSCRIPT_LIBRARY
216 #
217 # The QtTest library:         QT_QTTEST_LIBRARY
218 #
219 # The qtmain library for Windows QT_QTMAIN_LIBRARY
220 #
221 # The QtUiTools library:      QT_QTUITOOLS_LIBRARY
222
223 #
224 # The QtAssistantClient library:  QT_QTASSISTANTCLIENT_LIBRARY
225 #
226 # The QtHelp library:             QT_QTHELP_LIBRARY
227 #
228 # The QtWebKit library:           QT_QTWEBKIT_LIBRARY
229 #
230 # The QtXmlPatterns library:      QT_QTXMLPATTERNS_LIBRARY
231 #
232 # The Phonon library:             QT_PHONON_LIBRARY
233
234
235
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
249 #
250 #
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
262
263 # Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
264 # See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
265
266 if (QT4_QMAKE_FOUND)
267    # Check already done in this cmake run, nothing more to do
268
269 else (QT4_QMAKE_FOUND)
270
271 # check that QT_NO_DEBUG is defined for release configurations
272 MACRO(QT_CHECK_FLAG_EXISTS FLAG VAR DOC)
273   IF(NOT ${VAR} MATCHES "${FLAG}")
274     SET(${VAR} "${${VAR}} ${FLAG}" 
275       CACHE STRING "Flags used by the compiler during ${DOC} builds." FORCE)
276   ENDIF(NOT ${VAR} MATCHES "${FLAG}")
277 ENDMACRO(QT_CHECK_FLAG_EXISTS FLAG VAR)
278 QT_CHECK_FLAG_EXISTS(-DQT_NO_DEBUG CMAKE_CXX_FLAGS_RELWITHDEBINFO "Release with Debug Info")
279 QT_CHECK_FLAG_EXISTS(-DQT_NO_DEBUG CMAKE_CXX_FLAGS_RELEASE "release")
280 QT_CHECK_FLAG_EXISTS(-DQT_NO_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL "release minsize")
281
282 INCLUDE(CheckSymbolExists)
283 INCLUDE(MacroAddFileDependencies)
284 INCLUDE(MacroPushRequiredVars)
285
286 SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake)
287
288 SET( QT_DEFINITIONS "")
289
290 IF (WIN32 AND NOT STATIC)
291   SET(QT_DEFINITIONS -DQT_DLL)
292 ENDIF(WIN32 AND NOT STATIC)
293
294 SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE)
295
296 #  macro for asking qmake to process pro files
297 MACRO(QT_QUERY_QMAKE outvar invar)
298   FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake/tmp.pro
299     "message(CMAKE_MESSAGE<$$${invar}>)")
300
301   # Invoke qmake with the tmp.pro program to get the desired
302   # information.  Use the same variable for both stdout and stderr
303   # to make sure we get the output on all platforms.
304   EXECUTE_PROCESS(COMMAND ${QT_QMAKE_EXECUTABLE}
305     WORKING_DIRECTORY  
306     ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake
307     OUTPUT_VARIABLE _qmake_query_output
308     RESULT_VARIABLE _qmake_result
309     ERROR_VARIABLE _qmake_query_output )
310   
311   FILE(REMOVE_RECURSE 
312     "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake")
313
314   IF(_qmake_result)
315     MESSAGE(WARNING " querying qmake for ${invar}.  qmake reported:\n${_qmake_query_output}")
316   ELSE(_qmake_result)
317     STRING(REGEX REPLACE ".*CMAKE_MESSAGE<([^>]*).*" "\\1" ${outvar} "${_qmake_query_output}")
318   ENDIF(_qmake_result)
319
320 ENDMACRO(QT_QUERY_QMAKE)
321
322 GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME)
323 # check for qmake
324 FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 PATHS
325   "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
326   "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
327   "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]/bin"
328   $ENV{QTDIR}/bin
329 )
330
331 IF (QT_QMAKE_EXECUTABLE)
332
333   SET(QT4_QMAKE_FOUND FALSE)
334   
335   EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
336
337   # check for qt3 qmake and then try and find qmake4 or qmake-qt4 in the path
338   IF("${QTVERSION}" MATCHES "Unknown")
339     SET(QT_QMAKE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE)
340     FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 PATHS
341       "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
342       "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
343       $ENV{QTDIR}/bin
344       )
345     IF(QT_QMAKE_EXECUTABLE)
346       EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} 
347         ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
348     ENDIF(QT_QMAKE_EXECUTABLE)
349   ENDIF("${QTVERSION}" MATCHES "Unknown")
350
351   # check that we found the Qt4 qmake, Qt3 qmake output won't match here
352   STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" qt_version_tmp "${QTVERSION}")
353   IF (qt_version_tmp)
354
355     # we need at least version 4.0.0
356     IF (NOT QT_MIN_VERSION)
357       SET(QT_MIN_VERSION "4.0.0")
358     ENDIF (NOT QT_MIN_VERSION)
359
360     #now parse the parts of the user given version string into variables
361     STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" req_qt_major_vers "${QT_MIN_VERSION}")
362     IF (NOT req_qt_major_vers)
363       MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"4.0.1\"")
364     ENDIF (NOT req_qt_major_vers)
365
366     # now parse the parts of the user given version string into variables
367     STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}")
368     STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers "${QT_MIN_VERSION}")
369     STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}")
370
371     IF (NOT req_qt_major_vers EQUAL 4)
372       MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", major version 4 is required, e.g. \"4.0.1\"")
373     ENDIF (NOT req_qt_major_vers EQUAL 4)
374
375     # and now the version string given by qmake
376     STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" found_qt_major_vers "${QTVERSION}")
377     STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" found_qt_minor_vers "${QTVERSION}")
378     STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" found_qt_patch_vers "${QTVERSION}")
379
380     # compute an overall version number which can be compared at once
381     MATH(EXPR req_vers "${req_qt_major_vers}*10000 + ${req_qt_minor_vers}*100 + ${req_qt_patch_vers}")
382     MATH(EXPR found_vers "${found_qt_major_vers}*10000 + ${found_qt_minor_vers}*100 + ${found_qt_patch_vers}")
383
384     IF (found_vers LESS req_vers)
385       SET(QT4_QMAKE_FOUND FALSE)
386       SET(QT4_INSTALLED_VERSION_TOO_OLD TRUE)
387     ELSE (found_vers LESS req_vers)
388       SET(QT4_QMAKE_FOUND TRUE)
389     ENDIF (found_vers LESS req_vers)
390   ENDIF (qt_version_tmp)
391
392 ENDIF (QT_QMAKE_EXECUTABLE)
393
394 IF (QT4_QMAKE_FOUND)
395
396   if (WIN32)
397     # get qt install dir 
398     get_filename_component(_DIR ${QT_QMAKE_EXECUTABLE} PATH )
399     get_filename_component(QT_INSTALL_DIR ${_DIR} PATH )
400   endif (WIN32)
401
402   # ask qmake for the library dir
403   # Set QT_LIBRARY_DIR
404   IF (NOT QT_LIBRARY_DIR)
405     EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
406       ARGS "-query QT_INSTALL_LIBS"
407       OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP )
408     # make sure we have / and not \ as qmake gives on windows
409     FILE(TO_CMAKE_PATH "${QT_LIBRARY_DIR_TMP}" QT_LIBRARY_DIR_TMP)
410     IF(EXISTS "${QT_LIBRARY_DIR_TMP}")
411       SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir")
412     ELSE(EXISTS "${QT_LIBRARY_DIR_TMP}")
413       MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}")
414       MESSAGE("Warning: ${QT_LIBRARY_DIR_TMP} does NOT exist, Qt must NOT be installed correctly.")
415     ENDIF(EXISTS "${QT_LIBRARY_DIR_TMP}")
416   ENDIF(NOT QT_LIBRARY_DIR)
417   
418   IF (APPLE)
419     IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
420       SET(QT_USE_FRAMEWORKS ON
421         CACHE BOOL "Set to ON if Qt build uses frameworks.")
422     ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
423       SET(QT_USE_FRAMEWORKS OFF
424         CACHE BOOL "Set to ON if Qt build uses frameworks.")
425     ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
426     
427     MARK_AS_ADVANCED(QT_USE_FRAMEWORKS)
428   ENDIF (APPLE)
429   
430   # ask qmake for the binary dir
431   IF (QT_LIBRARY_DIR AND NOT QT_BINARY_DIR)
432      EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE}
433        ARGS "-query QT_INSTALL_BINS"
434        OUTPUT_VARIABLE qt_bins )
435      # make sure we have / and not \ as qmake gives on windows
436      FILE(TO_CMAKE_PATH "${qt_bins}" qt_bins)
437      SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "")
438   ENDIF (QT_LIBRARY_DIR AND NOT QT_BINARY_DIR)
439
440   # ask qmake for the include dir
441   IF (QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR)
442       EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
443         ARGS "-query QT_INSTALL_HEADERS" 
444         OUTPUT_VARIABLE qt_headers ) 
445       # make sure we have / and not \ as qmake gives on windows
446       FILE(TO_CMAKE_PATH "${qt_headers}" qt_headers)
447       SET(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "")
448   ENDIF(QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR)
449
450
451   # ask qmake for the documentation directory
452   IF (QT_LIBRARY_DIR AND NOT QT_DOC_DIR)
453     EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
454       ARGS "-query QT_INSTALL_DOCS"
455       OUTPUT_VARIABLE qt_doc_dir )
456     # make sure we have / and not \ as qmake gives on windows
457     FILE(TO_CMAKE_PATH "${qt_doc_dir}" qt_doc_dir)
458     SET(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs")
459   ENDIF (QT_LIBRARY_DIR AND NOT QT_DOC_DIR)
460
461   # ask qmake for the mkspecs directory
462   IF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR)
463     EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
464       ARGS "-query QMAKE_MKSPECS"
465       OUTPUT_VARIABLE qt_mkspecs_dirs )
466     # do not replace : on windows as it might be a drive letter
467     # and windows should already use ; as a separator
468     IF(UNIX)
469       STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}")
470     ENDIF(UNIX)
471     FIND_PATH(QT_MKSPECS_DIR qconfig.pri PATHS ${qt_mkspecs_dirs}
472       DOC "The location of the Qt mkspecs containing qconfig.pri"
473       NO_DEFAULT_PATH )
474   ENDIF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR)
475
476   # ask qmake for the plugins directory
477   IF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR)
478     EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
479       ARGS "-query QT_INSTALL_PLUGINS"
480       OUTPUT_VARIABLE qt_plugins_dir )
481     # make sure we have / and not \ as qmake gives on windows
482     FILE(TO_CMAKE_PATH "${qt_plugins_dir}" qt_plugins_dir)
483     SET(QT_PLUGINS_DIR ${qt_plugins_dir} CACHE PATH "The location of the Qt plugins")
484   ENDIF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR)
485   ########################################
486   #
487   #       Setting the INCLUDE-Variables
488   #
489   ########################################
490
491   FIND_PATH(QT_QTCORE_INCLUDE_DIR QtGlobal
492     ${QT_HEADERS_DIR}/QtCore
493     ${QT_LIBRARY_DIR}/QtCore.framework/Headers
494     NO_DEFAULT_PATH
495     )
496
497   # Set QT_INCLUDE_DIR by removine "/QtCore" in the string ${QT_QTCORE_INCLUDE_DIR}
498   IF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
499     IF (QT_USE_FRAMEWORKS)
500       SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR})
501     ELSE (QT_USE_FRAMEWORKS)
502       STRING( REGEX REPLACE "/QtCore$" "" qt4_include_dir ${QT_QTCORE_INCLUDE_DIR})
503       SET( QT_INCLUDE_DIR ${qt4_include_dir} CACHE PATH "")
504     ENDIF (QT_USE_FRAMEWORKS)
505   ENDIF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
506
507   IF( NOT QT_INCLUDE_DIR)
508     IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
509       MESSAGE( FATAL_ERROR "Could NOT find QtGlobal header")
510     ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
511   ENDIF( NOT QT_INCLUDE_DIR)
512
513   #############################################
514   #
515   # Find out what window system we're using
516   #
517   #############################################
518   # Save required includes and required_flags variables
519   macro_push_required_vars()
520   # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES
521   SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}")
522   # On Mac OS X when Qt has framework support, also add the framework path
523   IF( QT_USE_FRAMEWORKS )
524     SET(CMAKE_REQUIRED_FLAGS "-F${QT_LIBRARY_DIR} ")
525   ENDIF( QT_USE_FRAMEWORKS )
526   # Check for Window system symbols (note: only one should end up being set)
527   CHECK_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11)
528   CHECK_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN)
529   CHECK_SYMBOL_EXISTS(Q_WS_QWS "QtCore/qglobal.h" Q_WS_QWS)
530   CHECK_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC)
531
532   IF (QT_QTCOPY_REQUIRED)
533      CHECK_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY)
534      IF (NOT QT_IS_QTCOPY)
535         MESSAGE(FATAL_ERROR "qt-copy is required, but hasn't been found")
536      ENDIF (NOT QT_IS_QTCOPY)
537   ENDIF (QT_QTCOPY_REQUIRED)
538
539   # Restore CMAKE_REQUIRED_INCLUDES+CMAKE_REQUIRED_FLAGS variables
540   macro_pop_required_vars()
541   #
542   #############################################
543
544   IF (QT_USE_FRAMEWORKS)
545     SET(QT_DEFINITIONS ${QT_DEFINITIONS} -F${QT_LIBRARY_DIR} -L${QT_LIBRARY_DIR} )
546   ENDIF (QT_USE_FRAMEWORKS)
547
548   # Set QT_QT3SUPPORT_INCLUDE_DIR
549   FIND_PATH(QT_QT3SUPPORT_INCLUDE_DIR Qt3Support
550     PATHS
551     ${QT_INCLUDE_DIR}/Qt3Support
552     ${QT_LIBRARY_DIR}/Qt3Support.framework/Headers
553     NO_DEFAULT_PATH
554     )
555
556   # Set QT_QT_INCLUDE_DIR
557   FIND_PATH(QT_QT_INCLUDE_DIR qglobal.h
558     PATHS
559     ${QT_INCLUDE_DIR}/Qt
560     ${QT_LIBRARY_DIR}/QtCore.framework/Headers
561     NO_DEFAULT_PATH
562     )
563
564   # Set QT_QTGUI_INCLUDE_DIR
565   FIND_PATH(QT_QTGUI_INCLUDE_DIR QtGui
566     PATHS
567     ${QT_INCLUDE_DIR}/QtGui
568     ${QT_LIBRARY_DIR}/QtGui.framework/Headers
569     NO_DEFAULT_PATH
570     )
571
572   # Set QT_QTSVG_INCLUDE_DIR
573   FIND_PATH(QT_QTSVG_INCLUDE_DIR QtSvg
574     PATHS
575     ${QT_INCLUDE_DIR}/QtSvg
576     ${QT_LIBRARY_DIR}/QtSvg.framework/Headers
577     NO_DEFAULT_PATH
578     )
579
580   # Set QT_QTSCRIPT_INCLUDE_DIR
581   FIND_PATH(QT_QTSCRIPT_INCLUDE_DIR QtScript
582     PATHS
583     ${QT_INCLUDE_DIR}/QtScript
584     ${QT_LIBRARY_DIR}/QtScript.framework/Headers
585     NO_DEFAULT_PATH
586     )
587
588   # Set QT_QTTEST_INCLUDE_DIR
589   FIND_PATH(QT_QTTEST_INCLUDE_DIR QtTest
590     PATHS
591     ${QT_INCLUDE_DIR}/QtTest
592     ${QT_LIBRARY_DIR}/QtTest.framework/Headers
593     NO_DEFAULT_PATH
594     )
595
596   # Set QT_QTUITOOLS_INCLUDE_DIR
597   FIND_PATH(QT_QTUITOOLS_INCLUDE_DIR QtUiTools
598     PATHS
599     ${QT_INCLUDE_DIR}/QtUiTools
600     ${QT_LIBRARY_DIR}/QtUiTools.framework/Headers
601     NO_DEFAULT_PATH
602     )
603
604   # Set QT_QTMOTIF_INCLUDE_DIR
605   IF(Q_WS_X11)
606     FIND_PATH(QT_QTMOTIF_INCLUDE_DIR QtMotif 
607       PATHS 
608       ${QT_INCLUDE_DIR}/QtMotif 
609       NO_DEFAULT_PATH )
610   ENDIF(Q_WS_X11)
611
612   # Set QT_QTNETWORK_INCLUDE_DIR
613   FIND_PATH(QT_QTNETWORK_INCLUDE_DIR QtNetwork
614     PATHS
615     ${QT_INCLUDE_DIR}/QtNetwork
616     ${QT_LIBRARY_DIR}/QtNetwork.framework/Headers
617     NO_DEFAULT_PATH
618     )
619
620   # Set QT_QTNSPLUGIN_INCLUDE_DIR
621   FIND_PATH(QT_QTNSPLUGIN_INCLUDE_DIR QtNsPlugin
622     PATHS
623     ${QT_INCLUDE_DIR}/QtNsPlugin
624     ${QT_LIBRARY_DIR}/QtNsPlugin.framework/Headers
625     NO_DEFAULT_PATH
626     )
627
628   # Set QT_QTOPENGL_INCLUDE_DIR
629   FIND_PATH(QT_QTOPENGL_INCLUDE_DIR QtOpenGL
630     PATHS
631     ${QT_INCLUDE_DIR}/QtOpenGL
632     ${QT_LIBRARY_DIR}/QtOpenGL.framework/Headers
633     NO_DEFAULT_PATH
634     )
635
636   # Set QT_QTSQL_INCLUDE_DIR
637   FIND_PATH(QT_QTSQL_INCLUDE_DIR QtSql
638     PATHS
639     ${QT_INCLUDE_DIR}/QtSql
640     ${QT_LIBRARY_DIR}/QtSql.framework/Headers
641     NO_DEFAULT_PATH
642     )
643
644   # Set QT_QTXML_INCLUDE_DIR
645   FIND_PATH(QT_QTXML_INCLUDE_DIR QtXml
646     PATHS
647     ${QT_INCLUDE_DIR}/QtXml
648     ${QT_LIBRARY_DIR}/QtXml.framework/Headers
649     NO_DEFAULT_PATH
650     )
651
652   # Set QT_QTASSISTANT_INCLUDE_DIR
653   FIND_PATH(QT_QTASSISTANT_INCLUDE_DIR QtAssistant
654     PATHS
655     ${QT_INCLUDE_DIR}/QtAssistant
656     ${QT_HEADERS_DIR}/QtAssistant
657     ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers
658     NO_DEFAULT_PATH
659     )
660
661   # Set QT_QTDESIGNER_INCLUDE_DIR
662   FIND_PATH(QT_QTDESIGNER_INCLUDE_DIR QDesignerComponents
663     PATHS
664     ${QT_INCLUDE_DIR}/QtDesigner
665     ${QT_HEADERS_DIR}/QtDesigner 
666     ${QT_LIBRARY_DIR}/QtDesigner.framework/Headers
667     NO_DEFAULT_PATH
668     )
669
670   # Set QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR
671   FIND_PATH(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR QDesignerComponents
672     PATHS
673     ${QT_INCLUDE_DIR}/QtDesigner
674     ${QT_HEADERS_DIR}/QtDesigner
675     NO_DEFAULT_PATH
676     )
677
678   # Set QT_QTDBUS_INCLUDE_DIR
679   FIND_PATH(QT_QTDBUS_INCLUDE_DIR QtDBus
680     PATHS
681     ${QT_INCLUDE_DIR}/QtDBus
682     ${QT_HEADERS_DIR}/QtDBus
683     ${QT_LIBRARY_DIR}/QtDBus.framework/Headers
684     NO_DEFAULT_PATH
685     )
686   
687   # Set QT_QTASSISTANTCLIENT_INCLUDE_DIR
688   FIND_PATH(QT_QTASSISTANTCLIENT_INCLUDE_DIR QAssistantClient
689     PATHS
690     ${QT_INCLUDE_DIR}/QtAssistant
691     ${QT_HEADERS_DIR}/QtAssistant
692     NO_DEFAULT_PATH
693     )
694   
695   # Set QT_QTHELP_INCLUDE_DIR
696   FIND_PATH(QT_QTHELP_INCLUDE_DIR QtHelp
697     PATHS
698     ${QT_INCLUDE_DIR}/QtHelp
699     ${QT_HEADERS_DIR}/QtHelp
700     NO_DEFAULT_PATH
701     )
702   
703   # Set QT_QTWEBKIT_INCLUDE_DIR
704   FIND_PATH(QT_QTWEBKIT_INCLUDE_DIR QtWebKit
705     PATHS
706     ${QT_INCLUDE_DIR}/QtWebKit
707     ${QT_HEADERS_DIR}/QtWebKit
708     NO_DEFAULT_PATH
709     )
710   
711   # Set QT_QTXMLPATTERNS_INCLUDE_DIR
712   FIND_PATH(QT_QTXMLPATTERNS_INCLUDE_DIR QtXmlPatterns
713     PATHS
714     ${QT_INCLUDE_DIR}/QtXmlPatterns
715     ${QT_HEADERS_DIR}/QtXmlPatterns
716     NO_DEFAULT_PATH
717     )
718   
719   # Set QT_PHONON_INCLUDE_DIR
720   FIND_PATH(QT_PHONON_INCLUDE_DIR phonon
721     PATHS
722     ${QT_INCLUDE_DIR}/phonon
723     NO_DEFAULT_PATH
724     )
725
726   # Make variables changeble to the advanced user
727   MARK_AS_ADVANCED( QT_LIBRARY_DIR QT_INCLUDE_DIR QT_QT_INCLUDE_DIR QT_DOC_DIR QT_MKSPECS_DIR QT_PLUGINS_DIR)
728
729   # Set QT_INCLUDES
730   SET( QT_INCLUDES ${QT_QT_INCLUDE_DIR} ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} )
731
732   ########################################
733   #
734   #       Setting the LIBRARY-Variables
735   #
736   ########################################
737
738   IF (QT_USE_FRAMEWORKS)
739     # If FIND_LIBRARY found libraries in Apple frameworks, we would NOT have
740     # to jump through these hoops.
741     IF(EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
742       SET(QT_QTCORE_FOUND TRUE)
743       SET(QT_QTCORE_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtCore" CACHE STRING "The QtCore library.")
744     ELSE(EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
745       SET(QT_QTCORE_FOUND FALSE)
746     ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
747
748     IF(EXISTS ${QT_LIBRARY_DIR}/QtGui.framework)
749       SET(QT_QTGUI_FOUND TRUE)
750       SET(QT_QTGUI_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtGui" CACHE STRING "The QtGui library.")
751     ELSE(EXISTS ${QT_LIBRARY_DIR}/QtGui.framework)
752       SET(QT_QTGUI_FOUND FALSE)
753     ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtGui.framework)
754
755     IF(EXISTS ${QT_LIBRARY_DIR}/Qt3Support.framework)
756       SET(QT_QT3SUPPORT_FOUND TRUE)
757       SET(QT_QT3SUPPORT_LIBRARY "-F${QT_LIBRARY_DIR} -framework Qt3Support" CACHE STRING "The Qt3Support library.")
758     ELSE(EXISTS ${QT_LIBRARY_DIR}/Qt3Support.framework)
759       SET(QT_QT3SUPPORT_FOUND FALSE)
760     ENDIF(EXISTS ${QT_LIBRARY_DIR}/Qt3Support.framework)
761
762     IF(EXISTS ${QT_LIBRARY_DIR}/QtNetwork.framework)
763       SET(QT_QTNETWORK_FOUND TRUE)
764       SET(QT_QTNETWORK_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtNetwork" CACHE STRING "The QtNetwork library.")
765     ELSE(EXISTS ${QT_LIBRARY_DIR}/QtNetwork.framework)
766       SET(QT_QTNETWORK_FOUND FALSE)
767     ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtNetwork.framework)
768
769     IF(EXISTS ${QT_LIBRARY_DIR}/QtOpenGL.framework)
770       SET(QT_QTOPENGL_FOUND TRUE)
771       SET(QT_QTOPENGL_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtOpenGL" CACHE STRING "The QtOpenGL library.")
772     ELSE(EXISTS ${QT_LIBRARY_DIR}/QtOpenGL.framework)
773       SET(QT_QTOPENGL_FOUND FALSE)
774     ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtOpenGL.framework)
775
776     IF(EXISTS ${QT_LIBRARY_DIR}/QtSql.framework)
777       SET(QT_QTSQL_FOUND TRUE)
778       SET(QT_QTSQL_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtSql" CACHE STRING "The QtSql library.")
779     ELSE(EXISTS ${QT_LIBRARY_DIR}/QtSql.framework)
780       SET(QT_QTSQL_FOUND FALSE)
781     ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtSql.framework)
782
783     IF(EXISTS ${QT_LIBRARY_DIR}/QtXml.framework)
784       SET(QT_QTXML_FOUND TRUE)
785       SET(QT_QTXML_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtXml" CACHE STRING "The QtXml library.")
786     ELSE(EXISTS ${QT_LIBRARY_DIR}/QtXml.framework)
787       SET(QT_QTXML_FOUND FALSE)
788     ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtXml.framework)
789
790     IF(EXISTS ${QT_LIBRARY_DIR}/QtSvg.framework)
791       SET(QT_QTSVG_FOUND TRUE)
792       SET(QT_QTSVG_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtSvg" CACHE STRING "The QtSvg library.")
793     ELSE(EXISTS ${QT_LIBRARY_DIR}/QtSvg.framework)
794       SET(QT_QTSVG_FOUND FALSE)
795     ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtSvg.framework)
796
797     IF(EXISTS ${QT_LIBRARY_DIR}/QtDBus.framework)
798       SET(QT_QTDBUS_FOUND TRUE)
799       SET(QT_QTDBUS_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtDBus" CACHE STRING "The QtDBus library.")
800     ELSE(EXISTS ${QT_LIBRARY_DIR}/QtDBus.framework)
801       SET(QT_QTDBUS_FOUND FALSE)
802     ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtDBus.framework)
803
804     IF(EXISTS ${QT_LIBRARY_DIR}/QtTest.framework)
805       SET(QT_QTTEST_FOUND TRUE)
806       SET(QT_QTTEST_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtTest" CACHE STRING "The QtTest library.")
807     ELSE(EXISTS ${QT_LIBRARY_DIR}/QtTest.framework)
808       SET(QT_QTTEST_FOUND FALSE)
809     ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtTest.framework)
810
811     IF(EXISTS ${QT_LIBRARY_DIR}/QtAssistantClient.framework)
812       SET(QT_QTASSISTANTCLIENT_FOUND TRUE)
813       SET(QT_QTASSISTANTCLIENT_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtAssistantClient" CACHE STRING "The QtAssistantClient library.")
814     ELSE(EXISTS ${QT_LIBRARY_DIR}/QtAssistantClient.framework)
815       SET(QT_QTASSISTANTCLIENT_FOUND FALSE)
816     ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtAssistantClient.framework)
817
818     IF(EXISTS ${QT_LIBRARY_DIR}/QtWebKit.framework)
819       SET(QT_QTWEBKIT_FOUND TRUE)
820       SET(QT_QTWEBKIT_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtWebKit" CACHE STRING "The QtWebKit library.")
821     ELSE(EXISTS ${QT_LIBRARY_DIR}/QtWebKit.framework)
822       SET(QT_QTWEBKIT_FOUND FALSE)
823     ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtWebKit.framework)
824
825     IF(EXISTS ${QT_LIBRARY_DIR}/QtXmlPatterns.framework)
826       SET(QT_QTXMLPATTERNS_FOUND TRUE)
827       SET(QT_QTXMLPATTERNS_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtXmlPatterns" CACHE STRING "The QtXmlPatterns library.")
828     ELSE(EXISTS ${QT_LIBRARY_DIR}/QtXmlPatterns.framework)
829       SET(QT_QTXMLPATTERNS_FOUND FALSE)
830     ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtXmlPatterns.framework)
831
832
833     # WTF?  why don't we have frameworks?  :P
834     # Set QT_QTUITOOLS_LIBRARY
835     FIND_LIBRARY(QT_QTUITOOLS_LIBRARY NAMES QtUiTools QtUiTools4 PATHS ${QT_LIBRARY_DIR} )
836     # Set QT_QTSCRIPT_LIBRARY
837     FIND_LIBRARY(QT_QTSCRIPT_LIBRARY NAMES QtScript QtScript4    PATHS ${QT_LIBRARY_DIR} )
838
839   ELSE (QT_USE_FRAMEWORKS)
840     
841     # Set QT_QTCORE_LIBRARY by searching for a lib with "QtCore."  as part of the filename
842     FIND_LIBRARY(QT_QTCORE_LIBRARY NAMES QtCore QtCore4 QtCored4 QtCore_debug         PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH )
843
844     # Set QT_QT3SUPPORT_LIBRARY
845     FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY NAMES Qt3Support Qt3Support_debug Qt3Support4 Qt3Supportd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
846
847     # Set QT_QTGUI_LIBRARY
848     FIND_LIBRARY(QT_QTGUI_LIBRARY NAMES QtGui QtGui_debug QtGui_debug QtGui4 QtGuid4            PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
849
850     # Set QT_QTMOTIF_LIBRARY
851     IF(Q_WS_X11)
852       FIND_LIBRARY(QT_QTMOTIF_LIBRARY NAMES QtMotif  QtMotif_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
853     ENDIF(Q_WS_X11)
854
855     # Set QT_QTNETWORK_LIBRARY
856     FIND_LIBRARY(QT_QTNETWORK_LIBRARY NAMES QtNetwork QtNetwork_debug QtNetwork4 QtNetworkd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
857
858     # Set QT_QTNSPLUGIN_LIBRARY
859     FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY NAMES QtNsPlugin QtNsPlugin_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
860
861     # Set QT_QTOPENGL_LIBRARY
862     FIND_LIBRARY(QT_QTOPENGL_LIBRARY NAMES QtOpenGL QtOpenGL_debug QtOpenGL4 QtOpenGLd4    PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
863
864     # Set QT_QTSQL_LIBRARY
865     FIND_LIBRARY(QT_QTSQL_LIBRARY NAMES QtSql QtSql_debug QtSql4 QtSqld4       PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
866
867     # Set QT_QTXML_LIBRARY
868     FIND_LIBRARY(QT_QTXML_LIBRARY NAMES QtXml QtXml_debug QtXml4 QtXmld4       PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
869
870     # Set QT_QTSVG_LIBRARY
871     FIND_LIBRARY(QT_QTSVG_LIBRARY NAMES QtSvg QtSvg_debug QtSvg4 QtSvgd4       PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
872
873     # Set QT_QTSCRIPT_LIBRARY
874     FIND_LIBRARY(QT_QTSCRIPT_LIBRARY NAMES QtScript QtScript_debug QtScript4 QtScriptd4   PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
875
876     # Set QT_QTUITOOLS_LIBRARY
877     FIND_LIBRARY(QT_QTUITOOLS_LIBRARY NAMES QtUiTools QtUiTools_debug QtUiTools4 QtUiToolsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
878
879     # Set QT_QTTEST_LIBRARY
880     FIND_LIBRARY(QT_QTTEST_LIBRARY NAMES QtTest QtTest_debug QtTest4 QtTestd4          PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
881
882     FIND_LIBRARY(QT_QTDBUS_LIBRARY NAMES QtDBus QtDBus_debug QtDBus4 QtDBusd4         PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
883
884     FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY NAMES QtAssistantClient QtAssistantClient_debug QtAssistantClient4 QtAssistantClientd4         PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
885
886     FIND_LIBRARY(QT_QTHELP_LIBRARY NAMES QtHelp QtHelp_debug QtHelp4 QtHelpd4         PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
887
888     FIND_LIBRARY(QT_QTWEBKIT_LIBRARY NAMES QtWebKit QtWebKit_debug QtWebKit4 QtWebKitd4         PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
889
890     FIND_LIBRARY(QT_QTXMLPATTERNS_LIBRARY NAMES QtXmlPatterns QtXmlPatterns_debug QtXmlPatterns4 QtXmlPatternsd4         PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
891
892     FIND_LIBRARY(QT_PHONON_LIBRARY NAMES phonon phonon4 phonon_debug phonond4    PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
893
894
895     IF(MSVC)
896       FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE    NAMES QtCore4            PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
897       FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG      NAMES QtCored4            PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
898       FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_RELEASE NAMES Qt3Support4        PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
899       FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG  NAMES Qt3Supportd4        PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
900       FIND_LIBRARY(QT_QTGUI_LIBRARY_RELEASE     NAMES QtGui4             PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
901       FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG       NAMES QtGuid4             PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
902       FIND_LIBRARY(QT_QTNETWORK_LIBRARY_RELEASE NAMES QtNetwork4         PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
903       FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG   NAMES QtNetworkd4         PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
904       FIND_LIBRARY(QT_QTOPENGL_LIBRARY_RELEASE  NAMES QtOpenGL4          PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
905       FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG    NAMES QtOpenGLd4          PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
906       FIND_LIBRARY(QT_QTSQL_LIBRARY_RELEASE     NAMES QtSql4             PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
907       FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG       NAMES QtSqld4             PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
908       FIND_LIBRARY(QT_QTXML_LIBRARY_RELEASE     NAMES QtXml4             PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
909       FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG       NAMES QtXmld4             PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
910       FIND_LIBRARY(QT_QTSVG_LIBRARY_RELEASE     NAMES QtSvg4             PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
911       FIND_LIBRARY(QT_QTSVG_LIBRARY_DEBUG       NAMES QtSvgd4             PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
912       FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_RELEASE  NAMES QtScript4          PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
913       FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_DEBUG    NAMES QtScriptd4          PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
914       FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools QtUiTools4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
915       FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_DEBUG   NAMES QtUiToolsd QtUiToolsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
916       FIND_LIBRARY(QT_QTTEST_LIBRARY_RELEASE    NAMES QtTest4            PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
917       FIND_LIBRARY(QT_QTTEST_LIBRARY_DEBUG      NAMES QtTestd4            PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
918       FIND_LIBRARY(QT_QTDBUS_LIBRARY_RELEASE    NAMES QtDBus4            PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
919       FIND_LIBRARY(QT_QTDBUS_LIBRARY_DEBUG      NAMES QtDBusd4            PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
920       FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
921       FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistantClientd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
922       FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_RELEASE NAMES QtDesigner4            PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
923       FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_DEBUG  NAMES QtDesignerd4            PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
924       FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
925       FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NAMES QtDesignerComponentsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
926       FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE    NAMES qtmain             PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
927       FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG      NAMES qtmaind             PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
928     ENDIF(MSVC)
929   ENDIF (QT_USE_FRAMEWORKS)
930
931   IF( NOT QT_QTCORE_LIBRARY )
932     IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
933       MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.")
934     ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
935   ENDIF( NOT QT_QTCORE_LIBRARY )
936
937   # Set QT_QTASSISTANT_LIBRARY
938   FIND_LIBRARY(QT_QTASSISTANT_LIBRARY NAMES QtAssistantClient QtAssistantClient4 QtAssistant QtAssistant4 QtAssistantd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
939
940   # Set QT_QTDESIGNER_LIBRARY
941   FIND_LIBRARY(QT_QTDESIGNER_LIBRARY NAMES QtDesigner QtDesigner_debug QtDesigner4 QtDesignerd4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
942
943   # Set QT_QTDESIGNERCOMPONENTS_LIBRARY
944   FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY NAMES QtDesignerComponents QtDesignerComponents_debug QtDesignerComponents4 QtDesignerComponentsd4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
945
946   # Set QT_QTMAIN_LIBRARY
947   IF(WIN32)
948     FIND_LIBRARY(QT_QTMAIN_LIBRARY NAMES qtmain qtmaind PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
949   ENDIF(WIN32)
950
951   ############################################
952   #
953   # Check the existence of the libraries.
954   #
955   ############################################
956
957   MACRO (_QT4_ADJUST_LIB_VARS basename)
958     IF (QT_${basename}_LIBRARY OR QT_${basename}_LIBRARY_DEBUG)
959
960       IF(MSVC)
961         # Both set
962         IF (QT_${basename}_LIBRARY_RELEASE AND QT_${basename}_LIBRARY_DEBUG)
963           SET(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
964         ENDIF (QT_${basename}_LIBRARY_RELEASE AND QT_${basename}_LIBRARY_DEBUG)
965
966         # Only debug was found
967         IF (NOT QT_${basename}_LIBRARY_RELEASE AND QT_${basename}_LIBRARY_DEBUG)
968           SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG})
969         ENDIF (NOT QT_${basename}_LIBRARY_RELEASE AND QT_${basename}_LIBRARY_DEBUG)
970
971         # Only release was found
972         IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
973           SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE})
974         ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
975
976         # Hmm, is this used anywhere ? Yes, in UseQt4.cmake. We are currently incompatible :-(
977         SET(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY} debug ${QT_${basename}_LIBRARY_DEBUG})
978
979       ENDIF(MSVC)
980
981       SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE FILEPATH "The Qt ${basename} library")
982
983       IF (QT_${basename}_LIBRARY)
984         SET(QT_${basename}_FOUND 1)
985       ENDIF (QT_${basename}_LIBRARY)
986       
987     ENDIF (QT_${basename}_LIBRARY OR QT_${basename}_LIBRARY_DEBUG)
988     
989     IF (QT_${basename}_INCLUDE_DIR)
990       #add the include directory to QT_INCLUDES
991       SET(QT_INCLUDES "${QT_${basename}_INCLUDE_DIR}" ${QT_INCLUDES})
992     ENDIF (QT_${basename}_INCLUDE_DIR)
993
994     # Make variables changeble to the advanced user
995     MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_INCLUDE_DIR)
996   ENDMACRO (_QT4_ADJUST_LIB_VARS)
997
998
999   # Set QT_xyz_LIBRARY variable and add 
1000   # library include path to QT_INCLUDES
1001   _QT4_ADJUST_LIB_VARS(QTCORE)
1002   _QT4_ADJUST_LIB_VARS(QTGUI)
1003   _QT4_ADJUST_LIB_VARS(QT3SUPPORT)
1004   _QT4_ADJUST_LIB_VARS(QTASSISTANT)
1005   _QT4_ADJUST_LIB_VARS(QTDESIGNER)
1006   _QT4_ADJUST_LIB_VARS(QTDESIGNERCOMPONENTS)
1007   _QT4_ADJUST_LIB_VARS(QTNETWORK)
1008   _QT4_ADJUST_LIB_VARS(QTNSPLUGIN)
1009   _QT4_ADJUST_LIB_VARS(QTOPENGL)
1010   _QT4_ADJUST_LIB_VARS(QTSQL)
1011   _QT4_ADJUST_LIB_VARS(QTXML)
1012   _QT4_ADJUST_LIB_VARS(QTSVG)
1013   _QT4_ADJUST_LIB_VARS(QTSCRIPT)
1014   _QT4_ADJUST_LIB_VARS(QTUITOOLS)
1015   _QT4_ADJUST_LIB_VARS(QTTEST)
1016   _QT4_ADJUST_LIB_VARS(QTDBUS)
1017   _QT4_ADJUST_LIB_VARS(QTASSISTANTCLIENT)
1018   _QT4_ADJUST_LIB_VARS(QTHELP)
1019   _QT4_ADJUST_LIB_VARS(QTWEBKIT)
1020   _QT4_ADJUST_LIB_VARS(QTXMLPATTERNS)
1021   _QT4_ADJUST_LIB_VARS(PHONON)
1022
1023   # platform dependent libraries
1024   IF(Q_WS_X11)
1025     _QT4_ADJUST_LIB_VARS(QTMOTIF)
1026   ENDIF(Q_WS_X11)
1027   IF(WIN32)
1028     _QT4_ADJUST_LIB_VARS(QTMAIN)
1029   ENDIF(WIN32)
1030   
1031
1032   #######################################
1033   #
1034   #       Check the executables of Qt 
1035   #          ( moc, uic, rcc )
1036   #
1037   #######################################
1038
1039
1040   # find moc and uic using qmake
1041   QT_QUERY_QMAKE(QT_MOC_EXECUTABLE_INTERNAL "QMAKE_MOC")
1042   QT_QUERY_QMAKE(QT_UIC_EXECUTABLE_INTERNAL "QMAKE_UIC")
1043
1044   # make sure we have / and not \ as qmake gives on windows
1045   FILE(TO_CMAKE_PATH 
1046     "${QT_MOC_EXECUTABLE_INTERNAL}" QT_MOC_EXECUTABLE_INTERNAL)
1047   # make sure we have / and not \ as qmake gives on windows
1048   FILE(TO_CMAKE_PATH 
1049     "${QT_UIC_EXECUTABLE_INTERNAL}" QT_UIC_EXECUTABLE_INTERNAL)
1050
1051   SET(QT_MOC_EXECUTABLE 
1052     ${QT_MOC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The moc executable")
1053   SET(QT_UIC_EXECUTABLE 
1054     ${QT_UIC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The uic executable")
1055
1056   FIND_PROGRAM(QT_UIC3_EXECUTABLE
1057     NAMES uic3
1058     PATHS ${QT_BINARY_DIR}
1059     NO_DEFAULT_PATH
1060     )
1061
1062   FIND_PROGRAM(QT_RCC_EXECUTABLE 
1063     NAMES rcc
1064     PATHS ${QT_BINARY_DIR}
1065     NO_DEFAULT_PATH
1066     )
1067
1068   FIND_PROGRAM(QT_DBUSCPP2XML_EXECUTABLE 
1069     NAMES qdbuscpp2xml
1070     PATHS ${QT_BINARY_DIR}
1071     NO_DEFAULT_PATH
1072     )
1073
1074   FIND_PROGRAM(QT_DBUSXML2CPP_EXECUTABLE 
1075     NAMES qdbusxml2cpp
1076     PATHS ${QT_BINARY_DIR}
1077     NO_DEFAULT_PATH
1078     )
1079
1080   FIND_PROGRAM(QT_LUPDATE_EXECUTABLE
1081     NAMES lupdate-qt4 lupdate
1082     PATHS ${QT_BINARY_DIR}
1083     NO_DEFAULT_PATH
1084     )
1085
1086   FIND_PROGRAM(QT_LRELEASE_EXECUTABLE
1087     NAMES lrelease-qt4 lrelease
1088     PATHS ${QT_BINARY_DIR}
1089     NO_DEFAULT_PATH
1090     )
1091
1092   IF (QT_MOC_EXECUTABLE)
1093      SET(QT_WRAP_CPP "YES")
1094   ENDIF (QT_MOC_EXECUTABLE)
1095
1096   IF (QT_UIC_EXECUTABLE)
1097      SET(QT_WRAP_UI "YES")
1098   ENDIF (QT_UIC_EXECUTABLE)
1099
1100
1101
1102   MARK_AS_ADVANCED( QT_UIC_EXECUTABLE QT_UIC3_EXECUTABLE QT_MOC_EXECUTABLE
1103     QT_RCC_EXECUTABLE QT_DBUSXML2CPP_EXECUTABLE QT_DBUSCPP2XML_EXECUTABLE
1104     QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE)
1105
1106   ######################################
1107   #
1108   #       Macros for building Qt files
1109   #
1110   ######################################
1111
1112   MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
1113     SET(${_qt4_files})
1114     SET(${_qt4_options})
1115     SET(_QT4_DOING_OPTIONS FALSE)
1116     FOREACH(_currentArg ${ARGN})
1117       IF ("${_currentArg}" STREQUAL "OPTIONS")
1118         SET(_QT4_DOING_OPTIONS TRUE)
1119       ELSE ("${_currentArg}" STREQUAL "OPTIONS")
1120         IF(_QT4_DOING_OPTIONS) 
1121           LIST(APPEND ${_qt4_options} "${_currentArg}")
1122         ELSE(_QT4_DOING_OPTIONS)
1123           LIST(APPEND ${_qt4_files} "${_currentArg}")
1124         ENDIF(_QT4_DOING_OPTIONS)
1125       ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
1126     ENDFOREACH(_currentArg) 
1127   ENDMACRO (QT4_EXTRACT_OPTIONS)
1128
1129   MACRO (QT4_GET_MOC_INC_DIRS _moc_INC_DIRS)
1130      SET(${_moc_INC_DIRS})
1131      GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES)
1132
1133      FOREACH(_current ${_inc_DIRS})
1134         SET(${_moc_INC_DIRS} ${${_moc_INC_DIRS}} "-I" ${_current})
1135      ENDFOREACH(_current ${_inc_DIRS})
1136
1137      # if Qt is installed only as framework, add -F /library/Frameworks to the moc arguments
1138      # otherwise moc can't find the headers in the framework include dirs
1139      IF(APPLE  AND  "${QT_QTCORE_INCLUDE_DIR}" MATCHES "/Library/Frameworks/")
1140         SET(${_moc_INC_DIRS} ${${_moc_INC_DIRS}} "-F/Library/Frameworks")
1141      ENDIF(APPLE  AND  "${QT_QTCORE_INCLUDE_DIR}" MATCHES "/Library/Frameworks/")
1142
1143   ENDMACRO(QT4_GET_MOC_INC_DIRS)
1144
1145   # Added by Sput to provide definitions to moc calls
1146   MACRO (QT4_GET_MOC_DEFINES _moc_DEFINES)
1147      SET(${_moc_DEFINES})
1148      GET_DIRECTORY_PROPERTY(_defines COMPILE_DEFINITIONS)
1149      FOREACH(_current ${_defines})
1150         SET(${_moc_DEFINES} ${${_moc_DEFINES}} -D${_current})
1151      ENDFOREACH(_current ${_defines})
1152
1153   ENDMACRO(QT4_GET_MOC_DEFINES)
1154
1155   MACRO (QT4_GENERATE_MOC infile outfile )
1156   # get include dirs
1157      # QT4_GET_MOC_INC_DIRS(moc_includes) # Not needed...
1158      QT4_GET_MOC_DEFINES(moc_defines)
1159
1160      GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE)
1161
1162      IF (MSVC_IDE)
1163         SET (_moc_parameter_file ${outfile}_parameters)
1164         SET (_moc_param "${moc_includes} \n-o${outfile} \n${abs_infile}")
1165         STRING(REGEX REPLACE ";-I;" "\\n-I" _moc_param "${_moc_param}")
1166         FILE (WRITE ${_moc_parameter_file} "${_moc_param}")
1167         ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1168           COMMAND ${QT_MOC_EXECUTABLE}
1169           ARGS @"${_moc_parameter_file}"
1170           DEPENDS ${abs_infile})
1171      ELSE (MSVC_IDE)
1172         ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1173            COMMAND ${QT_MOC_EXECUTABLE}
1174            ARGS ${moc_includes} ${moc_defines} -o ${outfile} ${abs_infile}
1175            DEPENDS ${abs_infile})
1176      ENDIF (MSVC_IDE)
1177
1178      SET_SOURCE_FILES_PROPERTIES(${outfile} PROPERTIES SKIP_AUTOMOC TRUE)  # dont run automoc on this file
1179
1180      MACRO_ADD_FILE_DEPENDENCIES(${abs_infile} ${outfile})
1181   ENDMACRO (QT4_GENERATE_MOC)
1182
1183
1184   # QT4_WRAP_CPP(outfiles inputfile ... )
1185
1186   MACRO (QT4_WRAP_CPP outfiles )
1187     # get include dirs
1188     # QT4_GET_MOC_INC_DIRS(moc_includes) # Not needed
1189     QT4_GET_MOC_DEFINES(moc_defines)
1190     QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
1191
1192     FOREACH (it ${moc_files})
1193       GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
1194       GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
1195
1196       SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/moc_${outfile}.cxx)
1197       ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1198         COMMAND ${QT_MOC_EXECUTABLE}
1199         ARGS ${moc_includes} ${moc_defines} ${moc_options} -o ${outfile} ${it}
1200         DEPENDS ${it})
1201       SET(${outfiles} ${${outfiles}} ${outfile})
1202     ENDFOREACH(it)
1203
1204   ENDMACRO (QT4_WRAP_CPP)
1205
1206
1207   # QT4_WRAP_UI(outfiles inputfile ... )
1208
1209   MACRO (QT4_WRAP_UI outfiles )
1210     QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
1211
1212     FOREACH (it ${ui_files})
1213       GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
1214       GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
1215       SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
1216       ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1217         COMMAND ${QT_UIC_EXECUTABLE}
1218         ARGS ${ui_options} -o ${outfile} ${infile}
1219         MAIN_DEPENDENCY ${infile})
1220       SET(${outfiles} ${${outfiles}} ${outfile})
1221     ENDFOREACH (it)
1222
1223   ENDMACRO (QT4_WRAP_UI)
1224
1225
1226   # QT4_ADD_RESOURCES(outfiles inputfile ... )
1227
1228   MACRO (QT4_ADD_RESOURCES outfiles )
1229     QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN})
1230
1231     FOREACH (it ${rcc_files})
1232       GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
1233       GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
1234       GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
1235       SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
1236       #  parse file for dependencies 
1237       #  all files are absolute paths or relative to the location of the qrc file
1238       FILE(READ "${infile}" _RC_FILE_CONTENTS)
1239       STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
1240       SET(_RC_DEPENDS)
1241       FOREACH(_RC_FILE ${_RC_FILES})
1242         STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
1243         STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}")
1244         IF(NOT _ABS_PATH_INDICATOR)
1245           SET(_RC_FILE "${rc_path}/${_RC_FILE}")
1246         ENDIF(NOT _ABS_PATH_INDICATOR)
1247         SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
1248       ENDFOREACH(_RC_FILE)
1249       ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1250         COMMAND ${QT_RCC_EXECUTABLE}
1251         ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
1252         MAIN_DEPENDENCY ${infile}
1253         DEPENDS ${_RC_DEPENDS})
1254       SET(${outfiles} ${${outfiles}} ${outfile})
1255     ENDFOREACH (it)
1256
1257   ENDMACRO (QT4_ADD_RESOURCES)
1258
1259   MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename)
1260     GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE)
1261     SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
1262     SET(_impl   ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
1263     SET(_moc    ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
1264
1265     GET_SOURCE_FILE_PROPERTY(_nonamespace ${_interface} NO_NAMESPACE)
1266     IF ( _nonamespace )
1267         SET(_params -N -m)
1268     ELSE ( _nonamespace )
1269         SET(_params -m)
1270     ENDIF ( _nonamespace )
1271
1272     GET_SOURCE_FILE_PROPERTY(_include ${_interface} INCLUDE)
1273     IF ( _include )
1274         SET(_params ${_params} -i ${_include})
1275     ENDIF ( _include )
1276
1277     ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1278         COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile}
1279         DEPENDS ${_infile})
1280   
1281     SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
1282     
1283     QT4_GENERATE_MOC(${_header} ${_moc})
1284   
1285     SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
1286     MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
1287   
1288   ENDMACRO(QT4_ADD_DBUS_INTERFACE)
1289   
1290   
1291   MACRO(QT4_ADD_DBUS_INTERFACES _sources)
1292      FOREACH (_current_FILE ${ARGN})
1293         GET_FILENAME_COMPONENT(_infile ${_current_FILE} ABSOLUTE)
1294         # get the part before the ".xml" suffix
1295         STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2" _basename ${_current_FILE})
1296         STRING(TOLOWER ${_basename} _basename)
1297         QT4_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface)
1298      ENDFOREACH (_current_FILE)
1299   ENDMACRO(QT4_ADD_DBUS_INTERFACES)
1300   
1301   
1302   MACRO(QT4_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options )
1303     QT4_EXTRACT_OPTIONS(_customName _qt4_dbus_options ${ARGN})
1304
1305     GET_FILENAME_COMPONENT(_in_file ${_header} ABSOLUTE)
1306     GET_FILENAME_COMPONENT(_basename ${_header} NAME_WE)
1307     
1308     IF (_customName)
1309       SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName})
1310     ELSE (_customName)
1311       SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml)
1312     ENDIF (_customName)
1313   
1314     ADD_CUSTOM_COMMAND(OUTPUT ${_target}
1315         COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} > ${_target}
1316         DEPENDS ${_in_file}
1317     )
1318   ENDMACRO(QT4_GENERATE_DBUS_INTERFACE)
1319   
1320   
1321   MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName)
1322     GET_FILENAME_COMPONENT(_infile ${_xml_file} ABSOLUTE)
1323     
1324     SET(_optionalBasename "${ARGV4}")
1325     IF (_optionalBasename)
1326        SET(_basename ${_optionalBasename} )
1327     ELSE (_optionalBasename)
1328        STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile})
1329        STRING(TOLOWER ${_basename} _basename)
1330     ENDIF (_optionalBasename)
1331
1332     SET(_optionalClassName "${ARGV5}")
1333     SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
1334     SET(_impl   ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
1335     SET(_moc    ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
1336
1337     IF(_optionalClassName)
1338        ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1339           COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
1340           DEPENDS ${_infile}
1341         )
1342     ELSE(_optionalClassName)
1343        ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1344           COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
1345           DEPENDS ${_infile}
1346         )
1347     ENDIF(_optionalClassName)
1348
1349     QT4_GENERATE_MOC(${_header} ${_moc})
1350     SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
1351     MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
1352
1353     SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
1354   ENDMACRO(QT4_ADD_DBUS_ADAPTOR)
1355
1356    MACRO(QT4_AUTOMOC)
1357       # QT4_GET_MOC_INC_DIRS(_moc_INCS)
1358       QT4_GET_MOC_DEFINES(_moc_DEFINES)
1359
1360
1361       SET(_matching_FILES )
1362       FOREACH (_current_FILE ${ARGN})
1363
1364          GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
1365          # if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
1366          # This is required to make uic work correctly:
1367          # we need to add generated .cpp files to the sources (to compile them),
1368          # but we cannot let automoc handle them, as the .cpp files don't exist yet when
1369          # cmake is run for the very first time on them -> however the .cpp files might
1370          # exist at a later run. at that time we need to skip them, so that we don't add two
1371          # different rules for the same moc file
1372          GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC)
1373
1374          IF ( NOT _skip AND EXISTS ${_abs_FILE} )
1375
1376             FILE(READ ${_abs_FILE} _contents)
1377
1378             GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH)
1379
1380             STRING(REGEX MATCHALL "#include +[^ ]+\\.moc[\">]" _match "${_contents}")
1381             IF(_match)
1382                FOREACH (_current_MOC_INC ${_match})
1383                   STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
1384
1385                   GET_filename_component(_basename ${_current_MOC} NAME_WE)
1386    #               SET(_header ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h)
1387                   SET(_header ${_abs_PATH}/${_basename}.h)
1388                   SET(_moc    ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
1389                   ADD_CUSTOM_COMMAND(OUTPUT ${_moc}
1390                      COMMAND ${QT_MOC_EXECUTABLE}
1391                      ARGS ${_moc_INCS} ${_moc_DEFINES} ${_header} -o ${_moc}
1392                      DEPENDS ${_header}
1393                   )
1394
1395                   MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
1396                ENDFOREACH (_current_MOC_INC)
1397             ENDIF(_match)
1398          ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} )
1399       ENDFOREACH (_current_FILE)
1400    ENDMACRO(QT4_AUTOMOC)
1401
1402
1403
1404   ######################################
1405   #
1406   #       decide if Qt got found
1407   #
1408   ######################################
1409
1410   # if the includes,libraries,moc,uic and rcc are found then we have it
1411   IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1412     SET( QT4_FOUND "YES" )
1413     IF( NOT Qt4_FIND_QUIETLY)
1414       MESSAGE(STATUS "Found Qt-Version ${QTVERSION} (using ${QT_QMAKE_EXECUTABLE})")
1415     ENDIF( NOT Qt4_FIND_QUIETLY)
1416   ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1417     SET( QT4_FOUND "NO")
1418     SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1419     IF( Qt4_FIND_REQUIRED)
1420       IF ( NOT QT_LIBRARY_DIR )
1421         MESSAGE(STATUS "Qt libraries NOT found!")
1422       ENDIF(NOT QT_LIBRARY_DIR )
1423       IF ( NOT QT_INCLUDE_DIR )
1424         MESSAGE(STATUS "Qt includes NOT found!")
1425       ENDIF( NOT QT_INCLUDE_DIR )
1426       IF ( NOT QT_MOC_EXECUTABLE )
1427         MESSAGE(STATUS "Qt's moc NOT found!")
1428       ENDIF( NOT QT_MOC_EXECUTABLE )
1429       IF ( NOT QT_UIC_EXECUTABLE )
1430         MESSAGE(STATUS "Qt's uic NOT found!")
1431       ENDIF( NOT QT_UIC_EXECUTABLE )
1432       IF ( NOT QT_RCC_EXECUTABLE )
1433         MESSAGE(STATUS "Qt's rcc NOT found!")
1434       ENDIF( NOT QT_RCC_EXECUTABLE )
1435       MESSAGE( FATAL_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!")
1436     ENDIF( Qt4_FIND_REQUIRED)
1437   ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND  QT_RCC_EXECUTABLE)
1438   SET(QT_FOUND ${QT4_FOUND})
1439
1440
1441   #######################################
1442   #
1443   #       Qt configuration
1444   #
1445   #######################################
1446   IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
1447     FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents)
1448     STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG ${_qconfig_FILE_contents})
1449     STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG ${_qconfig_FILE_contents})
1450     STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION ${_qconfig_FILE_contents})
1451   ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
1452   IF("${QT_EDITION}" MATCHES "DesktopLight")
1453     SET(QT_EDITION_DESKTOPLIGHT 1)
1454   ENDIF("${QT_EDITION}" MATCHES "DesktopLight")
1455   
1456   ###############################################
1457   #
1458   #       configuration/system dependent settings  
1459   #
1460   ###############################################
1461
1462   SET(QT_GUI_LIB_DEPENDENCIES "")
1463   SET(QT_CORE_LIB_DEPENDENCIES "")
1464   
1465   # shared build needs -DQT_SHARED
1466   IF(NOT QT_CONFIG MATCHES "static")
1467     # warning currently only qconfig.pri on Windows potentially contains "static"
1468     # so QT_SHARED might not get defined properly on Mac/X11 (which seems harmless right now)
1469     # Trolltech said they'd consider exporting it for all platforms in future releases.
1470     SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_SHARED)
1471   ENDIF(NOT QT_CONFIG MATCHES "static")
1472
1473   # OpenSSL
1474   IF(NOT QT_QCONFIG MATCHES "openssl")
1475     SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_NO_OPENSSL)
1476   ENDIF(NOT QT_QCONFIG MATCHES "openssl")
1477   
1478   ## system png
1479   IF(QT_QCONFIG MATCHES "system-png")
1480     FIND_LIBRARY(QT_PNG_LIBRARY NAMES png)
1481     SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY})
1482     MARK_AS_ADVANCED(QT_PNG_LIBRARY)
1483   ENDIF(QT_QCONFIG MATCHES "system-png")
1484   
1485   # for X11, get X11 library directory
1486   IF(Q_WS_X11)
1487     QT_QUERY_QMAKE(QMAKE_LIBDIR_X11 "QMAKE_LIBDIR_X11")
1488   ENDIF(Q_WS_X11)
1489
1490   ## X11 SM
1491   IF(QT_QCONFIG MATCHES "x11sm")
1492     # ask qmake where the x11 libs are
1493     FIND_LIBRARY(QT_X11_SM_LIBRARY NAMES SM PATHS ${QMAKE_LIBDIR_X11})
1494     FIND_LIBRARY(QT_X11_ICE_LIBRARY NAMES ICE PATHS ${QMAKE_LIBDIR_X11})
1495     SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_X11_SM_LIBRARY} ${QT_X11_ICE_LIBRARY})
1496     MARK_AS_ADVANCED(QT_X11_SM_LIBRARY)
1497     MARK_AS_ADVANCED(QT_X11_ICE_LIBRARY)
1498   ENDIF(QT_QCONFIG MATCHES "x11sm")
1499   
1500   ## Xi
1501   IF(QT_QCONFIG MATCHES "tablet")
1502     FIND_LIBRARY(QT_XI_LIBRARY NAMES Xi PATHS ${QMAKE_LIBDIR_X11})
1503     SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XI_LIBRARY})
1504     MARK_AS_ADVANCED(QT_XI_LIBRARY)
1505   ENDIF(QT_QCONFIG MATCHES "tablet")
1506
1507   ## Xrender
1508   IF(QT_QCONFIG MATCHES "xrender")
1509     FIND_LIBRARY(QT_XRENDER_LIBRARY NAMES Xrender PATHS ${QMAKE_LIBDIR_X11})
1510     SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XRENDER_LIBRARY})
1511     MARK_AS_ADVANCED(QT_XRENDER_LIBRARY)
1512   ENDIF(QT_QCONFIG MATCHES "xrender")
1513   
1514   ## Xrandr
1515   IF(QT_QCONFIG MATCHES "xrandr")
1516     FIND_LIBRARY(QT_XRANDR_LIBRARY NAMES Xrandr PATHS ${QMAKE_LIBDIR_X11})
1517     SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XRANDR_LIBRARY})
1518     MARK_AS_ADVANCED(QT_XRANDR_LIBRARY)
1519   ENDIF(QT_QCONFIG MATCHES "xrandr")
1520   
1521   ## Xcursor
1522   IF(QT_QCONFIG MATCHES "xcursor")
1523     FIND_LIBRARY(QT_XCURSOR_LIBRARY NAMES Xcursor PATHS ${QMAKE_LIBDIR_X11})
1524     SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XCURSOR_LIBRARY})
1525     MARK_AS_ADVANCED(QT_XCURSOR_LIBRARY)
1526   ENDIF(QT_QCONFIG MATCHES "xcursor")
1527   
1528   ## Xinerama
1529   IF(QT_QCONFIG MATCHES "xinerama")
1530     FIND_LIBRARY(QT_XINERAMA_LIBRARY NAMES Xinerama PATHS ${QMAKE_LIBDIR_X11})
1531     SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XINERAMA_LIBRARY})
1532     MARK_AS_ADVANCED(QT_XINERAMA_LIBRARY)
1533   ENDIF(QT_QCONFIG MATCHES "xinerama")
1534   
1535   ## Xfixes
1536   IF(QT_QCONFIG MATCHES "xfixes")
1537     FIND_LIBRARY(QT_XFIXES_LIBRARY NAMES Xfixes PATHS ${QMAKE_LIBDIR_X11})
1538     SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XFIXES_LIBRARY})
1539     MARK_AS_ADVANCED(QT_XFIXES_LIBRARY)
1540   ENDIF(QT_QCONFIG MATCHES "xfixes")
1541   
1542   ## system-freetype
1543   IF(QT_QCONFIG MATCHES "system-freetype")
1544     FIND_LIBRARY(QT_FREETYPE_LIBRARY NAMES freetype)
1545     SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY})
1546     MARK_AS_ADVANCED(QT_FREETYPE_LIBRARY)
1547   ENDIF(QT_QCONFIG MATCHES "system-freetype")
1548   
1549   ## fontconfig
1550   IF(QT_QCONFIG MATCHES "fontconfig")
1551     FIND_LIBRARY(QT_FONTCONFIG_LIBRARY NAMES fontconfig)
1552     SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY})
1553     MARK_AS_ADVANCED(QT_FONTCONFIG_LIBRARY)
1554   ENDIF(QT_QCONFIG MATCHES "fontconfig")
1555   
1556   ## system-zlib
1557   IF(QT_QCONFIG MATCHES "system-zlib")
1558     FIND_LIBRARY(QT_ZLIB_LIBRARY NAMES z)
1559     SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY})
1560     MARK_AS_ADVANCED(QT_ZLIB_LIBRARY)
1561   ENDIF(QT_QCONFIG MATCHES "system-zlib")
1562   
1563   ## glib
1564   IF(QT_QCONFIG MATCHES "glib")
1565     # Qt less than Qt 4.2.0 doesn't use glib
1566     # Qt 4.2.0 uses glib-2.0 (wish we could ask Qt that it uses 2.0)
1567     FIND_LIBRARY(QT_GLIB_LIBRARY NAMES glib-2.0)
1568     FIND_LIBRARY(QT_GTHREAD_LIBRARY NAMES gthread-2.0)
1569     IF(QT_GTHREAD_LIBRARY AND QT_GLIB_LIBRARY)  #TEMP: need more robust find of glib2
1570       SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES}
1571         ${QT_GTHREAD_LIBRARY} ${QT_GLIB_LIBRARY})
1572     ENDIF(QT_GTHREAD_LIBRARY AND QT_GLIB_LIBRARY)
1573     MARK_AS_ADVANCED(QT_GLIB_LIBRARY)
1574     MARK_AS_ADVANCED(QT_GTHREAD_LIBRARY)
1575   ENDIF(QT_QCONFIG MATCHES "glib")
1576   
1577   ## clock-monotonic, just see if we need to link with rt
1578   IF(QT_QCONFIG MATCHES "clock-monotonic")
1579     SET(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
1580     SET(CMAKE_REQUIRED_LIBRARIES rt)
1581     CHECK_SYMBOL_EXISTS(_POSIX_TIMERS "unistd.h;time.h" QT_POSIX_TIMERS)
1582     SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
1583     IF(QT_POSIX_TIMERS)
1584       FIND_LIBRARY(QT_RT_LIBRARY NAMES rt)
1585       SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QT_RT_LIBRARY})
1586       MARK_AS_ADVANCED(QT_RT_LIBRARY)
1587     ENDIF(QT_POSIX_TIMERS)
1588   ENDIF(QT_QCONFIG MATCHES "clock-monotonic")
1589  
1590   IF(Q_WS_X11)
1591     # X11 libraries Qt absolutely depends on
1592     QT_QUERY_QMAKE(QT_LIBS_X11 "QMAKE_LIBS_X11")
1593     SEPARATE_ARGUMENTS(QT_LIBS_X11)
1594     FOREACH(QT_X11_LIB ${QT_LIBS_X11})
1595       STRING(REGEX REPLACE "-l" "" QT_X11_LIB "${QT_X11_LIB}")
1596       SET(QT_TMP_STR "QT_X11_${QT_X11_LIB}_LIBRARY")
1597       FIND_LIBRARY(${QT_TMP_STR} NAMES "${QT_X11_LIB}" PATHS ${QMAKE_LIBDIR_X11})
1598       SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${${QT_TMP_STR}})
1599       MARK_AS_ADVANCED(${QT_TMP_STR})
1600     ENDFOREACH(QT_X11_LIB)
1601
1602     QT_QUERY_QMAKE(QT_LIBS_THREAD "QMAKE_LIBS_THREAD")
1603     SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QT_LIBS_THREAD})
1604     
1605     QT_QUERY_QMAKE(QMAKE_LIBS_DYNLOAD "QMAKE_LIBS_DYNLOAD")
1606     SET (QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QMAKE_LIBS_DYNLOAD})
1607
1608   ENDIF(Q_WS_X11)
1609   
1610   IF(Q_WS_WIN)
1611     SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} imm32 winmm)
1612     SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ws2_32)
1613   ENDIF(Q_WS_WIN)
1614   
1615   IF(Q_WS_MAC)
1616     SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} "-framework Carbon" "-framework QuickTime")
1617     SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} "-framework ApplicationServices")
1618   ENDIF(Q_WS_MAC)
1619
1620   #######################################
1621   #
1622   #       compatibility settings 
1623   #
1624   #######################################
1625   # Backwards compatibility for CMake1.4 and 1.2
1626   SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} )
1627   SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} )
1628
1629   SET( QT_QT_LIBRARY "")
1630
1631 ELSE(QT4_QMAKE_FOUND)
1632    
1633    SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1634    IF(Qt4_FIND_REQUIRED)
1635       IF(QT4_INSTALLED_VERSION_TOO_OLD)
1636          MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1637       ELSE(QT4_INSTALLED_VERSION_TOO_OLD)
1638          MESSAGE( FATAL_ERROR "Qt qmake not found!")
1639       ENDIF(QT4_INSTALLED_VERSION_TOO_OLD)
1640    ELSE(Qt4_FIND_REQUIRED)
1641       IF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1642          MESSAGE(STATUS "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1643       ENDIF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1644    ENDIF(Qt4_FIND_REQUIRED)
1645  
1646 ENDIF (QT4_QMAKE_FOUND)
1647 ENDIF (QT4_QMAKE_FOUND)
1648