Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Modules / FindQt4.cmake
blob2050dec8ed01c0edc156bfd0724077cab4d1f09e
1 # - Find QT 4
2 # This module can be used to find Qt4.
3 # The most important issue is that the Qt4 qmake is available via the system path.
4 # This qmake is then used to detect basically everything else.
5 # This module defines a number of key variables and macros. 
6 # The variable QT_USE_FILE is set which is the path to a CMake file that can be included 
7 # to compile Qt 4 applications and libraries.  It sets up the compilation
8 # environment for include directories, preprocessor defines and populates a
9 # QT_LIBRARIES variable.
11 # Typical usage could be something like:
12 #   find_package(Qt4 4.4.3 COMPONENTS QtCore QtGui QtXml REQUIRED )
13 #   include(${QT_USE_FILE})
14 #   add_executable(myexe main.cpp)
15 #   target_link_libraries(myexe ${QT_LIBRARIES})
17 # When using the components argument, QT_USE_QT* variables are automatically set
18 # for the QT_USE_FILE to pick up.  If one wishes to manually set them, the
19 # available ones to set include:
20 #                    QT_DONT_USE_QTCORE
21 #                    QT_DONT_USE_QTGUI
22 #                    QT_USE_QT3SUPPORT
23 #                    QT_USE_QTASSISTANT
24 #                    QT_USE_QAXCONTAINER
25 #                    QT_USE_QAXSERVER
26 #                    QT_USE_QTDESIGNER
27 #                    QT_USE_QTMOTIF
28 #                    QT_USE_QTMAIN
29 #                    QT_USE_QTNETWORK
30 #                    QT_USE_QTNSPLUGIN
31 #                    QT_USE_QTOPENGL
32 #                    QT_USE_QTSQL
33 #                    QT_USE_QTXML
34 #                    QT_USE_QTSVG
35 #                    QT_USE_QTTEST
36 #                    QT_USE_QTUITOOLS
37 #                    QT_USE_QTDBUS
38 #                    QT_USE_QTSCRIPT
39 #                    QT_USE_QTASSISTANTCLIENT
40 #                    QT_USE_QTHELP
41 #                    QT_USE_QTWEBKIT
42 #                    QT_USE_QTXMLPATTERNS
43 #                    QT_USE_PHONON
45 # There are also some files that need processing by some Qt tools such as moc
46 # and uic.  Listed below are macros that may be used to process those files.
47 #  
48 #  macro QT4_WRAP_CPP(outfiles inputfile ... OPTIONS ...)
49 #        create moc code from a list of files containing Qt class with
50 #        the Q_OBJECT declaration.  Per-direcotry preprocessor definitions 
51 #        are also added.  Options may be given to moc, such as those found
52 #        when executing "moc -help".  
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"
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"
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.
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.
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
87 #  macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... )
88 #        create the interface header and implementation files 
89 #        for all listed interface xml files
90 #        the name will be automatically determined from the name of the xml file
92 #  macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname [basename] )
93 #        create a dbus adaptor (header and implementation file) from the xml file
94 #        describing the interface, and add it to the list of sources. The adaptor
95 #        forwards the calls to a parent class, defined in parentheader and named
96 #        parentclassname. The name of the generated files will be
97 #        <basename>adaptor.{cpp,h} where basename is the basename of the xml file.
99 #  macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] )
100 #        generate the xml interface file from the given header.
101 #        If the optional argument interfacename is omitted, the name of the 
102 #        interface file is constructed from the basename of the header with
103 #        the suffix .xml appended.
105 #  macro QT4_CREATE_TRANSLATION( qm_files directories ... sources ... 
106 #                                ts_files ... OPTIONS ...)
107 #        out: qm_files
108 #        in:  directories sources ts_files
109 #        options: flags to pass to lupdate, such as -extensions to specify
110 #        extensions for a directory scan.
111 #        generates commands to create .ts (vie lupdate) and .qm
112 #        (via lrelease) - files from directories and/or sources. The ts files are 
113 #        created and/or updated in the source tree (unless given with full paths).
114 #        The qm files are generated in the build tree.
115 #        Updating the translations can be done by adding the qm_files
116 #        to the source list of your library/executable, so they are
117 #        always updated, or by adding a custom target to control when
118 #        they get updated/generated.
120 #  macro QT4_ADD_TRANSLATION( qm_files ts_files ... )
121 #        out: qm_files
122 #        in:  ts_files
123 #        generates commands to create .qm from .ts - files. The generated
124 #        filenames can be found in qm_files. The ts_files
125 #        must exists and are not updated in any way.
128 #  Below is a detailed list of variables that FindQt4.cmake sets.
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_QAXCONTAINER_FOUND     True if QAxContainer was found (Windows only).
143 #  QT_QAXSERVER_FOUND          True if QAxServer was found (Windows only).
144 #  QT_QTDBUS_FOUND          True if QtDBus was found.
145 #  QT_QTDESIGNER_FOUND      True if QtDesigner was found.
146 #  QT_QTDESIGNERCOMPONENTS  True if QtDesignerComponents was found.
147 #  QT_QTMOTIF_FOUND         True if QtMotif was found.
148 #  QT_QTNETWORK_FOUND       True if QtNetwork was found.
149 #  QT_QTNSPLUGIN_FOUND      True if QtNsPlugin was found.
150 #  QT_QTOPENGL_FOUND        True if QtOpenGL was found.
151 #  QT_QTSQL_FOUND           True if QtSql was found.
152 #  QT_QTXML_FOUND           True if QtXml was found.
153 #  QT_QTSVG_FOUND           True if QtSvg was found.
154 #  QT_QTSCRIPT_FOUND        True if QtScript was found.
155 #  QT_QTTEST_FOUND          True if QtTest was found.
156 #  QT_QTUITOOLS_FOUND       True if QtUiTools was found.
157 #  QT_QTASSISTANTCLIENT_FOUND  True if QtAssistantClient was found.
158 #  QT_QTHELP_FOUND          True if QtHelp was found.
159 #  QT_QTWEBKIT_FOUND        True if QtWebKit was found.
160 #  QT_QTXMLPATTERNS_FOUND   True if QtXmlPatterns was found.
161 #  QT_PHONON_FOUND          True if phonon was found.
164 #  QT_DEFINITIONS   Definitions to use when compiling code that uses Qt.
165 #                   You do not need to use this if you include QT_USE_FILE.
166 #                   The QT_USE_FILE will also define QT_DEBUG and QT_NO_DEBUG
167 #                   to fit your current build type.  Those are not contained
168 #                   in QT_DEFINITIONS.
169 #                  
170 #  QT_INCLUDES      List of paths to all include directories of 
171 #                   Qt4 QT_INCLUDE_DIR and QT_QTCORE_INCLUDE_DIR are
172 #                   always in this variable even if NOTFOUND,
173 #                   all other INCLUDE_DIRS are
174 #                   only added if they are found.
175 #                   You do not need to use this if you include QT_USE_FILE.
176 #   
178 #  Include directories for the Qt modules are listed here.
179 #  You do not need to use these variables if you include QT_USE_FILE.
181 #  QT_INCLUDE_DIR              Path to "include" of Qt4
182 #  QT_QT3SUPPORT_INCLUDE_DIR   Path to "include/Qt3Support" 
183 #  QT_QTASSISTANT_INCLUDE_DIR  Path to "include/QtAssistant" 
184 #  QT_QAXCONTAINER_INCLUDE_DIR  Path to "include/ActiveQt" (Windows only)
185 #  QT_QAXSERVER_INCLUDE_DIR  Path to "include/ActiveQt" (Windows only)
186 #  QT_QTCORE_INCLUDE_DIR       Path to "include/QtCore"         
187 #  QT_QTDESIGNER_INCLUDE_DIR   Path to "include/QtDesigner" 
188 #  QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR   Path to "include/QtDesigner"
189 #  QT_QTDBUS_INCLUDE_DIR       Path to "include/QtDBus" 
190 #  QT_QTGUI_INCLUDE_DIR        Path to "include/QtGui" 
191 #  QT_QTMOTIF_INCLUDE_DIR      Path to "include/QtMotif" 
192 #  QT_QTNETWORK_INCLUDE_DIR    Path to "include/QtNetwork" 
193 #  QT_QTNSPLUGIN_INCLUDE_DIR   Path to "include/QtNsPlugin" 
194 #  QT_QTOPENGL_INCLUDE_DIR     Path to "include/QtOpenGL" 
195 #  QT_QTSQL_INCLUDE_DIR        Path to "include/QtSql" 
196 #  QT_QTXML_INCLUDE_DIR        Path to "include/QtXml" 
197 #  QT_QTSVG_INCLUDE_DIR        Path to "include/QtSvg"
198 #  QT_QTSCRIPT_INCLUDE_DIR     Path to "include/QtScript"
199 #  QT_QTTEST_INCLUDE_DIR       Path to "include/QtTest"
200 #  QT_QTASSISTANTCLIENT_INCLUDE_DIR       Path to "include/QtAssistant"
201 #  QT_QTHELP_INCLUDE_DIR       Path to "include/QtHelp"
202 #  QT_QTWEBKIT_INCLUDE_DIR     Path to "include/QtWebKit"
203 #  QT_QTXMLPATTERNS_INCLUDE_DIR  Path to "include/QtXmlPatterns"
204 #  QT_PHONON_INCLUDE_DIR       Path to "include/phonon"
205 #                            
206 #  QT_BINARY_DIR               Path to "bin" of Qt4
207 #  QT_LIBRARY_DIR              Path to "lib" of Qt4
208 #  QT_PLUGINS_DIR              Path to "plugins" for Qt4
209 #  QT_TRANSLATIONS_DIR         Path to "translations" of Qt4
210 #  QT_DOC_DIR                  Path to "doc" of Qt4
211 #  QT_MKSPECS_DIR              Path to "mkspecs" of Qt4
212 #                            
214 # The Qt toolkit may contain both debug and release libraries.
215 # In that case, the following library variables will contain both.
216 # You do not need to use these variables if you include QT_USE_FILE,
217 # and use QT_LIBRARIES.
219 #  QT_QT3SUPPORT_LIBRARY            The Qt3Support library
220 #  QT_QTASSISTANT_LIBRARY           The QtAssistant library
221 #  QT_QAXCONTAINER_LIBRARY           The QAxContainer library (Windows only)
222 #  QT_QAXSERVER_LIBRARY                The QAxServer library (Windows only)
223 #  QT_QTCORE_LIBRARY                The QtCore library
224 #  QT_QTDBUS_LIBRARY                The QtDBus library
225 #  QT_QTDESIGNER_LIBRARY            The QtDesigner library
226 #  QT_QTDESIGNERCOMPONENTS_LIBRARY  The QtDesignerComponents library
227 #  QT_QTGUI_LIBRARY                 The QtGui library
228 #  QT_QTMOTIF_LIBRARY               The QtMotif library
229 #  QT_QTNETWORK_LIBRARY             The QtNetwork library
230 #  QT_QTNSPLUGIN_LIBRARY            The QtNsPLugin library
231 #  QT_QTOPENGL_LIBRARY              The QtOpenGL library
232 #  QT_QTSQL_LIBRARY                 The QtSql library
233 #  QT_QTXML_LIBRARY                 The QtXml library
234 #  QT_QTSVG_LIBRARY                 The QtSvg library
235 #  QT_QTSCRIPT_LIBRARY              The QtScript library
236 #  QT_QTTEST_LIBRARY                The QtTest library
237 #  QT_QTMAIN_LIBRARY                The qtmain library for Windows
238 #  QT_QTUITOOLS_LIBRARY             The QtUiTools library
239 #  QT_QTASSISTANTCLIENT_LIBRARY     The QtAssistantClient library
240 #  QT_QTHELP_LIBRARY                The QtHelp library
241 #  QT_QTWEBKIT_LIBRARY              The QtWebKit library
242 #  QT_QTXMLPATTERNS_LIBRARY         The QtXmlPatterns library
243 #  QT_PHONON_LIBRARY                The phonon library
244 #  
245 # also defined, but NOT for general use are
246 #  QT_MOC_EXECUTABLE          Where to find the moc tool.
247 #  QT_UIC_EXECUTABLE          Where to find the uic tool.
248 #  QT_UIC3_EXECUTABLE         Where to find the uic3 tool.
249 #  QT_RCC_EXECUTABLE          Where to find the rcc tool
250 #  QT_DBUSCPP2XML_EXECUTABLE  Where to find the qdbuscpp2xml tool.
251 #  QT_DBUSXML2CPP_EXECUTABLE  Where to find the qdbusxml2cpp tool.
252 #  QT_LUPDATE_EXECUTABLE      Where to find the lupdate tool.
253 #  QT_LRELEASE_EXECUTABLE     Where to find the lrelease tool.
254 #  
256 # These are around for backwards compatibility 
257 # they will be set
258 #  QT_WRAP_CPP  Set true if QT_MOC_EXECUTABLE is found
259 #  QT_WRAP_UI   Set true if QT_UIC_EXECUTABLE is found
260 #  
261 # These variables do _NOT_ have any effect anymore (compared to FindQt.cmake)
262 #  QT_MT_REQUIRED         Qt4 is now always multithreaded
263 #  
264 # These variables are set to "" Because Qt structure changed 
265 # (They make no sense in Qt4)
266 #  QT_QT_LIBRARY        Qt-Library is now split
269 # Use FIND_PACKAGE( Qt4 COMPONENTS ... ) to enable modules
270 IF( Qt4_FIND_COMPONENTS )
271   FOREACH( component ${Qt4_FIND_COMPONENTS} )
272     STRING( TOUPPER ${component} _COMPONENT )
273     SET( QT_USE_${_COMPONENT} 1 )
274   ENDFOREACH( component )
275   
276   # To make sure we don't use QtCore or QtGui when not in COMPONENTS
277   IF(NOT QT_USE_QTCORE)
278     SET( QT_DONT_USE_QTCORE 1 )
279   ENDIF(NOT QT_USE_QTCORE)
280   
281   IF(NOT QT_USE_QTGUI)
282     SET( QT_DONT_USE_QTGUI 1 )
283   ENDIF(NOT QT_USE_QTGUI)
285 ENDIF( Qt4_FIND_COMPONENTS )
287 # If Qt3 has already been found, fail.
288 IF(QT_QT_LIBRARY)
289   IF(Qt4_FIND_REQUIRED)
290     MESSAGE( FATAL_ERROR "Qt3 and Qt4 cannot be used together in one project.")
291   ELSE(Qt4_FIND_REQUIRED)
292     IF(NOT Qt4_FIND_QUIETLY)
293       MESSAGE( STATUS    "Qt3 and Qt4 cannot be used together in one project.")
294     ENDIF(NOT Qt4_FIND_QUIETLY)
295     RETURN()
296   ENDIF(Qt4_FIND_REQUIRED)
297 ENDIF(QT_QT_LIBRARY)
300 INCLUDE(CheckSymbolExists)
301 INCLUDE(MacroAddFileDependencies)
303 SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake)
305 SET( QT_DEFINITIONS "")
307 SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE)
309 #  macro for asking qmake to process pro files
310 MACRO(QT_QUERY_QMAKE outvar invar)
311   IF(QT_QMAKE_EXECUTABLE)
312   FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake/tmp.pro
313     "message(CMAKE_MESSAGE<$$${invar}>)")
315   # Invoke qmake with the tmp.pro program to get the desired
316   # information.  Use the same variable for both stdout and stderr
317   # to make sure we get the output on all platforms.
318   EXECUTE_PROCESS(COMMAND ${QT_QMAKE_EXECUTABLE}
319     WORKING_DIRECTORY  
320     ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake
321     OUTPUT_VARIABLE _qmake_query_output
322     RESULT_VARIABLE _qmake_result
323     ERROR_VARIABLE _qmake_query_output )
324   
325   FILE(REMOVE_RECURSE 
326     "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake")
328   IF(_qmake_result)
329     MESSAGE(WARNING " querying qmake for ${invar}.  qmake reported:\n${_qmake_query_output}")
330   ELSE(_qmake_result)
331     STRING(REGEX REPLACE ".*CMAKE_MESSAGE<([^>]*).*" "\\1" ${outvar} "${_qmake_query_output}")
332   ENDIF(_qmake_result)
334   ENDIF(QT_QMAKE_EXECUTABLE)
335 ENDMACRO(QT_QUERY_QMAKE)
337 GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME)
338 # check for qmake
339 FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 PATHS
340   "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
341   "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
342   "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]/bin"
343   $ENV{QTDIR}/bin
346 IF (QT_QMAKE_EXECUTABLE)
348   IF(QT_QMAKE_EXECUTABLE_LAST)
349     STRING(COMPARE NOTEQUAL "${QT_QMAKE_EXECUTABLE_LAST}" "${QT_QMAKE_EXECUTABLE}" QT_QMAKE_CHANGED)
350   ENDIF(QT_QMAKE_EXECUTABLE_LAST)
352   SET(QT_QMAKE_EXECUTABLE_LAST "${QT_QMAKE_EXECUTABLE}" CACHE INTERNAL "" FORCE)
354   SET(QT4_QMAKE_FOUND FALSE)
355   
356   EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
358   # check for qt3 qmake and then try and find qmake4 or qmake-qt4 in the path
359   IF("${QTVERSION}" MATCHES "Unknown")
360     SET(QT_QMAKE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE)
361     FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 PATHS
362       "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
363       "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
364       $ENV{QTDIR}/bin
365       )
366     IF(QT_QMAKE_EXECUTABLE)
367       EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} 
368         ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
369     ENDIF(QT_QMAKE_EXECUTABLE)
370   ENDIF("${QTVERSION}" MATCHES "Unknown")
372   # check that we found the Qt4 qmake, Qt3 qmake output won't match here
373   STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" qt_version_tmp "${QTVERSION}")
374   IF (qt_version_tmp)
376     # we need at least version 4.0.0
377     IF (NOT QT_MIN_VERSION)
378       SET(QT_MIN_VERSION "4.0.0")
379     ENDIF (NOT QT_MIN_VERSION)
381     #now parse the parts of the user given version string into variables
382     STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" req_qt_major_vers "${QT_MIN_VERSION}")
383     IF (NOT req_qt_major_vers)
384       MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"4.0.1\"")
385     ENDIF (NOT req_qt_major_vers)
387     # now parse the parts of the user given version string into variables
388     STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}")
389     STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers "${QT_MIN_VERSION}")
390     STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}")
392   # Suppport finding at least a particular version, for instance FIND_PACKAGE( Qt4 4.4.3 )
393   # This implementation is a hack to avoid duplicating code and make sure we stay
394   # source-compatible with CMake 2.6.x
395   # For CMake 2.8, we should not set QT_MIN_VERSION but only use Qt4_FIND_VERSION_MAJOR,
396   # Qt4_FIND_VERSION_MINOR, etc
397   IF( Qt4_FIND_VERSION )
398     SET( QT_MIN_VERSION ${Qt4_FIND_VERSION} )
399     SET( req_qt_major_vers ${Qt4_FIND_VERSION_MAJOR} )
400     SET( req_qt_minor_vers ${Qt4_FIND_VERSION_MINOR} )
401     SET( req_qt_patch_vers ${Qt4_FIND_VERSION_PATCH} )
402   ENDIF( Qt4_FIND_VERSION )
404     IF (NOT req_qt_major_vers EQUAL 4)
405       MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", major version 4 is required, e.g. \"4.0.1\"")
406     ENDIF (NOT req_qt_major_vers EQUAL 4)
408     # and now the version string given by qmake
409     STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" QT_VERSION_MAJOR "${QTVERSION}")
410     STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" QT_VERSION_MINOR "${QTVERSION}")
411     STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" QT_VERSION_PATCH "${QTVERSION}")
413     # compute an overall version number which can be compared at once
414     MATH(EXPR req_vers "${req_qt_major_vers}*10000 + ${req_qt_minor_vers}*100 + ${req_qt_patch_vers}")
415     MATH(EXPR found_vers "${QT_VERSION_MAJOR}*10000 + ${QT_VERSION_MINOR}*100 + ${QT_VERSION_PATCH}")
417   # Support finding *exactly* a particular version, for instance FIND_PACKAGE( Qt4 4.4.3 EXACT )
418   # The 'else' branch should be removed for CMake 2.8
419   IF( Qt4_FIND_VERSION_EXACT )
420     IF(found_vers EQUAL req_vers)
421       SET( QT4_QMAKE_FOUND TRUE )
422     ELSE(found_vers EQUAL req_vers)
423       SET( QT4_QMAKE_FOUND FALSE )
424       IF (found_vers LESS req_vers)
425         SET(QT4_INSTALLED_VERSION_TOO_OLD TRUE)
426       ELSE (found_vers LESS req_vers)
427         SET(QT4_INSTALLED_VERSION_TOO_NEW TRUE)
428       ENDIF (found_vers LESS req_vers)
429     ENDIF(found_vers EQUAL req_vers)
430   ELSE( Qt4_FIND_VERSION_EXACT )
431     IF (found_vers LESS req_vers)
432       SET(QT4_QMAKE_FOUND FALSE)
433       SET(QT4_INSTALLED_VERSION_TOO_OLD TRUE)
434     ELSE (found_vers LESS req_vers)
435       SET(QT4_QMAKE_FOUND TRUE)
436     ENDIF (found_vers LESS req_vers)
437   ENDIF( Qt4_FIND_VERSION_EXACT )
438   ENDIF (qt_version_tmp)
440 ENDIF (QT_QMAKE_EXECUTABLE)
442 IF (QT4_QMAKE_FOUND)
444   # ask qmake for the library dir
445   # Set QT_LIBRARY_DIR
446   IF (NOT QT_LIBRARY_DIR OR QT_QMAKE_CHANGED)
447     EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
448       ARGS "-query QT_INSTALL_LIBS"
449       OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP )
450     # make sure we have / and not \ as qmake gives on windows
451     FILE(TO_CMAKE_PATH "${QT_LIBRARY_DIR_TMP}" QT_LIBRARY_DIR_TMP)
452     IF(EXISTS "${QT_LIBRARY_DIR_TMP}")
453       SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir" FORCE)
454     ELSE(EXISTS "${QT_LIBRARY_DIR_TMP}")
455       MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}")
456       MESSAGE("Warning: ${QT_LIBRARY_DIR_TMP} does NOT exist, Qt must NOT be installed correctly.")
457     ENDIF(EXISTS "${QT_LIBRARY_DIR_TMP}")
458   ENDIF(NOT QT_LIBRARY_DIR OR QT_QMAKE_CHANGED)
459   
460   IF (APPLE)
461     IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
462       SET(QT_USE_FRAMEWORKS ON
463         CACHE BOOL "Set to ON if Qt build uses frameworks." FORCE)
464     ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
465       SET(QT_USE_FRAMEWORKS OFF
466         CACHE BOOL "Set to ON if Qt build uses frameworks." FORCE)
467     ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
468     
469     MARK_AS_ADVANCED(QT_USE_FRAMEWORKS)
470   ENDIF (APPLE)
471   
472   # ask qmake for the binary dir
473   IF ((QT_LIBRARY_DIR AND NOT QT_BINARY_DIR) OR QT_QMAKE_CHANGED)
474      EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE}
475        ARGS "-query QT_INSTALL_BINS"
476        OUTPUT_VARIABLE qt_bins )
477      # make sure we have / and not \ as qmake gives on windows
478      FILE(TO_CMAKE_PATH "${qt_bins}" qt_bins)
479      SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "" FORCE)
480   ENDIF ((QT_LIBRARY_DIR AND NOT QT_BINARY_DIR) OR QT_QMAKE_CHANGED)
482   # ask qmake for the include dir
483   IF ((QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR) OR QT_QMAKE_CHANGED)
484       EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
485         ARGS "-query QT_INSTALL_HEADERS" 
486         OUTPUT_VARIABLE qt_headers ) 
487       # make sure we have / and not \ as qmake gives on windows
488       FILE(TO_CMAKE_PATH "${qt_headers}" qt_headers)
489       SET(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "" FORCE)
490   ENDIF ((QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR) OR QT_QMAKE_CHANGED)
493   # ask qmake for the documentation directory
494   IF ((QT_LIBRARY_DIR AND NOT QT_DOC_DIR) OR QT_QMAKE_CHANGED)
495     EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
496       ARGS "-query QT_INSTALL_DOCS"
497       OUTPUT_VARIABLE qt_doc_dir )
498     # make sure we have / and not \ as qmake gives on windows
499     FILE(TO_CMAKE_PATH "${qt_doc_dir}" qt_doc_dir)
500     SET(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs" FORCE)
501   ENDIF ((QT_LIBRARY_DIR AND NOT QT_DOC_DIR) OR QT_QMAKE_CHANGED)
503   # ask qmake for the mkspecs directory
504   IF ((QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR) OR QT_QMAKE_CHANGED)
505     EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
506       ARGS "-query QMAKE_MKSPECS"
507       OUTPUT_VARIABLE qt_mkspecs_dirs )
508     # do not replace : on windows as it might be a drive letter
509     # and windows should already use ; as a separator
510     IF(UNIX)
511       STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}")
512     ENDIF(UNIX)
513     SET(QT_MKSPECS_DIR NOTFOUND)
514     FIND_PATH(QT_MKSPECS_DIR qconfig.pri PATHS ${qt_mkspecs_dirs}
515       DOC "The location of the Qt mkspecs containing qconfig.pri"
516       NO_DEFAULT_PATH )
517   ENDIF ((QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR) OR QT_QMAKE_CHANGED)
519   # ask qmake for the plugins directory
520   IF ((QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR) OR QT_QMAKE_CHANGED)
521     EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
522       ARGS "-query QT_INSTALL_PLUGINS"
523       OUTPUT_VARIABLE qt_plugins_dir )
524     # make sure we have / and not \ as qmake gives on windows
525     FILE(TO_CMAKE_PATH "${qt_plugins_dir}" qt_plugins_dir)
526     SET(QT_PLUGINS_DIR ${qt_plugins_dir} CACHE PATH "The location of the Qt plugins" FORCE)
527   ENDIF ((QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR) OR QT_QMAKE_CHANGED)
529   # ask qmake for the translations directory
530   IF ((QT_LIBRARY_DIR AND NOT QT_TRANSLATIONS_DIR) OR QT_QMAKE_CHANGED)
531     EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
532       ARGS "-query QT_INSTALL_TRANSLATIONS"
533       OUTPUT_VARIABLE qt_translations_dir )
534     # make sure we have / and not \ as qmake gives on windows
535     FILE(TO_CMAKE_PATH "${qt_translations_dir}" qt_translations_dir)
536     SET(QT_TRANSLATIONS_DIR ${qt_translations_dir} CACHE PATH "The location of the Qt translations" FORCE)
537   ENDIF ((QT_LIBRARY_DIR AND NOT QT_TRANSLATIONS_DIR) OR QT_QMAKE_CHANGED)
539   ########################################
540   #
541   #       Setting the INCLUDE-Variables
542   #
543   ########################################
545   SET(QT_MODULES QtCore QtGui Qt3Support QtSvg QtScript QtTest QtUiTools 
546                  QtHelp QtWebKit QtXmlPatterns phonon QtMotif QtNetwork 
547                  QtNsPlugin QtOpenGL QtSql QtXml QtDesigner QtDBus)
549   IF(QT_QMAKE_CHANGED)
550     FOREACH(QT_MODULE ${QT_MODULES})
551       STRING(TOUPPER ${QT_MODULE} _upper_qt_module)
552       SET(QT_${_upper_qt_module}_INCLUDE_DIR NOTFOUND)
553       SET(QT_${_upper_qt_module}_LIBRARY_RELEASE NOTFOUND)
554       SET(QT_${_upper_qt_module}_LIBRARY_DEBUG NOTFOUND)
555     ENDFOREACH(QT_MODULE)
556     SET(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR NOTFOUND)
557     SET(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NOTFOUND)
558     SET(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NOTFOUND)
559     SET(QT_QTASSISTANTCLIENT_INCLUDE_DIR NOTFOUND)
560     SET(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NOTFOUND)
561     SET(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NOTFOUND)
562     SET(QT_QTASSISTANT_INCLUDE_DIR NOTFOUND)
563     SET(QT_QTASSISTANT_LIBRARY_RELEASE NOTFOUND)
564     SET(QT_QTASSISTANT_LIBRARY_DEBUG NOTFOUND)
565     SET(QT_QTCLUCENE_LIBRARY_RELEASE NOTFOUND)
566     SET(QT_QTCLUCENE_LIBRARY_DEBUG NOTFOUND)
567     SET(QT_QAXCONTAINER_INCLUDE_DIR NOTFOUND)
568     SET(QT_QAXCONTAINER_LIBRARY_RELEASE NOTFOUND)
569     SET(QT_QAXCONTAINER_LIBRARY_DEBUG NOTFOUND)
570     SET(QT_QAXSERVER_INCLUDE_DIR NOTFOUND)
571     SET(QT_QAXSERVER_LIBRARY_RELEASE NOTFOUND)
572     SET(QT_QAXSERVER_LIBRARY_DEBUG NOTFOUND)
573     IF(WIN32)
574       SET(QT_QTMAIN_LIBRARY_DEBUG NOTFOUND)
575       SET(QT_QTMAIN_LIBRARY_RELEASE NOTFOUND)
576     ENDIF(WIN32)
577   ENDIF(QT_QMAKE_CHANGED)
579   FOREACH(QT_MODULE ${QT_MODULES})
580     STRING(TOUPPER ${QT_MODULE} _upper_qt_module)
581     FIND_PATH(QT_${_upper_qt_module}_INCLUDE_DIR ${QT_MODULE}
582               PATHS
583               ${QT_HEADERS_DIR}/${QT_MODULE}
584               ${QT_LIBRARY_DIR}/${QT_MODULE}.framework/Headers
585               NO_DEFAULT_PATH
586       )
587   ENDFOREACH(QT_MODULE)
588   
589   IF(WIN32)
590     SET(QT_MODULES ${QT_MODULES} QAxContainer QAxServer)
591     # Set QT_AXCONTAINER_INCLUDE_DIR and QT_AXSERVER_INCLUDE_DIR
592     FIND_PATH(QT_QAXCONTAINER_INCLUDE_DIR ActiveQt
593       PATHS
594       ${QT_HEADERS_DIR}/ActiveQt
595       NO_DEFAULT_PATH
596       )
597     FIND_PATH(QT_QAXSERVER_INCLUDE_DIR ActiveQt
598       PATHS
599       ${QT_HEADERS_DIR}/ActiveQt
600       NO_DEFAULT_PATH
601       )
602   ENDIF(WIN32)
603   
604   # Set QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR
605   FIND_PATH(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR QDesignerComponents
606     PATHS
607     ${QT_HEADERS_DIR}/QtDesigner
608     ${QT_LIBRARY_DIR}/QtDesigner.framework/Headers
609     NO_DEFAULT_PATH
610     )
611   
612   # Set QT_QTASSISTANT_INCLUDE_DIR
613   FIND_PATH(QT_QTASSISTANT_INCLUDE_DIR QAssistantClient
614     PATHS
615     ${QT_HEADERS_DIR}/QtAssistant
616     ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers
617     NO_DEFAULT_PATH
618     )
619   
620   # Set QT_QTASSISTANTCLIENT_INCLUDE_DIR
621   FIND_PATH(QT_QTASSISTANTCLIENT_INCLUDE_DIR QAssistantClient
622     PATHS
623     ${QT_HEADERS_DIR}/QtAssistant
624     ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers
625     NO_DEFAULT_PATH
626     )
627   
628   # Set QT_INCLUDE_DIR by removine "/QtCore" in the string ${QT_QTCORE_INCLUDE_DIR}
629   IF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
630     IF (QT_USE_FRAMEWORKS)
631       SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR})
632     ELSE (QT_USE_FRAMEWORKS)
633       STRING( REGEX REPLACE "/QtCore$" "" qt4_include_dir ${QT_QTCORE_INCLUDE_DIR})
634       SET( QT_INCLUDE_DIR ${qt4_include_dir})
635     ENDIF (QT_USE_FRAMEWORKS)
636   ENDIF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
638   IF( NOT QT_INCLUDE_DIR)
639     IF(Qt4_FIND_REQUIRED)
640       MESSAGE( FATAL_ERROR "Could NOT find QtCore header")
641     ENDIF(Qt4_FIND_REQUIRED)
642   ENDIF( NOT QT_INCLUDE_DIR)
643   
644   # Make variables changeble to the advanced user
645   MARK_AS_ADVANCED( QT_LIBRARY_DIR QT_INCLUDE_DIR QT_DOC_DIR QT_MKSPECS_DIR
646                     QT_PLUGINS_DIR QT_TRANSLATIONS_DIR)
648   # Set QT_INCLUDES
649   SET( QT_INCLUDES ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} )
652   #############################################
653   #
654   # Find out what window system we're using
655   #
656   #############################################
657   # Save required variable
658   SET(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
659   SET(CMAKE_REQUIRED_FLAGS_SAVE    ${CMAKE_REQUIRED_FLAGS})
660   # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES
661   SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}")
662   # On Mac OS X when Qt has framework support, also add the framework path
663   IF( QT_USE_FRAMEWORKS )
664     SET(CMAKE_REQUIRED_FLAGS "-F${QT_LIBRARY_DIR} ")
665   ENDIF( QT_USE_FRAMEWORKS )
666   # Check for Window system symbols (note: only one should end up being set)
667   CHECK_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11)
668   CHECK_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN)
669   CHECK_SYMBOL_EXISTS(Q_WS_QWS "QtCore/qglobal.h" Q_WS_QWS)
670   CHECK_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC)
671   IF(Q_WS_MAC)
672     IF(QT_QMAKE_CHANGED)
673       UNSET(QT_MAC_USE_COCOA CACHE)
674     ENDIF(QT_QMAKE_CHANGED)
675     CHECK_SYMBOL_EXISTS(QT_MAC_USE_COCOA "QtCore/qconfig.h" QT_MAC_USE_COCOA)
676   ENDIF(Q_WS_MAC)
678   IF (QT_QTCOPY_REQUIRED)
679      CHECK_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY)
680      IF (NOT QT_IS_QTCOPY)
681         MESSAGE(FATAL_ERROR "qt-copy is required, but hasn't been found")
682      ENDIF (NOT QT_IS_QTCOPY)
683   ENDIF (QT_QTCOPY_REQUIRED)
685   # Restore CMAKE_REQUIRED_INCLUDES and CMAKE_REQUIRED_FLAGS variables
686   SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
687   SET(CMAKE_REQUIRED_FLAGS    ${CMAKE_REQUIRED_FLAGS_SAVE})
688   #
689   #############################################
691   
692   # find the libraries
693   FOREACH(QT_MODULE ${QT_MODULES})
694     STRING(TOUPPER ${QT_MODULE} _upper_qt_module)
695     FIND_LIBRARY(QT_${_upper_qt_module}_LIBRARY_RELEASE 
696                  NAMES ${QT_MODULE} ${QT_MODULE}4
697                  PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH
698         )
699     FIND_LIBRARY(QT_${_upper_qt_module}_LIBRARY_DEBUG 
700                  NAMES ${QT_MODULE}_debug ${QT_MODULE}d ${QT_MODULE}d4
701                  PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH
702         )
703   ENDFOREACH(QT_MODULE)
705   # QtUiTools not with other frameworks with binary installation (in /usr/lib)
706   IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE)
707     FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools PATHS ${QT_LIBRARY_DIR})
708   ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE)
710   IF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE )
711     
712     # try dropping a hint if trying to use Visual Studio with Qt built by mingw
713     IF(QT_LIBRARY_DIR AND MSVC)
714       IF(EXISTS ${QT_LIBRARY_DIR}/libqtmain.a)
715         MESSAGE( FATAL_ERROR "It appears you're trying to use Visual Studio with Qt built by mingw")
716       ENDIF(EXISTS ${QT_LIBRARY_DIR}/libqtmain.a)
717     ENDIF(QT_LIBRARY_DIR AND MSVC)
719     IF(Qt4_FIND_REQUIRED)
720       MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.")
721     ENDIF(Qt4_FIND_REQUIRED)
722   ENDIF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE )
724   # Set QT_QTDESIGNERCOMPONENTS_LIBRARY
725   FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents QtDesignerComponents4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
726   FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG   NAMES QtDesignerComponents_debug QtDesignerComponentsd QtDesignerComponentsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
728   # Set QT_QTMAIN_LIBRARY
729   IF(WIN32)
730     FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain PATHS ${QT_LIBRARY_DIR}
731       NO_DEFAULT_PATH)
732     FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmaind PATHS ${QT_LIBRARY_DIR}
733       NO_DEFAULT_PATH)
734   ENDIF(WIN32)
735   
736   # Set QT_QTASSISTANTCLIENT_LIBRARY
737   FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NAMES QtAssistantClient QtAssistantClient4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
738   FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG   NAMES QtAssistantClient_debug QtAssistantClientd QtAssistantClientd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
739   
740   # Set QT_QTASSISTANT_LIBRARY
741   FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient QtAssistantClient4 QtAssistant QtAssistant4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
742   FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG   NAMES QtAssistantClient_debug QtAssistantClientd QtAssistantClientd4 QtAssistant_debug QtAssistantd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
744   # Set QT_QTHELP_LIBRARY
745   FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene QtCLucene4 PATHS ${QT_LIBRARY_DIR}        NO_DEFAULT_PATH)
746   FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_DEBUG   NAMES QtCLucene_debug QtCLucened QtCLucened4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
747   # QtCLucene not with other frameworks with binary installation (in /usr/lib)
748   IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE)
749     FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene PATHS ${QT_LIBRARY_DIR})
750   ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE)
752   ############################################
753   #
754   # Check the existence of the libraries.
755   #
756   ############################################
758   MACRO (_QT4_ADJUST_LIB_VARS basename)
759     IF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG)
761       # if only the release version was found, set the debug variable also to the release version
762       IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
763         SET(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE})
764         SET(QT_${basename}_LIBRARY       ${QT_${basename}_LIBRARY_RELEASE})
765         SET(QT_${basename}_LIBRARIES     ${QT_${basename}_LIBRARY_RELEASE})
766       ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
768       # if only the debug version was found, set the release variable also to the debug version
769       IF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE)
770         SET(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG})
771         SET(QT_${basename}_LIBRARY         ${QT_${basename}_LIBRARY_DEBUG})
772         SET(QT_${basename}_LIBRARIES       ${QT_${basename}_LIBRARY_DEBUG})
773       ENDIF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE)
775       IF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
776         # if the generator supports configuration types then set
777         # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
778         IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
779           SET(QT_${basename}_LIBRARY       optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
780         ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
781           # if there are no configuration types and CMAKE_BUILD_TYPE has no value
782           # then just use the release libraries
783           SET(QT_${basename}_LIBRARY       ${QT_${basename}_LIBRARY_RELEASE} )
784         ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
785         SET(QT_${basename}_LIBRARIES       optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
786       ENDIF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
788       IF(QT_QMAKE_CHANGED)
789         SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE STRING "The Qt ${basename} library" FORCE)
790       ELSE(QT_QMAKE_CHANGED)
791         SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE STRING "The Qt ${basename} library")
792       ENDIF(QT_QMAKE_CHANGED)
794       IF (QT_${basename}_LIBRARY)
795         SET(QT_${basename}_FOUND 1)
796       ENDIF (QT_${basename}_LIBRARY)
798     ENDIF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG)
800     IF (QT_${basename}_INCLUDE_DIR)
801       #add the include directory to QT_INCLUDES
802       SET(QT_INCLUDES "${QT_${basename}_INCLUDE_DIR}" ${QT_INCLUDES})
803     ENDIF (QT_${basename}_INCLUDE_DIR)
805     # Make variables changeble to the advanced user
806     MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR)
807   ENDMACRO (_QT4_ADJUST_LIB_VARS)
810   # Set QT_xyz_LIBRARY variable and add 
811   # library include path to QT_INCLUDES
812   _QT4_ADJUST_LIB_VARS(QTCORE)
813   _QT4_ADJUST_LIB_VARS(QTGUI)
814   _QT4_ADJUST_LIB_VARS(QT3SUPPORT)
815   _QT4_ADJUST_LIB_VARS(QTASSISTANT)
816   _QT4_ADJUST_LIB_VARS(QTDESIGNER)
817   _QT4_ADJUST_LIB_VARS(QTDESIGNERCOMPONENTS)
818   _QT4_ADJUST_LIB_VARS(QTNETWORK)
819   _QT4_ADJUST_LIB_VARS(QTNSPLUGIN)
820   _QT4_ADJUST_LIB_VARS(QTOPENGL)
821   _QT4_ADJUST_LIB_VARS(QTSQL)
822   _QT4_ADJUST_LIB_VARS(QTXML)
823   _QT4_ADJUST_LIB_VARS(QTSVG)
824   _QT4_ADJUST_LIB_VARS(QTSCRIPT)
825   _QT4_ADJUST_LIB_VARS(QTUITOOLS)
826   _QT4_ADJUST_LIB_VARS(QTTEST)
827   _QT4_ADJUST_LIB_VARS(QTDBUS)
828   _QT4_ADJUST_LIB_VARS(QTASSISTANTCLIENT)
829   _QT4_ADJUST_LIB_VARS(QTHELP)
830   _QT4_ADJUST_LIB_VARS(QTWEBKIT)
831   _QT4_ADJUST_LIB_VARS(QTXMLPATTERNS)
832   _QT4_ADJUST_LIB_VARS(PHONON)
833   _QT4_ADJUST_LIB_VARS(QTCLUCENE)
834   _QT4_ADJUST_LIB_VARS(QTMOTIF)
836   # platform dependent libraries
837   IF(WIN32)
838     _QT4_ADJUST_LIB_VARS(QTMAIN)
839     _QT4_ADJUST_LIB_VARS(QAXSERVER)
840     _QT4_ADJUST_LIB_VARS(QAXCONTAINER)
841   ENDIF(WIN32)
842   
844   #######################################
845   #
846   #       Check the executables of Qt 
847   #          ( moc, uic, rcc )
848   #
849   #######################################
852   IF(QT_QMAKE_CHANGED)
853     SET(QT_UIC_EXECUTABLE NOTFOUND)
854     SET(QT_MOC_EXECUTABLE NOTFOUND)
855     SET(QT_UIC3_EXECUTABLE NOTFOUND)
856     SET(QT_RCC_EXECUTABLE NOTFOUND)
857     SET(QT_DBUSCPP2XML_EXECUTABLE NOTFOUND)
858     SET(QT_DBUSXML2CPP_EXECUTABLE NOTFOUND)
859     SET(QT_LUPDATE_EXECUTABLE NOTFOUND)
860     SET(QT_LRELEASE_EXECUTABLE NOTFOUND)
861   ENDIF(QT_QMAKE_CHANGED)
862   
863   FIND_PROGRAM(QT_MOC_EXECUTABLE
864     NAMES moc-qt4 moc
865     PATHS ${QT_BINARY_DIR}
866     NO_DEFAULT_PATH
867     )
869   FIND_PROGRAM(QT_UIC_EXECUTABLE
870     NAMES uic-qt4 uic
871     PATHS ${QT_BINARY_DIR}
872     NO_DEFAULT_PATH
873     )
875   FIND_PROGRAM(QT_UIC3_EXECUTABLE
876     NAMES uic3
877     PATHS ${QT_BINARY_DIR}
878     NO_DEFAULT_PATH
879     )
881   FIND_PROGRAM(QT_RCC_EXECUTABLE 
882     NAMES rcc
883     PATHS ${QT_BINARY_DIR}
884     NO_DEFAULT_PATH
885     )
887   FIND_PROGRAM(QT_DBUSCPP2XML_EXECUTABLE 
888     NAMES qdbuscpp2xml
889     PATHS ${QT_BINARY_DIR}
890     NO_DEFAULT_PATH
891     )
893   FIND_PROGRAM(QT_DBUSXML2CPP_EXECUTABLE 
894     NAMES qdbusxml2cpp
895     PATHS ${QT_BINARY_DIR}
896     NO_DEFAULT_PATH
897     )
899   FIND_PROGRAM(QT_LUPDATE_EXECUTABLE
900     NAMES lupdate-qt4 lupdate
901     PATHS ${QT_BINARY_DIR}
902     NO_DEFAULT_PATH
903     )
905   FIND_PROGRAM(QT_LRELEASE_EXECUTABLE
906     NAMES lrelease-qt4 lrelease
907     PATHS ${QT_BINARY_DIR}
908     NO_DEFAULT_PATH
909     )
911   IF (QT_MOC_EXECUTABLE)
912      SET(QT_WRAP_CPP "YES")
913   ENDIF (QT_MOC_EXECUTABLE)
915   IF (QT_UIC_EXECUTABLE)
916      SET(QT_WRAP_UI "YES")
917   ENDIF (QT_UIC_EXECUTABLE)
921   MARK_AS_ADVANCED( QT_UIC_EXECUTABLE QT_UIC3_EXECUTABLE QT_MOC_EXECUTABLE
922     QT_RCC_EXECUTABLE QT_DBUSXML2CPP_EXECUTABLE QT_DBUSCPP2XML_EXECUTABLE
923     QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE)
925   ######################################
926   #
927   #       Macros for building Qt files
928   #
929   ######################################
931   MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
932     SET(${_qt4_files})
933     SET(${_qt4_options})
934     SET(_QT4_DOING_OPTIONS FALSE)
935     FOREACH(_currentArg ${ARGN})
936       IF ("${_currentArg}" STREQUAL "OPTIONS")
937         SET(_QT4_DOING_OPTIONS TRUE)
938       ELSE ("${_currentArg}" STREQUAL "OPTIONS")
939         IF(_QT4_DOING_OPTIONS) 
940           LIST(APPEND ${_qt4_options} "${_currentArg}")
941         ELSE(_QT4_DOING_OPTIONS)
942           LIST(APPEND ${_qt4_files} "${_currentArg}")
943         ENDIF(_QT4_DOING_OPTIONS)
944       ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
945     ENDFOREACH(_currentArg) 
946   ENDMACRO (QT4_EXTRACT_OPTIONS)
947   
948   # macro used to create the names of output files preserving relative dirs
949   MACRO (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile )
950     STRING(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
951     STRING(LENGTH ${infile} _infileLength)
952     SET(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
953     IF(_infileLength GREATER _binlength)
954       STRING(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
955       IF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
956         FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
957       ELSE(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
958         FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
959       ENDIF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
960     ELSE(_infileLength GREATER _binlength)
961       FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
962     ENDIF(_infileLength GREATER _binlength)
963     SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
964     STRING(REPLACE ".." "__" _outfile ${_outfile})
965     GET_FILENAME_COMPONENT(outpath ${_outfile} PATH)
966     GET_FILENAME_COMPONENT(_outfile ${_outfile} NAME_WE)
967     FILE(MAKE_DIRECTORY ${outpath})
968     SET(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
969   ENDMACRO (QT4_MAKE_OUTPUT_FILE )
971   MACRO (QT4_GET_MOC_FLAGS _moc_flags)
972      SET(${_moc_flags})
973      GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES)
975      FOREACH(_current ${_inc_DIRS})
976         SET(${_moc_flags} ${${_moc_flags}} "-I${_current}")
977      ENDFOREACH(_current ${_inc_DIRS})
978      
979      GET_DIRECTORY_PROPERTY(_defines COMPILE_DEFINITIONS)
980      FOREACH(_current ${_defines})
981         SET(${_moc_flags} ${${_moc_flags}} "-D${_current}")
982      ENDFOREACH(_current ${_defines})
984      IF(Q_WS_WIN)
985        SET(${_moc_flags} ${${_moc_flags}} -DWIN32)
986      ENDIF(Q_WS_WIN)
988   ENDMACRO(QT4_GET_MOC_FLAGS)
990   # helper macro to set up a moc rule
991   MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options)
992     # For Windows, create a parameters file to work around command line length limit
993     IF (WIN32)
994       # Pass the parameters in a file.  Set the working directory to
995       # be that containing the parameters file and reference it by
996       # just the file name.  This is necessary because the moc tool on
997       # MinGW builds does not seem to handle spaces in the path to the
998       # file given with the @ syntax.
999       GET_FILENAME_COMPONENT(_moc_outfile_name "${outfile}" NAME)
1000       GET_FILENAME_COMPONENT(_moc_outfile_dir "${outfile}" PATH)
1001       IF(_moc_outfile_dir)
1002         SET(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
1003       ENDIF(_moc_outfile_dir)
1004       SET (_moc_parameters_file ${outfile}_parameters)
1005       SET (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}")
1006       FILE (REMOVE ${_moc_parameters_file})
1007       FOREACH(arg ${_moc_parameters})
1008         FILE (APPEND ${_moc_parameters_file} "${arg}\n")
1009       ENDFOREACH(arg)
1010       ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1011                          COMMAND ${QT_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters
1012                          DEPENDS ${infile}
1013                          ${_moc_working_dir}
1014                          VERBATIM)
1015     ELSE (WIN32)     
1016       ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1017                          COMMAND ${QT_MOC_EXECUTABLE}
1018                          ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile}
1019                          DEPENDS ${infile})     
1020     ENDIF (WIN32)
1021   ENDMACRO (QT4_CREATE_MOC_COMMAND)
1023   
1024   MACRO (QT4_GENERATE_MOC infile outfile )
1025      QT4_GET_MOC_FLAGS(moc_flags)
1026      GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE)
1027      QT4_CREATE_MOC_COMMAND(${abs_infile} ${outfile} "${moc_flags}" "")
1028      SET_SOURCE_FILES_PROPERTIES(${outfile} PROPERTIES SKIP_AUTOMOC TRUE)  # dont run automoc on this file
1029   ENDMACRO (QT4_GENERATE_MOC)
1032   # QT4_WRAP_CPP(outfiles inputfile ... )
1034   MACRO (QT4_WRAP_CPP outfiles )
1035     # get include dirs
1036     QT4_GET_MOC_FLAGS(moc_flags)
1037     QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
1039     FOREACH (it ${moc_files})
1040       GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
1041       QT4_MAKE_OUTPUT_FILE(${it} moc_ cxx outfile)
1042       QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_flags}" "${moc_options}")
1043       SET(${outfiles} ${${outfiles}} ${outfile})
1044     ENDFOREACH(it)
1046   ENDMACRO (QT4_WRAP_CPP)
1049   # QT4_WRAP_UI(outfiles inputfile ... )
1051   MACRO (QT4_WRAP_UI outfiles )
1052     QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
1054     FOREACH (it ${ui_files})
1055       GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
1056       GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
1057       SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
1058       ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1059         COMMAND ${QT_UIC_EXECUTABLE}
1060         ARGS ${ui_options} -o ${outfile} ${infile}
1061         MAIN_DEPENDENCY ${infile})
1062       SET(${outfiles} ${${outfiles}} ${outfile})
1063     ENDFOREACH (it)
1065   ENDMACRO (QT4_WRAP_UI)
1068   # QT4_ADD_RESOURCES(outfiles inputfile ... )
1070   MACRO (QT4_ADD_RESOURCES outfiles )
1071     QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN})
1073     FOREACH (it ${rcc_files})
1074       GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
1075       GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
1076       GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
1077       SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
1078       #  parse file for dependencies 
1079       #  all files are absolute paths or relative to the location of the qrc file
1080       FILE(READ "${infile}" _RC_FILE_CONTENTS)
1081       STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
1082       SET(_RC_DEPENDS)
1083       FOREACH(_RC_FILE ${_RC_FILES})
1084         STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
1085         STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}")
1086         IF(NOT _ABS_PATH_INDICATOR)
1087           SET(_RC_FILE "${rc_path}/${_RC_FILE}")
1088         ENDIF(NOT _ABS_PATH_INDICATOR)
1089         SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
1090       ENDFOREACH(_RC_FILE)
1091       ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1092         COMMAND ${QT_RCC_EXECUTABLE}
1093         ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
1094         MAIN_DEPENDENCY ${infile}
1095         DEPENDS ${_RC_DEPENDS})
1096       SET(${outfiles} ${${outfiles}} ${outfile})
1097     ENDFOREACH (it)
1099   ENDMACRO (QT4_ADD_RESOURCES)
1101   MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename)
1102     GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE)
1103     SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
1104     SET(_impl   ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
1105     SET(_moc    ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
1106   
1107     ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1108         COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -p ${_basename} ${_infile}
1109         DEPENDS ${_infile})
1110   
1111     SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
1112     
1113     QT4_GENERATE_MOC(${_header} ${_moc})
1114   
1115     SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
1116     MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
1117   
1118   ENDMACRO(QT4_ADD_DBUS_INTERFACE)
1119   
1120   
1121   MACRO(QT4_ADD_DBUS_INTERFACES _sources)
1122      FOREACH (_current_FILE ${ARGN})
1123         GET_FILENAME_COMPONENT(_infile ${_current_FILE} ABSOLUTE)
1124         # get the part before the ".xml" suffix
1125         STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2" _basename ${_current_FILE})
1126         STRING(TOLOWER ${_basename} _basename)
1127         QT4_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface)
1128      ENDFOREACH (_current_FILE)
1129   ENDMACRO(QT4_ADD_DBUS_INTERFACES)
1130   
1131   
1132   MACRO(QT4_GENERATE_DBUS_INTERFACE _header) # _customName )
1133     SET(_customName "${ARGV1}")
1134     GET_FILENAME_COMPONENT(_in_file ${_header} ABSOLUTE)
1135     GET_FILENAME_COMPONENT(_basename ${_header} NAME_WE)
1136     
1137     IF (_customName)
1138       SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName})
1139     ELSE (_customName)
1140       SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml)
1141     ENDIF (_customName)
1142   
1143     ADD_CUSTOM_COMMAND(OUTPUT ${_target}
1144         COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_in_file} > ${_target}
1145         DEPENDS ${_in_file}
1146     )
1147   ENDMACRO(QT4_GENERATE_DBUS_INTERFACE)
1148   
1149   
1150   MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename )
1151     GET_FILENAME_COMPONENT(_infile ${_xml_file} ABSOLUTE)
1152     
1153     SET(_optionalBasename "${ARGV4}")
1154     IF (_optionalBasename)
1155        SET(_basename ${_optionalBasename} )
1156     ELSE (_optionalBasename)
1157        STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile})
1158        STRING(TOLOWER ${_basename} _basename)
1159     ENDIF (_optionalBasename)
1161     SET(_optionalClassName "${ARGV5}")
1162     SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
1163     SET(_impl   ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
1164     SET(_moc    ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
1166     IF(_optionalClassName)
1167        ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1168           COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
1169           DEPENDS ${_infile}
1170         )
1171     ELSE(_optionalClassName)
1172        ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1173           COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
1174           DEPENDS ${_infile}
1175         )
1176     ENDIF(_optionalClassName)
1178     QT4_GENERATE_MOC(${_header} ${_moc})
1179     SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
1180     MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
1182     SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
1183   ENDMACRO(QT4_ADD_DBUS_ADAPTOR)
1185    MACRO(QT4_AUTOMOC)
1186       QT4_GET_MOC_FLAGS(_moc_INCS)
1188       SET(_matching_FILES )
1189       FOREACH (_current_FILE ${ARGN})
1191          GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
1192          # if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
1193          # This is required to make uic work correctly:
1194          # we need to add generated .cpp files to the sources (to compile them),
1195          # but we cannot let automoc handle them, as the .cpp files don't exist yet when
1196          # cmake is run for the very first time on them -> however the .cpp files might
1197          # exist at a later run. at that time we need to skip them, so that we don't add two
1198          # different rules for the same moc file
1199          GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC)
1201          IF ( NOT _skip AND EXISTS ${_abs_FILE} )
1203             FILE(READ ${_abs_FILE} _contents)
1205             GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH)
1207             STRING(REGEX MATCHALL "# *include +[^ ]+\\.moc[\">]" _match "${_contents}")
1208             IF(_match)
1209                FOREACH (_current_MOC_INC ${_match})
1210                   STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
1211                   GET_FILENAME_COMPONENT(_basename ${_current_MOC} NAME_WE)
1212                   IF(EXISTS ${_abs_PATH}/${_basename}.hpp)
1213                     SET(_header ${_abs_PATH}/${_basename}.hpp)
1214                   ELSE(EXISTS ${_abs_PATH}/${_basename}.hpp)
1215                     SET(_header ${_abs_PATH}/${_basename}.h)
1216                   ENDIF(EXISTS ${_abs_PATH}/${_basename}.hpp)
1217                   SET(_moc    ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
1218                   QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${_moc_INCS}" "")
1219                   MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
1220                ENDFOREACH (_current_MOC_INC)
1221             ENDIF(_match)
1222          ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} )
1223       ENDFOREACH (_current_FILE)
1224    ENDMACRO(QT4_AUTOMOC)
1226    MACRO(QT4_CREATE_TRANSLATION _qm_files)
1227       QT4_EXTRACT_OPTIONS(_lupdate_files _lupdate_options ${ARGN})
1228       SET(_my_sources)
1229       SET(_my_dirs)
1230       SET(_my_tsfiles)
1231       SET(_ts_pro)
1232       FOREACH (_file ${_lupdate_files})
1233          GET_FILENAME_COMPONENT(_ext ${_file} EXT)
1234          GET_FILENAME_COMPONENT(_abs_FILE ${_file} ABSOLUTE)
1235          IF(_ext MATCHES "ts")
1236            LIST(APPEND _my_tsfiles ${_abs_FILE})
1237          ELSE(_ext MATCHES "ts")
1238            IF(NOT _ext)
1239              LIST(APPEND _my_dirs ${_abs_FILE})
1240            ELSE(NOT _ext)
1241              LIST(APPEND _my_sources ${_abs_FILE})
1242            ENDIF(NOT _ext)
1243          ENDIF(_ext MATCHES "ts")
1244       ENDFOREACH(_file)
1245       FOREACH(_ts_file ${_my_tsfiles})
1246         IF(_my_sources)
1247           # make a .pro file to call lupdate on, so we don't make our commands too
1248           # long for some systems
1249           GET_FILENAME_COMPONENT(_ts_name ${_ts_file} NAME_WE)
1250           SET(_ts_pro ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lupdate.pro)
1251           STRING(REPLACE ";" " " _pro_srcs "${_my_sources}")
1252           FILE(WRITE ${_ts_pro} "SOURCES = ${_pro_srcs}")
1253         ENDIF(_my_sources)
1254         ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file}
1255            COMMAND ${QT_LUPDATE_EXECUTABLE}
1256            ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file}
1257            DEPENDS ${_my_sources} ${_ts_pro})
1258       ENDFOREACH(_ts_file)
1259       QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles})
1260    ENDMACRO(QT4_CREATE_TRANSLATION)
1262    MACRO(QT4_ADD_TRANSLATION _qm_files)
1263       FOREACH (_current_FILE ${ARGN})
1264          GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
1265          GET_FILENAME_COMPONENT(qm ${_abs_FILE} NAME_WE)
1266          GET_SOURCE_FILE_PROPERTY(output_location ${_abs_FILE} OUTPUT_LOCATION)
1267          IF(output_location)
1268            FILE(MAKE_DIRECTORY "${output_location}")
1269            SET(qm "${output_location}/${qm}.qm")
1270          ELSE(output_location)
1271            SET(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm")
1272          ENDIF(output_location)
1274          ADD_CUSTOM_COMMAND(OUTPUT ${qm}
1275             COMMAND ${QT_LRELEASE_EXECUTABLE}
1276             ARGS ${_abs_FILE} -qm ${qm}
1277             DEPENDS ${_abs_FILE}
1278          )
1279          SET(${_qm_files} ${${_qm_files}} ${qm})
1280       ENDFOREACH (_current_FILE)
1281    ENDMACRO(QT4_ADD_TRANSLATION)
1287   ######################################
1288   #
1289   #       decide if Qt got found
1290   #
1291   ######################################
1293   # if the includes,libraries,moc,uic and rcc are found then we have it
1294   IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND 
1295       QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE AND QT_QTCORE_LIBRARY)
1296     SET( QT4_FOUND "YES" )
1297     INCLUDE(FindPackageMessage)
1298     FIND_PACKAGE_MESSAGE(Qt4 "Found Qt-Version ${QTVERSION}"
1299       "[${QT_LIBRARY_DIR}][${QT_INCLUDE_DIR}][${QT_MOC_EXECUTABLE}][${QT_UIC_EXECUTABLE}][${QT_RCC_EXECUTABLE}]")
1300   ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND
1301         QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE AND QT_QTCORE_LIBRARY)
1302     SET( QT4_FOUND "NO")
1303     SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1304     IF( Qt4_FIND_REQUIRED)
1305       MESSAGE( FATAL_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!")
1306     ENDIF( Qt4_FIND_REQUIRED)
1307   ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND 
1308          QT_UIC_EXECUTABLE AND  QT_RCC_EXECUTABLE AND QT_QTCORE_LIBRARY)
1309   
1310   SET(QT_FOUND ${QT4_FOUND})
1313   #######################################
1314   #
1315   #       Qt configuration
1316   #
1317   #######################################
1318   IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
1319     FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents)
1320     STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG "${_qconfig_FILE_contents}")
1321     STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG "${_qconfig_FILE_contents}")
1322     STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION "${_qconfig_FILE_contents}")
1323   ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
1324   IF("${QT_EDITION}" MATCHES "DesktopLight")
1325     SET(QT_EDITION_DESKTOPLIGHT 1)
1326   ENDIF("${QT_EDITION}" MATCHES "DesktopLight")
1328   
1329   ###############################################
1330   #
1331   #       configuration/system dependent settings  
1332   #
1333   ###############################################
1334   
1335   # find dependencies for some Qt modules
1336   # when doing builds against a static Qt, they are required
1337   # when doing builds against a shared Qt, they are sometimes not required
1338   # even some Linux distros do not require these dependencies
1339   # if a user needs the dependencies, and they couldn't be found, they can set
1340   # the variables themselves.
1342   SET(QT_QTGUI_LIB_DEPENDENCIES "")
1343   SET(QT_QTCORE_LIB_DEPENDENCIES "")
1344   SET(QT_QTNETWORK_LIB_DEPENDENCIES "")
1345   SET(QT_QTOPENGL_LIB_DEPENDENCIES "")
1346   SET(QT_QTDBUS_LIB_DEPENDENCIES "")
1347   SET(QT_QTHELP_LIB_DEPENDENCIES ${QT_QTCLUCENE_LIBRARY})
1348   
1349   # build using shared Qt needs -DQT_DLL
1350   IF(NOT QT_CONFIG MATCHES "static")
1351     # warning currently only qconfig.pri on Windows potentially contains "static"
1352     # so QT_DLL might not get defined properly on other platforms.
1353     SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_DLL)
1354   ENDIF(NOT QT_CONFIG MATCHES "static")
1355   
1356   # QtOpenGL dependencies
1357   QT_QUERY_QMAKE(QMAKE_LIBS_OPENGL "QMAKE_LIBS_OPENGL")
1358   SET (QT_QTOPENGL_LIB_DEPENDENCIES ${QT_QTOPENGL_LIB_DEPENDENCIES} ${QMAKE_LIBS_OPENGL})
1359   
1360   ## system png
1361   IF(QT_QCONFIG MATCHES "system-png")
1362     FIND_LIBRARY(QT_PNG_LIBRARY NAMES png)
1363     MARK_AS_ADVANCED(QT_PNG_LIBRARY)
1364     IF(QT_PNG_LIBRARY)
1365       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY})
1366     ENDIF(QT_PNG_LIBRARY)
1367   ENDIF(QT_QCONFIG MATCHES "system-png")
1368   
1369   # for X11, get X11 library directory
1370   IF(Q_WS_X11)
1371     QT_QUERY_QMAKE(QMAKE_LIBDIR_X11 "QMAKE_LIBDIR_X11")
1372   ENDIF(Q_WS_X11)
1374   ## X11 SM
1375   IF(QT_QCONFIG MATCHES "x11sm")
1376     # ask qmake where the x11 libs are
1377     FIND_LIBRARY(QT_X11_SM_LIBRARY NAMES SM PATHS ${QMAKE_LIBDIR_X11})
1378     FIND_LIBRARY(QT_X11_ICE_LIBRARY NAMES ICE PATHS ${QMAKE_LIBDIR_X11})
1379     MARK_AS_ADVANCED(QT_X11_SM_LIBRARY)
1380     MARK_AS_ADVANCED(QT_X11_ICE_LIBRARY)
1381     IF(QT_X11_SM_LIBRARY AND QT_X11_ICE_LIBRARY)
1382       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_X11_SM_LIBRARY} ${QT_X11_ICE_LIBRARY})
1383     ENDIF(QT_X11_SM_LIBRARY AND QT_X11_ICE_LIBRARY)
1384   ENDIF(QT_QCONFIG MATCHES "x11sm")
1385   
1386   ## Xi
1387   IF(QT_QCONFIG MATCHES "tablet")
1388     FIND_LIBRARY(QT_XI_LIBRARY NAMES Xi PATHS ${QMAKE_LIBDIR_X11})
1389     MARK_AS_ADVANCED(QT_XI_LIBRARY)
1390     IF(QT_XI_LIBRARY)
1391       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XI_LIBRARY})
1392     ENDIF(QT_XI_LIBRARY)
1393   ENDIF(QT_QCONFIG MATCHES "tablet")
1395   ## Xrender
1396   IF(QT_QCONFIG MATCHES "xrender")
1397     FIND_LIBRARY(QT_XRENDER_LIBRARY NAMES Xrender PATHS ${QMAKE_LIBDIR_X11})
1398     MARK_AS_ADVANCED(QT_XRENDER_LIBRARY)
1399     IF(QT_XRENDER_LIBRARY)
1400       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRENDER_LIBRARY})
1401     ENDIF(QT_XRENDER_LIBRARY)
1402   ENDIF(QT_QCONFIG MATCHES "xrender")
1403   
1404   ## Xrandr
1405   IF(QT_QCONFIG MATCHES "xrandr")
1406     FIND_LIBRARY(QT_XRANDR_LIBRARY NAMES Xrandr PATHS ${QMAKE_LIBDIR_X11})
1407     MARK_AS_ADVANCED(QT_XRANDR_LIBRARY)
1408     IF(QT_XRANDR_LIBRARY)
1409       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRANDR_LIBRARY})
1410     ENDIF(QT_XRANDR_LIBRARY)
1411   ENDIF(QT_QCONFIG MATCHES "xrandr")
1412   
1413   ## Xcursor
1414   IF(QT_QCONFIG MATCHES "xcursor")
1415     FIND_LIBRARY(QT_XCURSOR_LIBRARY NAMES Xcursor PATHS ${QMAKE_LIBDIR_X11})
1416     MARK_AS_ADVANCED(QT_XCURSOR_LIBRARY)
1417     IF(QT_XCURSOR_LIBRARY)
1418       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XCURSOR_LIBRARY})
1419     ENDIF(QT_XCURSOR_LIBRARY)
1420   ENDIF(QT_QCONFIG MATCHES "xcursor")
1421   
1422   ## Xinerama
1423   IF(QT_QCONFIG MATCHES "xinerama")
1424     FIND_LIBRARY(QT_XINERAMA_LIBRARY NAMES Xinerama PATHS ${QMAKE_LIBDIR_X11})
1425     MARK_AS_ADVANCED(QT_XINERAMA_LIBRARY)
1426     IF(QT_XINERAMA_LIBRARY)
1427       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XINERAMA_LIBRARY})
1428     ENDIF(QT_XINERAMA_LIBRARY)
1429   ENDIF(QT_QCONFIG MATCHES "xinerama")
1430   
1431   ## Xfixes
1432   IF(QT_QCONFIG MATCHES "xfixes")
1433     FIND_LIBRARY(QT_XFIXES_LIBRARY NAMES Xfixes PATHS ${QMAKE_LIBDIR_X11})
1434     MARK_AS_ADVANCED(QT_XFIXES_LIBRARY)
1435     IF(QT_XFIXES_LIBRARY)
1436       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XFIXES_LIBRARY})
1437     ENDIF(QT_XFIXES_LIBRARY)
1438   ENDIF(QT_QCONFIG MATCHES "xfixes")
1439   
1440   ## system-freetype
1441   IF(QT_QCONFIG MATCHES "system-freetype")
1442     FIND_LIBRARY(QT_FREETYPE_LIBRARY NAMES freetype)
1443     MARK_AS_ADVANCED(QT_FREETYPE_LIBRARY)
1444     IF(QT_FREETYPE_LIBRARY)
1445       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY})
1446     ENDIF(QT_FREETYPE_LIBRARY)
1447   ENDIF(QT_QCONFIG MATCHES "system-freetype")
1448   
1449   ## fontconfig
1450   IF(QT_QCONFIG MATCHES "fontconfig")
1451     FIND_LIBRARY(QT_FONTCONFIG_LIBRARY NAMES fontconfig)
1452     MARK_AS_ADVANCED(QT_FONTCONFIG_LIBRARY)
1453     IF(QT_FONTCONFIG_LIBRARY)
1454       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY})
1455     ENDIF(QT_FONTCONFIG_LIBRARY)
1456   ENDIF(QT_QCONFIG MATCHES "fontconfig")
1457   
1458   ## system-zlib
1459   IF(QT_QCONFIG MATCHES "system-zlib")
1460     FIND_LIBRARY(QT_ZLIB_LIBRARY NAMES z)
1461     MARK_AS_ADVANCED(QT_ZLIB_LIBRARY)
1462     IF(QT_ZLIB_LIBRARY)
1463       SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY})
1464     ENDIF(QT_ZLIB_LIBRARY)
1465   ENDIF(QT_QCONFIG MATCHES "system-zlib")
1467   ## openssl
1468   IF(QT_QCONFIG MATCHES "openssl" AND NOT Q_WS_WIN)
1469     FIND_PACKAGE(OpenSSL)
1470     IF(OPENSSL_LIBRARIES)
1471       SET(QT_QTNETWORK_LIB_DEPENDENCIES ${QT_QTNETWORK_LIB_DEPENDENCIES} ${OPENSSL_LIBRARIES})
1472     ENDIF(OPENSSL_LIBRARIES)
1473   ENDIF(QT_QCONFIG MATCHES "openssl" AND NOT Q_WS_WIN)
1474   
1475   ## dbus
1476   IF(QT_QCONFIG MATCHES "dbus")
1478     # if the dbus library isn't found, we'll assume its not required to build
1479     # shared Qt on Linux doesn't require it
1480     IF(NOT QT_DBUS_LIBRARY)
1481       EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L dbus-1
1482         OUTPUT_VARIABLE _dbus_query_output
1483         RESULT_VARIABLE _dbus_result
1484         ERROR_VARIABLE _dbus_query_output )
1485       
1486       IF(_dbus_result MATCHES 0)
1487         STRING(REPLACE "-L" "" _dbus_query_output "${_dbus_query_output}")
1488         SEPARATE_ARGUMENTS(_dbus_query_output)
1489       ELSE(_dbus_result MATCHES 0)
1490         SET(_dbus_query_output)
1491       ENDIF(_dbus_result MATCHES 0)
1493       FIND_LIBRARY(QT_DBUS_LIBRARY NAMES dbus-1 PATHS ${_dbus_query_output} )
1495       IF(QT_DBUS_LIBRARY)
1496         SET(QT_QTDBUS_LIB_DEPENDENCIES ${QT_QTDBUS_LIB_DEPENDENCIES} ${QT_DBUS_LIBRARY})
1497       ENDIF(QT_DBUS_LIBRARY)
1499       MARK_AS_ADVANCED(QT_DBUS_LIBRARY)
1500     ENDIF(NOT QT_DBUS_LIBRARY)
1502   ENDIF(QT_QCONFIG MATCHES "dbus")
1503   
1504   ## glib
1505   IF(QT_QCONFIG MATCHES "glib")
1506     
1507     # if the glib libraries aren't found, we'll assume its not required to build
1508     # shared Qt on Linux doesn't require it
1510     # Qt 4.2.0+ uses glib-2.0
1511     IF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY)
1512       EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L glib-2.0 gthread-2.0
1513         OUTPUT_VARIABLE _glib_query_output
1514         RESULT_VARIABLE _glib_result
1515         ERROR_VARIABLE _glib_query_output )
1517       IF(_glib_result MATCHES 0)
1518         STRING(REPLACE "-L" "" _glib_query_output "${_glib_query_output}")
1519         SEPARATE_ARGUMENTS(_glib_query_output)
1520       ELSE(_glib_result MATCHES 0)
1521         SET(_glib_query_output)
1522       ENDIF(_glib_result MATCHES 0)
1524       FIND_LIBRARY(QT_GLIB_LIBRARY NAMES glib-2.0 PATHS ${_glib_query_output} )
1525       FIND_LIBRARY(QT_GTHREAD_LIBRARY NAMES gthread-2.0 PATHS ${_glib_query_output} )
1526     
1527       MARK_AS_ADVANCED(QT_GLIB_LIBRARY)
1528       MARK_AS_ADVANCED(QT_GTHREAD_LIBRARY)
1529     ENDIF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY)
1531     IF(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY)
1532       SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES}
1533           ${QT_GTHREAD_LIBRARY} ${QT_GLIB_LIBRARY})
1534     ENDIF(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY)
1536   ENDIF(QT_QCONFIG MATCHES "glib")
1537   
1538   ## clock-monotonic, just see if we need to link with rt
1539   IF(QT_QCONFIG MATCHES "clock-monotonic")
1540     SET(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
1541     SET(CMAKE_REQUIRED_LIBRARIES rt)
1542     CHECK_SYMBOL_EXISTS(_POSIX_TIMERS "unistd.h;time.h" QT_POSIX_TIMERS)
1543     SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
1544     IF(QT_POSIX_TIMERS)
1545       FIND_LIBRARY(QT_RT_LIBRARY NAMES rt)
1546       MARK_AS_ADVANCED(QT_RT_LIBRARY)
1547       IF(QT_RT_LIBRARY)
1548         SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_RT_LIBRARY})
1549       ENDIF(QT_RT_LIBRARY)
1550     ENDIF(QT_POSIX_TIMERS)
1551   ENDIF(QT_QCONFIG MATCHES "clock-monotonic")
1552     
1553   IF(Q_WS_X11)
1554     # X11 libraries Qt absolutely depends on
1555     QT_QUERY_QMAKE(QT_LIBS_X11 "QMAKE_LIBS_X11")
1556     SEPARATE_ARGUMENTS(QT_LIBS_X11)
1557     FOREACH(QT_X11_LIB ${QT_LIBS_X11})
1558       STRING(REGEX REPLACE "-l" "" QT_X11_LIB "${QT_X11_LIB}")
1559       SET(QT_TMP_STR "QT_X11_${QT_X11_LIB}_LIBRARY")
1560       FIND_LIBRARY(${QT_TMP_STR} NAMES "${QT_X11_LIB}" PATHS ${QMAKE_LIBDIR_X11})
1561       MARK_AS_ADVANCED(${QT_TMP_STR})
1562       IF(${QT_TMP_STR})
1563         SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${${QT_TMP_STR}})
1564       ENDIF(${QT_TMP_STR})
1565     ENDFOREACH(QT_X11_LIB)
1567     QT_QUERY_QMAKE(QT_LIBS_THREAD "QMAKE_LIBS_THREAD")
1568     SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_LIBS_THREAD})
1569     
1570     QT_QUERY_QMAKE(QMAKE_LIBS_DYNLOAD "QMAKE_LIBS_DYNLOAD")
1571     SET (QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QMAKE_LIBS_DYNLOAD})
1573   ENDIF(Q_WS_X11)
1574   
1575   IF(Q_WS_WIN)
1576     SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} imm32 winmm)
1577     SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ws2_32)
1578   ENDIF(Q_WS_WIN)
1579   
1580   IF(Q_WS_MAC)
1581     SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework Carbon")
1582     
1583     # Qt 4.0, 4.1, 4.2 use QuickTime
1584     IF(QT_VERSION_MINOR LESS 3)
1585       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework QuickTime")
1586     ENDIF(QT_VERSION_MINOR LESS 3)
1587     
1588     # Qt 4.2+ use AppKit
1589     IF(QT_VERSION_MINOR GREATER 1)
1590       SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework AppKit")
1591     ENDIF(QT_VERSION_MINOR GREATER 1)
1593     SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} "-framework ApplicationServices")
1594   ENDIF(Q_WS_MAC)
1596   #######################################
1597   #
1598   #       compatibility settings 
1599   #
1600   #######################################
1601   # Backwards compatibility for CMake1.4 and 1.2
1602   SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} )
1603   SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} )
1605   SET( QT_QT_LIBRARY "")
1607 ELSE(QT4_QMAKE_FOUND)
1608    
1609    SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1610    
1611    # The code below is overly complex to make sure we do not break compatibility with CMake 2.6.x
1612    # For CMake 2.8, it should be simplified by getting rid of QT4_INSTALLED_VERSION_TOO_OLD and 
1613    # QT4_INSTALLED_VERSION_TOO_NEW
1614    IF(Qt4_FIND_REQUIRED)
1615       IF(QT4_INSTALLED_VERSION_TOO_OLD)
1616     IF( Qt4_FIND_VERSION_EXACT )
1617       MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, version ${QT_MIN_VERSION} is required")
1618     ELSE( Qt4_FIND_VERSION_EXACT )
1619       MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1620     ENDIF( Qt4_FIND_VERSION_EXACT )
1621       ELSE(QT4_INSTALLED_VERSION_TOO_OLD)
1622       IF( Qt4_FIND_VERSION_EXACT AND QT4_INSTALLED_VERSION_TOO_NEW )
1623       MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too new, version ${QT_MIN_VERSION} is required")
1624     ELSE( Qt4_FIND_VERSION_EXACT AND QT4_INSTALLED_VERSION_TOO_NEW )
1625       MESSAGE( FATAL_ERROR "Qt qmake not found!")
1626     ENDIF( Qt4_FIND_VERSION_EXACT AND QT4_INSTALLED_VERSION_TOO_NEW )
1627       ENDIF(QT4_INSTALLED_VERSION_TOO_OLD)
1628    ELSE(Qt4_FIND_REQUIRED)
1629       IF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1630          MESSAGE(STATUS "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1631       ENDIF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1632    ENDIF(Qt4_FIND_REQUIRED)
1634 ENDIF (QT4_QMAKE_FOUND)