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. First is
6 # QT_USE_FILE which is the path to a CMake file that can be included to compile
7 # 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:
28 # All the libraries required are stored in a variable called QT_LIBRARIES.
29 # Add this variable to your TARGET_LINK_LIBRARIES.
31 # macro QT4_WRAP_CPP(outfiles inputfile ... OPTIONS ...)
32 # create moc code from a list of files containing Qt class with
33 # the Q_OBJECT declaration. Options may be given to moc, such as those found
34 # when executing "moc -help"
36 # macro QT4_WRAP_UI(outfiles inputfile ... OPTIONS ...)
37 # create code from a list of Qt designer ui files.
38 # Options may be given to uic, such as those found
39 # when executing "uic -help"
41 # macro QT4_ADD_RESOURCES(outfiles inputfile ... OPTIONS ...)
42 # create code from a list of Qt resource files.
43 # Options may be given to rcc, such as those found
44 # when executing "rcc -help"
46 # macro QT4_AUTOMOC(inputfile ... )
47 # macro QT4_GENERATE_MOC(inputfile outputfile )
49 # macro QT4_ADD_DBUS_INTERFACE(outfiles interface basename)
50 # create a the interface header and implementation files with the
51 # given basename from the given interface xml file and add it to
54 # macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... )
55 # create the interface header and implementation files
56 # for all listed interface xml files
57 # the name will be automatically determined from the name of the xml file
59 # macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname [basename] )
60 # create a dbus adaptor (header and implementation file) from the xml file
61 # describing the interface, and add it to the list of sources. The adaptor
62 # forwards the calls to a parent class, defined in parentheader and named
63 # parentclassname. The name of the generated files will be
64 # <basename>adaptor.{cpp,h} where basename is the basename of the xml file.
66 # macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] )
67 # generate the xml interface file from the given header.
68 # If the optional argument interfacename is omitted, the name of the
69 # interface file is constructed from the basename of the header with
70 # the suffix .xml appended.
72 # macro QT4_CREATE_TRANSLATION( qm_files sources ... ts_files ... )
74 # in: sources ts_files
75 # generates commands to create .ts (vie lupdate) and .qm
76 # (via lrelease) - files from sources. The ts files are
77 # created and/or updated in the source tree (unless given with full paths).
78 # The qm files are generated in the build tree.
79 # Updating the translations can be done by adding the qm_files
80 # to the source list of your library/executable, so they are
81 # always updated, or by adding a custom target to control when
82 # they get updated/generated.
84 # macro QT4_ADD_TRANSLATION( qm_files ts_files ... )
87 # generates commands to create .qm from .ts - files. The generated
88 # filenames can be found in qm_files. The ts_files
89 # must exists and are not updated in any way.
92 # QT_FOUND If false, don't try to use Qt.
93 # QT4_FOUND If false, don't try to use Qt 4.
95 # QT_EDITION Set to the edition of Qt (i.e. DesktopLight)
96 # QT_EDITION_DESKTOPLIGHT True if QT_EDITION == DesktopLight
97 # QT_QTCORE_FOUND True if QtCore was found.
98 # QT_QTGUI_FOUND True if QtGui was found.
99 # QT_QT3SUPPORT_FOUND True if Qt3Support was found.
100 # QT_QTASSISTANT_FOUND True if QtAssistant was found.
101 # QT_QTDBUS_FOUND True if QtDBus was found.
102 # QT_QTDESIGNER_FOUND True if QtDesigner was found.
103 # QT_QTDESIGNERCOMPONENTS True if QtDesignerComponents was found.
104 # QT_QTMOTIF_FOUND True if QtMotif was found.
105 # QT_QTNETWORK_FOUND True if QtNetwork was found.
106 # QT_QTNSPLUGIN_FOUND True if QtNsPlugin was found.
107 # QT_QTOPENGL_FOUND True if QtOpenGL was found.
108 # QT_QTSQL_FOUND True if QtSql was found.
109 # QT_QTXML_FOUND True if QtXml was found.
110 # QT_QTSVG_FOUND True if QtSvg was found.
111 # QT_QTSCRIPT_FOUND True if QtScript was found.
112 # QT_QTTEST_FOUND True if QtTest was found.
113 # QT_QTUITOOLS_FOUND True if QtUiTools was found.
115 # QT_DEFINITIONS Definitions to use when compiling code that uses Qt.
117 # QT_INCLUDES List of paths to all include directories of
118 # Qt4 QT_INCLUDE_DIR and QT_QTCORE_INCLUDE_DIR are
119 # always in this variable even if NOTFOUND,
120 # all other INCLUDE_DIRS are
121 # only added if they are found.
123 # QT_INCLUDE_DIR Path to "include" of Qt4
124 # QT_QT_INCLUDE_DIR Path to "include/Qt"
125 # QT_QT3SUPPORT_INCLUDE_DIR Path to "include/Qt3Support"
126 # QT_QTASSISTANT_INCLUDE_DIR Path to "include/QtAssistant"
127 # QT_QTCORE_INCLUDE_DIR Path to "include/QtCore"
128 # QT_QTDESIGNER_INCLUDE_DIR Path to "include/QtDesigner"
129 # QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR Path to "include/QtDesigner"
130 # QT_QTDBUS_INCLUDE_DIR Path to "include/QtDBus"
131 # QT_QTGUI_INCLUDE_DIR Path to "include/QtGui"
132 # QT_QTMOTIF_INCLUDE_DIR Path to "include/QtMotif"
133 # QT_QTNETWORK_INCLUDE_DIR Path to "include/QtNetwork"
134 # QT_QTNSPLUGIN_INCLUDE_DIR Path to "include/QtNsPlugin"
135 # QT_QTOPENGL_INCLUDE_DIR Path to "include/QtOpenGL"
136 # QT_QTSQL_INCLUDE_DIR Path to "include/QtSql"
137 # QT_QTXML_INCLUDE_DIR Path to "include/QtXml"
138 # QT_QTSVG_INCLUDE_DIR Path to "include/QtSvg"
139 # QT_QTSCRIPT_INCLUDE_DIR Path to "include/QtScript"
140 # QT_QTTEST_INCLUDE_DIR Path to "include/QtTest"
142 # QT_LIBRARY_DIR Path to "lib" of Qt4
144 # QT_PLUGINS_DIR Path to "plugins" for Qt4
146 # For every library of Qt there are three variables:
147 # QT_QTFOO_LIBRARY_RELEASE, which contains the full path to the release version, if it exists
148 # QT_QTFOO_LIBRARY_DEBUG, which contains the full path to the debug version, if it exists
149 # QT_QTFOO_LIBRARY, the full path to the release and/or debug version
151 # So there are the following variables:
152 # The Qt3Support library: QT_QT3SUPPORT_LIBRARY
153 # QT_QT3SUPPORT_LIBRARY_RELEASE
154 # QT_QT3SUPPORT_DEBUG
156 # The QtAssistant library: QT_QTASSISTANT_LIBRARY
157 # QT_QTASSISTANT_LIBRARY_RELEASE
158 # QT_QTASSISTANT_LIBRARY_DEBUG
160 # The QtCore library: QT_QTCORE_LIBRARY
161 # QT_QTCORE_LIBRARY_RELEASE
162 # QT_QTCORE_LIBRARY_DEBUG
164 # The QtDBus library: QT_QTDBUS_LIBRARY
165 # QT_QTDBUS_LIBRARY_RELEASE
166 # QT_QTDBUS_LIBRARY_DEBUG
168 # The QtDesigner library: QT_QTDESIGNER_LIBRARY
169 # QT_QTDESIGNER_LIBRARY_RELEASE
170 # QT_QTDESIGNER_LIBRARY_DEBUG
172 # The QtDesignerComponents library: QT_QTDESIGNERCOMPONENTS_LIBRARY
173 # QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE
174 # QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG
176 # The QtGui library: QT_QTGUI_LIBRARY
177 # QT_QTGUI_LIBRARY_RELEASE
178 # QT_QTGUI_LIBRARY_DEBUG
180 # The QtMotif library: QT_QTMOTIF_LIBRARY
181 # QT_QTMOTIF_LIBRARY_RELEASE
182 # QT_QTMOTIF_LIBRARY_DEBUG
184 # The QtNetwork library: QT_QTNETWORK_LIBRARY
185 # QT_QTNETWORK_LIBRARY_RELEASE
186 # QT_QTNETWORK_LIBRARY_DEBUG
188 # The QtNsPLugin library: QT_QTNSPLUGIN_LIBRARY
189 # QT_QTNSPLUGIN_LIBRARY_RELEASE
190 # QT_QTNSPLUGIN_LIBRARY_DEBUG
192 # The QtOpenGL library: QT_QTOPENGL_LIBRARY
193 # QT_QTOPENGL_LIBRARY_RELEASE
194 # QT_QTOPENGL_LIBRARY_DEBUG
196 # The QtSql library: QT_QTSQL_LIBRARY
197 # QT_QTSQL_LIBRARY_RELEASE
198 # QT_QTSQL_LIBRARY_DEBUG
200 # The QtXml library: QT_QTXML_LIBRARY
201 # QT_QTXML_LIBRARY_RELEASE
202 # QT_QTXML_LIBRARY_DEBUG
204 # The QtSvg library: QT_QTSVG_LIBRARY
205 # QT_QTSVG_LIBRARY_RELEASE
206 # QT_QTSVG_LIBRARY_DEBUG
208 # The QtScript library: QT_QTSCRIPT_LIBRARY
209 # QT_QTSCRIPT_LIBRARY_RELEASE
210 # QT_QTSCRIPT_LIBRARY_DEBUG
212 # The QtTest library: QT_QTTEST_LIBRARY
213 # QT_QTTEST_LIBRARY_RELEASE
214 # QT_QTTEST_LIBRARY_DEBUG
216 # The qtmain library for Windows QT_QTMAIN_LIBRARY
217 # QT_QTMAIN_LIBRARY_RELEASE
218 # QT_QTMAIN_LIBRARY_DEBUG
220 # The QtUiTools library: QT_QTUITOOLS_LIBRARY
221 # QT_QTUITOOLS_LIBRARY_RELEASE
222 # QT_QTUITOOLS_LIBRARY_DEBUG
224 # also defined, but NOT for general use are
225 # QT_MOC_EXECUTABLE Where to find the moc tool.
226 # QT_UIC_EXECUTABLE Where to find the uic tool.
227 # QT_UIC3_EXECUTABLE Where to find the uic3 tool.
228 # QT_RCC_EXECUTABLE Where to find the rcc tool
229 # QT_DBUSCPP2XML_EXECUTABLE Where to find the qdbuscpp2xml tool.
230 # QT_DBUSXML2CPP_EXECUTABLE Where to find the qdbusxml2cpp tool.
231 # QT_LUPDATE_EXECUTABLE Where to find the lupdate tool.
232 # QT_LRELEASE_EXECUTABLE Where to find the lrelease tool.
234 # QT_DOC_DIR Path to "doc" of Qt4
235 # QT_MKSPECS_DIR Path to "mkspecs" of Qt4
238 # These are around for backwards compatibility
240 # QT_WRAP_CPP Set true if QT_MOC_EXECUTABLE is found
241 # QT_WRAP_UI Set true if QT_UIC_EXECUTABLE is found
243 # These variables do _NOT_ have any effect anymore (compared to FindQt.cmake)
244 # QT_MT_REQUIRED Qt4 is now always multithreaded
246 # These variables are set to "" Because Qt structure changed
247 # (They make no sense in Qt4)
248 # QT_QT_LIBRARY Qt-Library is now split
250 INCLUDE(CheckSymbolExists)
251 INCLUDE(MacroAddFileDependencies)
253 SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake)
255 SET( QT_DEFINITIONS "")
257 SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE)
259 # macro for asking qmake to process pro files
260 MACRO(QT_QUERY_QMAKE outvar invar)
261 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake/tmp.pro
262 "message(CMAKE_MESSAGE<$$${invar}>)")
264 # Invoke qmake with the tmp.pro program to get the desired
265 # information. Use the same variable for both stdout and stderr
266 # to make sure we get the output on all platforms.
267 EXECUTE_PROCESS(COMMAND ${QT_QMAKE_EXECUTABLE}
269 ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake
270 OUTPUT_VARIABLE _qmake_query_output
271 RESULT_VARIABLE _qmake_result
272 ERROR_VARIABLE _qmake_query_output )
275 "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake")
278 MESSAGE(WARNING " querying qmake for ${invar}. qmake reported:\n${_qmake_query_output}")
280 STRING(REGEX REPLACE ".*CMAKE_MESSAGE<([^>]*).*" "\\1" ${outvar} "${_qmake_query_output}")
283 ENDMACRO(QT_QUERY_QMAKE)
285 GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME)
287 FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 PATHS
288 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
289 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
290 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]/bin"
294 IF (QT_QMAKE_EXECUTABLE)
296 SET(QT4_QMAKE_FOUND FALSE)
298 EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
300 # check for qt3 qmake and then try and find qmake4 or qmake-qt4 in the path
301 IF("${QTVERSION}" MATCHES "Unknown")
302 SET(QT_QMAKE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE)
303 FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 PATHS
304 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
305 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
308 IF(QT_QMAKE_EXECUTABLE)
309 EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE}
310 ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
311 ENDIF(QT_QMAKE_EXECUTABLE)
312 ENDIF("${QTVERSION}" MATCHES "Unknown")
314 # check that we found the Qt4 qmake, Qt3 qmake output won't match here
315 STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" qt_version_tmp "${QTVERSION}")
318 # we need at least version 4.0.0
319 IF (NOT QT_MIN_VERSION)
320 SET(QT_MIN_VERSION "4.0.0")
321 ENDIF (NOT QT_MIN_VERSION)
323 #now parse the parts of the user given version string into variables
324 STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" req_qt_major_vers "${QT_MIN_VERSION}")
325 IF (NOT req_qt_major_vers)
326 MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"4.0.1\"")
327 ENDIF (NOT req_qt_major_vers)
329 # now parse the parts of the user given version string into variables
330 STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}")
331 STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers "${QT_MIN_VERSION}")
332 STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}")
334 IF (NOT req_qt_major_vers EQUAL 4)
335 MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", major version 4 is required, e.g. \"4.0.1\"")
336 ENDIF (NOT req_qt_major_vers EQUAL 4)
338 # and now the version string given by qmake
339 STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" found_qt_major_vers "${QTVERSION}")
340 STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" found_qt_minor_vers "${QTVERSION}")
341 STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" found_qt_patch_vers "${QTVERSION}")
343 # compute an overall version number which can be compared at once
344 MATH(EXPR req_vers "${req_qt_major_vers}*10000 + ${req_qt_minor_vers}*100 + ${req_qt_patch_vers}")
345 MATH(EXPR found_vers "${found_qt_major_vers}*10000 + ${found_qt_minor_vers}*100 + ${found_qt_patch_vers}")
347 IF (found_vers LESS req_vers)
348 SET(QT4_QMAKE_FOUND FALSE)
349 SET(QT4_INSTALLED_VERSION_TOO_OLD TRUE)
350 ELSE (found_vers LESS req_vers)
351 SET(QT4_QMAKE_FOUND TRUE)
352 ENDIF (found_vers LESS req_vers)
353 ENDIF (qt_version_tmp)
355 ENDIF (QT_QMAKE_EXECUTABLE)
359 # ask qmake for the library dir
361 IF (NOT QT_LIBRARY_DIR)
362 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
363 ARGS "-query QT_INSTALL_LIBS"
364 OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP )
365 IF(EXISTS "${QT_LIBRARY_DIR_TMP}")
366 SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir")
367 ELSE(EXISTS "${QT_LIBRARY_DIR_TMP}")
368 MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}")
369 MESSAGE("Warning: ${QT_LIBRARY_DIR_TMP} does NOT exist, Qt must NOT be installed correctly.")
370 ENDIF(EXISTS "${QT_LIBRARY_DIR_TMP}")
371 ENDIF(NOT QT_LIBRARY_DIR)
374 IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
375 SET(QT_USE_FRAMEWORKS ON
376 CACHE BOOL "Set to ON if Qt build uses frameworks.")
377 ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
378 SET(QT_USE_FRAMEWORKS OFF
379 CACHE BOOL "Set to ON if Qt build uses frameworks.")
380 ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
382 MARK_AS_ADVANCED(QT_USE_FRAMEWORKS)
385 # ask qmake for the binary dir
386 IF (NOT QT_BINARY_DIR)
387 EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE}
388 ARGS "-query QT_INSTALL_BINS"
389 OUTPUT_VARIABLE qt_bins )
390 SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "")
391 ENDIF (NOT QT_BINARY_DIR)
393 # ask qmake for the include dir
394 IF (NOT QT_HEADERS_DIR)
395 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
396 ARGS "-query QT_INSTALL_HEADERS"
397 OUTPUT_VARIABLE qt_headers )
398 SET(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "")
399 ENDIF(NOT QT_HEADERS_DIR)
402 # ask qmake for the documentation directory
404 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
405 ARGS "-query QT_INSTALL_DOCS"
406 OUTPUT_VARIABLE qt_doc_dir )
407 SET(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs")
408 ENDIF (NOT QT_DOC_DIR)
410 # ask qmake for the mkspecs directory
411 IF (NOT QT_MKSPECS_DIR)
412 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
413 ARGS "-query QMAKE_MKSPECS"
414 OUTPUT_VARIABLE qt_mkspecs_dirs )
415 STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}")
416 FIND_PATH(QT_MKSPECS_DIR qconfig.pri PATHS ${qt_mkspecs_dirs}
417 DOC "The location of the Qt mkspecs containing qconfig.pri"
419 ENDIF (NOT QT_MKSPECS_DIR)
421 # ask qmake for the plugins directory
422 IF (NOT QT_PLUGINS_DIR)
423 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
424 ARGS "-query QT_INSTALL_PLUGINS"
425 OUTPUT_VARIABLE qt_plugins_dir )
426 SET(QT_PLUGINS_DIR ${qt_plugins_dir} CACHE PATH "The location of the Qt plugins")
427 ENDIF (NOT QT_PLUGINS_DIR)
428 ########################################
430 # Setting the INCLUDE-Variables
432 ########################################
434 FIND_PATH(QT_QTCORE_INCLUDE_DIR QtGlobal
435 ${QT_HEADERS_DIR}/QtCore
436 ${QT_LIBRARY_DIR}/QtCore.framework/Headers
440 # Set QT_INCLUDE_DIR by removine "/QtCore" in the string ${QT_QTCORE_INCLUDE_DIR}
441 IF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
442 IF (QT_USE_FRAMEWORKS)
443 SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR})
444 ELSE (QT_USE_FRAMEWORKS)
445 STRING( REGEX REPLACE "/QtCore$" "" qt4_include_dir ${QT_QTCORE_INCLUDE_DIR})
446 SET( QT_INCLUDE_DIR ${qt4_include_dir} CACHE PATH "")
447 ENDIF (QT_USE_FRAMEWORKS)
448 ENDIF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
450 IF( NOT QT_INCLUDE_DIR)
451 IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
452 MESSAGE( FATAL_ERROR "Could NOT find QtGlobal header")
453 ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
454 ENDIF( NOT QT_INCLUDE_DIR)
456 #############################################
458 # Find out what window system we're using
460 #############################################
461 # Save required variable
462 SET(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
463 SET(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
464 # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES
465 SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}")
466 # On Mac OS X when Qt has framework support, also add the framework path
467 IF( QT_USE_FRAMEWORKS )
468 SET(CMAKE_REQUIRED_FLAGS "-F${QT_LIBRARY_DIR} ")
469 ENDIF( QT_USE_FRAMEWORKS )
470 # Check for Window system symbols (note: only one should end up being set)
471 CHECK_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11)
472 CHECK_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN)
473 CHECK_SYMBOL_EXISTS(Q_WS_QWS "QtCore/qglobal.h" Q_WS_QWS)
474 CHECK_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC)
476 IF (QT_QTCOPY_REQUIRED)
477 CHECK_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY)
478 IF (NOT QT_IS_QTCOPY)
479 MESSAGE(FATAL_ERROR "qt-copy is required, but hasn't been found")
480 ENDIF (NOT QT_IS_QTCOPY)
481 ENDIF (QT_QTCOPY_REQUIRED)
483 # Restore CMAKE_REQUIRED_INCLUDES and CMAKE_REQUIRED_FLAGS variables
484 SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
485 SET(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
487 #############################################
489 IF (QT_USE_FRAMEWORKS)
490 SET(QT_DEFINITIONS ${QT_DEFINITIONS} -F${QT_LIBRARY_DIR} -L${QT_LIBRARY_DIR} )
491 ENDIF (QT_USE_FRAMEWORKS)
493 # Set QT_QT3SUPPORT_INCLUDE_DIR
494 FIND_PATH(QT_QT3SUPPORT_INCLUDE_DIR Qt3Support
496 ${QT_INCLUDE_DIR}/Qt3Support
497 ${QT_LIBRARY_DIR}/Qt3Support.framework/Headers
501 # Set QT_QT_INCLUDE_DIR
502 FIND_PATH(QT_QT_INCLUDE_DIR qglobal.h
505 ${QT_LIBRARY_DIR}/QtCore.framework/Headers
509 # Set QT_QTGUI_INCLUDE_DIR
510 FIND_PATH(QT_QTGUI_INCLUDE_DIR QtGui
512 ${QT_INCLUDE_DIR}/QtGui
513 ${QT_LIBRARY_DIR}/QtGui.framework/Headers
517 # Set QT_QTSVG_INCLUDE_DIR
518 FIND_PATH(QT_QTSVG_INCLUDE_DIR QtSvg
520 ${QT_INCLUDE_DIR}/QtSvg
521 ${QT_LIBRARY_DIR}/QtSvg.framework/Headers
525 # Set QT_QTSCRIPT_INCLUDE_DIR
526 FIND_PATH(QT_QTSCRIPT_INCLUDE_DIR QtScript
528 ${QT_INCLUDE_DIR}/QtScript
529 ${QT_LIBRARY_DIR}/QtScript.framework/Headers
533 # Set QT_QTTEST_INCLUDE_DIR
534 FIND_PATH(QT_QTTEST_INCLUDE_DIR QtTest
536 ${QT_INCLUDE_DIR}/QtTest
537 ${QT_LIBRARY_DIR}/QtTest.framework/Headers
541 # Set QT_QTUITOOLS_INCLUDE_DIR
542 FIND_PATH(QT_QTUITOOLS_INCLUDE_DIR QtUiTools
544 ${QT_INCLUDE_DIR}/QtUiTools
545 ${QT_LIBRARY_DIR}/QtUiTools.framework/Headers
551 # Set QT_QTMOTIF_INCLUDE_DIR
553 FIND_PATH(QT_QTMOTIF_INCLUDE_DIR QtMotif PATHS ${QT_INCLUDE_DIR}/QtMotif NO_DEFAULT_PATH )
556 # Set QT_QTNETWORK_INCLUDE_DIR
557 FIND_PATH(QT_QTNETWORK_INCLUDE_DIR QtNetwork
559 ${QT_INCLUDE_DIR}/QtNetwork
560 ${QT_LIBRARY_DIR}/QtNetwork.framework/Headers
564 # Set QT_QTNSPLUGIN_INCLUDE_DIR
565 FIND_PATH(QT_QTNSPLUGIN_INCLUDE_DIR QtNsPlugin
567 ${QT_INCLUDE_DIR}/QtNsPlugin
568 ${QT_LIBRARY_DIR}/QtNsPlugin.framework/Headers
572 # Set QT_QTOPENGL_INCLUDE_DIR
573 FIND_PATH(QT_QTOPENGL_INCLUDE_DIR QtOpenGL
575 ${QT_INCLUDE_DIR}/QtOpenGL
576 ${QT_LIBRARY_DIR}/QtOpenGL.framework/Headers
580 # Set QT_QTSQL_INCLUDE_DIR
581 FIND_PATH(QT_QTSQL_INCLUDE_DIR QtSql
583 ${QT_INCLUDE_DIR}/QtSql
584 ${QT_LIBRARY_DIR}/QtSql.framework/Headers
588 # Set QT_QTXML_INCLUDE_DIR
589 FIND_PATH(QT_QTXML_INCLUDE_DIR QtXml
591 ${QT_INCLUDE_DIR}/QtXml
592 ${QT_LIBRARY_DIR}/QtXml.framework/Headers
596 # Set QT_QTASSISTANT_INCLUDE_DIR
597 FIND_PATH(QT_QTASSISTANT_INCLUDE_DIR QtAssistant
599 ${QT_INCLUDE_DIR}/QtAssistant
600 ${QT_HEADERS_DIR}/QtAssistant
601 ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers
605 # Set QT_QTDESIGNER_INCLUDE_DIR
606 FIND_PATH(QT_QTDESIGNER_INCLUDE_DIR QDesignerComponents
608 ${QT_INCLUDE_DIR}/QtDesigner
609 ${QT_HEADERS_DIR}/QtDesigner
610 ${QT_LIBRARY_DIR}/QtDesigner.framework/Headers
614 # Set QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR
615 FIND_PATH(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR QDesignerComponents
617 ${QT_INCLUDE_DIR}/QtDesigner
618 ${QT_HEADERS_DIR}/QtDesigner
623 # Set QT_QTDBUS_INCLUDE_DIR
624 FIND_PATH(QT_QTDBUS_INCLUDE_DIR QtDBus
626 ${QT_INCLUDE_DIR}/QtDBus
627 ${QT_HEADERS_DIR}/QtDBus
631 # Make variables changeble to the advanced user
632 MARK_AS_ADVANCED( QT_LIBRARY_DIR QT_INCLUDE_DIR QT_QT_INCLUDE_DIR QT_DOC_DIR QT_MKSPECS_DIR QT_PLUGINS_DIR)
635 SET( QT_INCLUDES ${QT_INCLUDE_DIR} ${QT_QT_INCLUDE_DIR} ${QT_MKSPECS_DIR}/default )
637 # Set QT_QTCORE_LIBRARY by searching for a lib with "QtCore." as part of the filename
638 FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE NAMES QtCore QtCore4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH )
639 FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG NAMES QtCore_debug QtCored QtCored4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
641 # Set QT_QT3SUPPORT_LIBRARY
642 FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_RELEASE NAMES Qt3Support Qt3Support4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
643 FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG NAMES Qt3Support_debug Qt3Supportd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
645 # Set QT_QTGUI_LIBRARY
646 FIND_LIBRARY(QT_QTGUI_LIBRARY_RELEASE NAMES QtGui QtGui4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
647 FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG NAMES QtGui_debug QtGuid4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
649 # Set QT_QTMOTIF_LIBRARY
651 FIND_LIBRARY(QT_QTMOTIF_LIBRARY_RELEASE NAMES QtMotif PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
652 FIND_LIBRARY(QT_QTMOTIF_LIBRARY_DEBUG NAMES QtMotif_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
655 # Set QT_QTNETWORK_LIBRARY
656 FIND_LIBRARY(QT_QTNETWORK_LIBRARY_RELEASE NAMES QtNetwork QtNetwork4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
657 FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG NAMES QtNetwork_debug QtNetworkd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
659 # Set QT_QTNSPLUGIN_LIBRARY
660 FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_RELEASE NAMES QtNsPlugin PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
661 FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_DEBUG NAMES QtNsPlugin_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
663 # Set QT_QTOPENGL_LIBRARY
664 FIND_LIBRARY(QT_QTOPENGL_LIBRARY_RELEASE NAMES QtOpenGL QtOpenGL4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
665 FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG NAMES QtOpenGL_debug QtOpenGLd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
667 # Set QT_QTSQL_LIBRARY
668 FIND_LIBRARY(QT_QTSQL_LIBRARY_RELEASE NAMES QtSql QtSql4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
669 FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG NAMES QtSql_debug QtSqld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
671 # Set QT_QTXML_LIBRARY
672 FIND_LIBRARY(QT_QTXML_LIBRARY_RELEASE NAMES QtXml QtXml4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
673 FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG NAMES QtXml_debug QtXmld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
675 # Set QT_QTSVG_LIBRARY
676 FIND_LIBRARY(QT_QTSVG_LIBRARY_RELEASE NAMES QtSvg QtSvg4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
677 FIND_LIBRARY(QT_QTSVG_LIBRARY_DEBUG NAMES QtSvg_debug QtSvgd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
679 # Set QT_QTUITOOLS_LIBRARY
680 FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools QtUiTools4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
681 FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_DEBUG NAMES QtUiTools_debug QtUiToolsd QtUiToolsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
682 # QtUiTools not with other frameworks with binary installation (in /usr/lib)
683 IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE)
684 FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools PATHS ${QT_LIBRARY_DIR})
685 ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE)
687 # Set QT_QTTEST_LIBRARY
688 FIND_LIBRARY(QT_QTTEST_LIBRARY_RELEASE NAMES QtTest QtTest4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
689 FIND_LIBRARY(QT_QTTEST_LIBRARY_DEBUG NAMES QtTest_debug QtTest_debug4 QtTestd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
691 # Set QT_QTDBUS_LIBRARY
692 # This was introduced with Qt 4.2, where also the naming scheme for debug libs was changed
693 # So does any of the debug lib names listed here actually exist ?
694 FIND_LIBRARY(QT_QTDBUS_LIBRARY_RELEASE NAMES QtDBus QtDBus4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
695 FIND_LIBRARY(QT_QTDBUS_LIBRARY_DEBUG NAMES QtDBus_debug QtDBus_debug4 QtDBusd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
697 # Set QT_QTSCRIPT_LIBRARY
698 FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_RELEASE NAMES QtScript QtScript4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
699 FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_DEBUG NAMES QtScript_debug QtScriptd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
701 IF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE )
702 IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
703 MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.")
704 ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
705 ENDIF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE )
707 # Set QT_QTASSISTANT_LIBRARY
708 FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient QtAssistantClient4 QtAssistant QtAssistant4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
709 FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistantClientd QtAssistantClientd4 QtAssistantClient_debug QtAssistant_debug QtAssistantd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
711 # Set QT_QTDESIGNER_LIBRARY
712 FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_RELEASE NAMES QtDesigner QtDesigner4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
713 FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_DEBUG NAMES QtDesigner_debug QtDesignerd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
715 # Set QT_QTDESIGNERCOMPONENTS_LIBRARY
716 FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents QtDesignerComponents4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
717 FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NAMES QtDesigner_debug QtDesignerd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
719 # Set QT_QTMAIN_LIBRARY
721 FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain PATHS ${QT_LIBRARY_DIR}
723 FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmaind PATHS ${QT_LIBRARY_DIR}
727 ############################################
729 # Check the existence of the libraries.
731 ############################################
733 MACRO (_QT4_ADJUST_LIB_VARS basename)
734 IF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG)
736 # if only the release version was found, set the debug variable also to the release version
737 IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
738 SET(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE})
739 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE})
740 SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_RELEASE})
741 ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
743 # if only the debug version was found, set the release variable also to the debug version
744 IF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE)
745 SET(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG})
746 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG})
747 SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_DEBUG})
748 ENDIF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE)
750 IF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
751 # if the generator supports configuration types then set
752 # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
753 IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
754 SET(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
755 ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
756 # if there are no configuration types and CMAKE_BUILD_TYPE has no value
757 # then just use the release libraries
758 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE} )
759 ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
760 SET(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
761 ENDIF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
763 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE FILEPATH "The Qt ${basename} library")
765 IF (QT_${basename}_LIBRARY)
766 SET(QT_${basename}_FOUND 1)
767 ENDIF (QT_${basename}_LIBRARY)
769 ENDIF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG)
771 IF (QT_${basename}_INCLUDE_DIR)
772 #add the include directory to QT_INCLUDES
773 SET(QT_INCLUDES ${QT_INCLUDES} "${QT_${basename}_INCLUDE_DIR}")
774 ENDIF (QT_${basename}_INCLUDE_DIR)
776 # Make variables changeble to the advanced user
777 MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR)
778 ENDMACRO (_QT4_ADJUST_LIB_VARS)
781 # Set QT_xyz_LIBRARY variable and add
782 # library include path to QT_INCLUDES
783 _QT4_ADJUST_LIB_VARS(QTCORE)
784 _QT4_ADJUST_LIB_VARS(QTGUI)
785 _QT4_ADJUST_LIB_VARS(QT3SUPPORT)
786 _QT4_ADJUST_LIB_VARS(QTASSISTANT)
787 _QT4_ADJUST_LIB_VARS(QTDESIGNER)
788 _QT4_ADJUST_LIB_VARS(QTDESIGNERCOMPONENTS)
789 _QT4_ADJUST_LIB_VARS(QTNETWORK)
790 _QT4_ADJUST_LIB_VARS(QTNSPLUGIN)
791 _QT4_ADJUST_LIB_VARS(QTOPENGL)
792 _QT4_ADJUST_LIB_VARS(QTSQL)
793 _QT4_ADJUST_LIB_VARS(QTXML)
794 _QT4_ADJUST_LIB_VARS(QTSVG)
795 _QT4_ADJUST_LIB_VARS(QTSCRIPT)
796 _QT4_ADJUST_LIB_VARS(QTUITOOLS)
797 _QT4_ADJUST_LIB_VARS(QTTEST)
798 _QT4_ADJUST_LIB_VARS(QTDBUS)
800 # platform dependent libraries
802 _QT4_ADJUST_LIB_VARS(QTMOTIF)
805 _QT4_ADJUST_LIB_VARS(QTMAIN)
809 #######################################
811 # Check the executables of Qt
814 #######################################
817 # find moc and uic using qmake
818 QT_QUERY_QMAKE(QT_MOC_EXECUTABLE_INTERNAL "QMAKE_MOC")
819 QT_QUERY_QMAKE(QT_UIC_EXECUTABLE_INTERNAL "QMAKE_UIC")
822 "${QT_MOC_EXECUTABLE_INTERNAL}" QT_MOC_EXECUTABLE_INTERNAL)
824 "${QT_UIC_EXECUTABLE_INTERNAL}" QT_UIC_EXECUTABLE_INTERNAL)
826 SET(QT_MOC_EXECUTABLE
827 ${QT_MOC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The moc executable")
828 SET(QT_UIC_EXECUTABLE
829 ${QT_UIC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The uic executable")
831 FIND_PROGRAM(QT_UIC3_EXECUTABLE
833 PATHS ${QT_BINARY_DIR}
837 FIND_PROGRAM(QT_RCC_EXECUTABLE
839 PATHS ${QT_BINARY_DIR}
843 FIND_PROGRAM(QT_DBUSCPP2XML_EXECUTABLE
845 PATHS ${QT_BINARY_DIR}
849 FIND_PROGRAM(QT_DBUSXML2CPP_EXECUTABLE
851 PATHS ${QT_BINARY_DIR}
855 FIND_PROGRAM(QT_LUPDATE_EXECUTABLE
857 PATHS ${QT_BINARY_DIR}
861 FIND_PROGRAM(QT_LRELEASE_EXECUTABLE
863 PATHS ${QT_BINARY_DIR}
867 IF (QT_MOC_EXECUTABLE)
868 SET(QT_WRAP_CPP "YES")
869 ENDIF (QT_MOC_EXECUTABLE)
871 IF (QT_UIC_EXECUTABLE)
872 SET(QT_WRAP_UI "YES")
873 ENDIF (QT_UIC_EXECUTABLE)
877 MARK_AS_ADVANCED( QT_UIC_EXECUTABLE QT_UIC3_EXECUTABLE QT_MOC_EXECUTABLE
878 QT_RCC_EXECUTABLE QT_DBUSXML2CPP_EXECUTABLE QT_DBUSCPP2XML_EXECUTABLE
879 QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE)
881 ######################################
883 # Macros for building Qt files
885 ######################################
887 MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
890 SET(_QT4_DOING_OPTIONS FALSE)
891 FOREACH(_currentArg ${ARGN})
892 IF ("${_currentArg}" STREQUAL "OPTIONS")
893 SET(_QT4_DOING_OPTIONS TRUE)
894 ELSE ("${_currentArg}" STREQUAL "OPTIONS")
895 IF(_QT4_DOING_OPTIONS)
896 LIST(APPEND ${_qt4_options} "${_currentArg}")
897 ELSE(_QT4_DOING_OPTIONS)
898 LIST(APPEND ${_qt4_files} "${_currentArg}")
899 ENDIF(_QT4_DOING_OPTIONS)
900 ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
901 ENDFOREACH(_currentArg)
902 ENDMACRO (QT4_EXTRACT_OPTIONS)
904 # macro used to create the names of output files preserving relative dirs
905 MACRO (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile )
906 STRING(REGEX MATCH "${CMAKE_CURRENT_BINARY_DIR}" _match ${infile})
908 FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
910 FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
912 SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
913 GET_FILENAME_COMPONENT(outpath ${_outfile} PATH)
914 GET_FILENAME_COMPONENT(_outfile ${_outfile} NAME_WE)
915 FILE(MAKE_DIRECTORY ${outpath})
916 SET(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
917 ENDMACRO (QT4_MAKE_OUTPUT_FILE )
919 MACRO (QT4_GET_MOC_INC_DIRS _moc_INC_DIRS)
920 SET(${_moc_INC_DIRS})
921 GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES)
923 FOREACH(_current ${_inc_DIRS})
924 SET(${_moc_INC_DIRS} ${${_moc_INC_DIRS}} "-I" ${_current})
925 ENDFOREACH(_current ${_inc_DIRS})
927 ENDMACRO(QT4_GET_MOC_INC_DIRS)
929 # helper macro to set up a moc rule
930 MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_includes moc_options)
931 # For Windows, create a parameters file to work around command line length limit
933 # Pass the parameters in a file. Set the working directory to
934 # be that containing the parameters file and reference it by
935 # just the file name. This is necessary because the moc tool on
936 # MinGW builds does not seem to handle spaces in the path to the
937 # file given with the @ syntax.
938 GET_FILENAME_COMPONENT(_moc_outfile_name "${outfile}" NAME)
939 GET_FILENAME_COMPONENT(_moc_outfile_dir "${outfile}" PATH)
941 SET(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
942 ENDIF(_moc_outfile_dir)
943 SET (_moc_parameters_file ${outfile}_parameters)
944 SET (_moc_parameters ${moc_includes} ${moc_options} -o "${outfile}" "${infile}")
945 FILE (REMOVE ${_moc_parameters_file})
946 FOREACH(arg ${_moc_parameters})
947 FILE (APPEND ${_moc_parameters_file} "${arg}\n")
949 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
950 COMMAND ${QT_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters
955 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
956 COMMAND ${QT_MOC_EXECUTABLE}
957 ARGS ${moc_includes} ${moc_options} -o ${outfile} ${infile}
960 ENDMACRO (QT4_CREATE_MOC_COMMAND)
963 MACRO (QT4_GENERATE_MOC infile outfile )
964 QT4_GET_MOC_INC_DIRS(moc_includes)
965 GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE)
966 QT4_CREATE_MOC_COMMAND(${abs_infile} ${outfile} "${moc_includes}" "")
967 SET_SOURCE_FILES_PROPERTIES(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file
968 ENDMACRO (QT4_GENERATE_MOC)
971 # QT4_WRAP_CPP(outfiles inputfile ... )
973 MACRO (QT4_WRAP_CPP outfiles )
975 QT4_GET_MOC_INC_DIRS(moc_includes)
976 QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
978 FOREACH (it ${moc_files})
979 GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
980 QT4_MAKE_OUTPUT_FILE(${it} moc_ cxx outfile)
981 QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_includes}" "${moc_options}")
982 SET(${outfiles} ${${outfiles}} ${outfile})
985 ENDMACRO (QT4_WRAP_CPP)
988 # QT4_WRAP_UI(outfiles inputfile ... )
990 MACRO (QT4_WRAP_UI outfiles )
991 QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
993 FOREACH (it ${ui_files})
994 GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
995 GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
996 SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
997 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
998 COMMAND ${QT_UIC_EXECUTABLE}
999 ARGS ${ui_options} -o ${outfile} ${infile}
1000 MAIN_DEPENDENCY ${infile})
1001 SET(${outfiles} ${${outfiles}} ${outfile})
1004 ENDMACRO (QT4_WRAP_UI)
1007 # QT4_ADD_RESOURCES(outfiles inputfile ... )
1009 MACRO (QT4_ADD_RESOURCES outfiles )
1010 QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN})
1012 FOREACH (it ${rcc_files})
1013 GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
1014 GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
1015 GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
1016 SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
1017 # parse file for dependencies
1018 # all files are absolute paths or relative to the location of the qrc file
1019 FILE(READ "${infile}" _RC_FILE_CONTENTS)
1020 STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
1022 FOREACH(_RC_FILE ${_RC_FILES})
1023 STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
1024 STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}")
1025 IF(NOT _ABS_PATH_INDICATOR)
1026 SET(_RC_FILE "${rc_path}/${_RC_FILE}")
1027 ENDIF(NOT _ABS_PATH_INDICATOR)
1028 SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
1029 ENDFOREACH(_RC_FILE)
1030 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1031 COMMAND ${QT_RCC_EXECUTABLE}
1032 ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
1033 MAIN_DEPENDENCY ${infile}
1034 DEPENDS ${_RC_DEPENDS})
1035 SET(${outfiles} ${${outfiles}} ${outfile})
1038 ENDMACRO (QT4_ADD_RESOURCES)
1040 MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename)
1041 GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE)
1042 SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
1043 SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
1044 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
1046 ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1047 COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -p ${_basename} ${_infile}
1050 SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
1052 QT4_GENERATE_MOC(${_header} ${_moc})
1054 SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
1055 MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
1057 ENDMACRO(QT4_ADD_DBUS_INTERFACE)
1060 MACRO(QT4_ADD_DBUS_INTERFACES _sources)
1061 FOREACH (_current_FILE ${ARGN})
1062 GET_FILENAME_COMPONENT(_infile ${_current_FILE} ABSOLUTE)
1063 # get the part before the ".xml" suffix
1064 STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2" _basename ${_current_FILE})
1065 STRING(TOLOWER ${_basename} _basename)
1066 QT4_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface)
1067 ENDFOREACH (_current_FILE)
1068 ENDMACRO(QT4_ADD_DBUS_INTERFACES)
1071 MACRO(QT4_GENERATE_DBUS_INTERFACE _header) # _customName )
1072 SET(_customName "${ARGV1}")
1073 GET_FILENAME_COMPONENT(_in_file ${_header} ABSOLUTE)
1074 GET_FILENAME_COMPONENT(_basename ${_header} NAME_WE)
1077 SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName})
1079 SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml)
1082 ADD_CUSTOM_COMMAND(OUTPUT ${_target}
1083 COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_in_file} > ${_target}
1086 ENDMACRO(QT4_GENERATE_DBUS_INTERFACE)
1089 MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename )
1090 GET_FILENAME_COMPONENT(_infile ${_xml_file} ABSOLUTE)
1092 SET(_optionalBasename "${ARGV4}")
1093 IF (_optionalBasename)
1094 SET(_basename ${_optionalBasename} )
1095 ELSE (_optionalBasename)
1096 STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile})
1097 STRING(TOLOWER ${_basename} _basename)
1098 ENDIF (_optionalBasename)
1100 SET(_optionalClassName "${ARGV5}")
1101 SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
1102 SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
1103 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
1105 IF(_optionalClassName)
1106 ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1107 COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
1110 ELSE(_optionalClassName)
1111 ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1112 COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
1115 ENDIF(_optionalClassName)
1117 QT4_GENERATE_MOC(${_header} ${_moc})
1118 SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
1119 MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
1121 SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
1122 ENDMACRO(QT4_ADD_DBUS_ADAPTOR)
1125 QT4_GET_MOC_INC_DIRS(_moc_INCS)
1127 SET(_matching_FILES )
1128 FOREACH (_current_FILE ${ARGN})
1130 GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
1131 # if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
1132 # here. this is required to make bouic work correctly:
1133 # we need to add generated .cpp files to the sources (to compile them),
1134 # but we cannot let automoc handle them, as the .cpp files don't exist yet when
1135 # cmake is run for the very first time on them -> however the .cpp files might
1136 # exist at a later run. at that time we need to skip them, so that we don't add two
1137 # different rules for the same moc file
1138 GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC)
1140 IF ( NOT _skip AND EXISTS ${_abs_FILE} )
1142 FILE(READ ${_abs_FILE} _contents)
1144 GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH)
1146 STRING(REGEX MATCHALL "#include +[^ ]+\\.moc[\">]" _match "${_contents}")
1148 FOREACH (_current_MOC_INC ${_match})
1149 STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
1150 GET_FILENAME_COMPONENT(_basename ${_current_MOC} NAME_WE)
1151 SET(_header ${_abs_PATH}/${_basename}.h)
1152 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
1153 QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${moc_INCS}" "")
1154 MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
1155 ENDFOREACH (_current_MOC_INC)
1157 ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} )
1158 ENDFOREACH (_current_FILE)
1159 ENDMACRO(QT4_AUTOMOC)
1161 MACRO(QT4_CREATE_TRANSLATION _qm_files)
1164 FOREACH (_file ${ARGN})
1165 GET_FILENAME_COMPONENT(_ext ${_file} EXT)
1166 GET_FILENAME_COMPONENT(_abs_FILE ${_file} ABSOLUTE)
1167 IF(_ext MATCHES "ts")
1168 LIST(APPEND _my_tsfiles ${_abs_FILE})
1169 ELSE(_ext MATCHES "ts")
1170 LIST(APPEND _my_sources ${_abs_FILE})
1171 ENDIF(_ext MATCHES "ts")
1173 FOREACH(_ts_file ${_my_tsfiles})
1174 ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file}
1175 COMMAND ${QT_LUPDATE_EXECUTABLE}
1176 ARGS ${_my_sources} -ts ${_ts_file}
1177 DEPENDS ${_my_sources})
1178 ENDFOREACH(_ts_file)
1179 QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles})
1180 ENDMACRO(QT4_CREATE_TRANSLATION)
1182 MACRO(QT4_ADD_TRANSLATION _qm_files)
1183 FOREACH (_current_FILE ${ARGN})
1184 GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
1185 GET_FILENAME_COMPONENT(qm ${_abs_FILE} NAME_WE)
1186 SET(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm")
1188 ADD_CUSTOM_COMMAND(OUTPUT ${qm}
1189 COMMAND ${QT_LRELEASE_EXECUTABLE}
1190 ARGS ${_abs_FILE} -qm ${qm}
1191 DEPENDS ${_abs_FILE}
1193 SET(${_qm_files} ${${_qm_files}} ${qm})
1194 ENDFOREACH (_current_FILE)
1195 ENDMACRO(QT4_ADD_TRANSLATION)
1201 ######################################
1203 # decide if Qt got found
1205 ######################################
1207 # if the includes,libraries,moc,uic and rcc are found then we have it
1208 IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1209 SET( QT4_FOUND "YES" )
1210 IF( NOT Qt4_FIND_QUIETLY)
1211 MESSAGE(STATUS "Found Qt-Version ${QTVERSION}")
1212 ENDIF( NOT Qt4_FIND_QUIETLY)
1213 ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1214 SET( QT4_FOUND "NO")
1215 SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1216 IF( Qt4_FIND_REQUIRED)
1217 MESSAGE( FATAL_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!")
1218 ENDIF( Qt4_FIND_REQUIRED)
1219 ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1220 SET(QT_FOUND ${QT4_FOUND})
1223 #######################################
1227 #######################################
1228 IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
1229 FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents)
1230 STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG ${_qconfig_FILE_contents})
1231 STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG ${_qconfig_FILE_contents})
1232 STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION ${_qconfig_FILE_contents})
1233 ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
1234 IF("${QT_EDITION}" MATCHES "DesktopLight")
1235 SET(QT_EDITION_DESKTOPLIGHT 1)
1236 ENDIF("${QT_EDITION}" MATCHES "DesktopLight")
1239 ###############################################
1241 # configuration/system dependent settings
1243 ###############################################
1245 SET(QT_GUI_LIB_DEPENDENCIES "")
1246 SET(QT_CORE_LIB_DEPENDENCIES "")
1248 # build using shared Qt needs -DQT_DLL
1249 IF(NOT QT_CONFIG MATCHES "static")
1250 # warning currently only qconfig.pri on Windows potentially contains "static"
1251 # so QT_DLL might not get defined properly on other platforms.
1252 SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_DLL)
1253 ENDIF(NOT QT_CONFIG MATCHES "static")
1256 IF(QT_QCONFIG MATCHES "system-png")
1257 FIND_LIBRARY(QT_PNG_LIBRARY NAMES png)
1258 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY})
1259 MARK_AS_ADVANCED(QT_PNG_LIBRARY)
1260 ENDIF(QT_QCONFIG MATCHES "system-png")
1262 # for X11, get X11 library directory
1264 QT_QUERY_QMAKE(QMAKE_LIBDIR_X11 "QMAKE_LIBDIR_X11")
1268 IF(QT_QCONFIG MATCHES "x11sm")
1269 # ask qmake where the x11 libs are
1270 FIND_LIBRARY(QT_X11_SM_LIBRARY NAMES SM PATHS ${QMAKE_LIBDIR_X11})
1271 FIND_LIBRARY(QT_X11_ICE_LIBRARY NAMES ICE PATHS ${QMAKE_LIBDIR_X11})
1272 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_X11_SM_LIBRARY} ${QT_X11_ICE_LIBRARY})
1273 MARK_AS_ADVANCED(QT_X11_SM_LIBRARY)
1274 MARK_AS_ADVANCED(QT_X11_ICE_LIBRARY)
1275 ENDIF(QT_QCONFIG MATCHES "x11sm")
1278 IF(QT_QCONFIG MATCHES "tablet")
1279 FIND_LIBRARY(QT_XI_LIBRARY NAMES Xi PATHS ${QMAKE_LIBDIR_X11})
1280 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XI_LIBRARY})
1281 MARK_AS_ADVANCED(QT_XI_LIBRARY)
1282 ENDIF(QT_QCONFIG MATCHES "tablet")
1285 IF(QT_QCONFIG MATCHES "xrender")
1286 FIND_LIBRARY(QT_XRENDER_LIBRARY NAMES Xrender PATHS ${QMAKE_LIBDIR_X11})
1287 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XRENDER_LIBRARY})
1288 MARK_AS_ADVANCED(QT_XRENDER_LIBRARY)
1289 ENDIF(QT_QCONFIG MATCHES "xrender")
1292 IF(QT_QCONFIG MATCHES "xrandr")
1293 FIND_LIBRARY(QT_XRANDR_LIBRARY NAMES Xrandr PATHS ${QMAKE_LIBDIR_X11})
1294 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XRANDR_LIBRARY})
1295 MARK_AS_ADVANCED(QT_XRANDR_LIBRARY)
1296 ENDIF(QT_QCONFIG MATCHES "xrandr")
1299 IF(QT_QCONFIG MATCHES "xcursor")
1300 FIND_LIBRARY(QT_XCURSOR_LIBRARY NAMES Xcursor PATHS ${QMAKE_LIBDIR_X11})
1301 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XCURSOR_LIBRARY})
1302 MARK_AS_ADVANCED(QT_XCURSOR_LIBRARY)
1303 ENDIF(QT_QCONFIG MATCHES "xcursor")
1306 IF(QT_QCONFIG MATCHES "xinerama")
1307 FIND_LIBRARY(QT_XINERAMA_LIBRARY NAMES Xinerama PATHS ${QMAKE_LIBDIR_X11})
1308 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XINERAMA_LIBRARY})
1309 MARK_AS_ADVANCED(QT_XINERAMA_LIBRARY)
1310 ENDIF(QT_QCONFIG MATCHES "xinerama")
1313 IF(QT_QCONFIG MATCHES "xfixes")
1314 FIND_LIBRARY(QT_XFIXES_LIBRARY NAMES Xfixes PATHS ${QMAKE_LIBDIR_X11})
1315 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XFIXES_LIBRARY})
1316 MARK_AS_ADVANCED(QT_XFIXES_LIBRARY)
1317 ENDIF(QT_QCONFIG MATCHES "xfixes")
1320 IF(QT_QCONFIG MATCHES "system-freetype")
1321 FIND_LIBRARY(QT_FREETYPE_LIBRARY NAMES freetype)
1322 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY})
1323 MARK_AS_ADVANCED(QT_FREETYPE_LIBRARY)
1324 ENDIF(QT_QCONFIG MATCHES "system-freetype")
1327 IF(QT_QCONFIG MATCHES "fontconfig")
1328 FIND_LIBRARY(QT_FONTCONFIG_LIBRARY NAMES fontconfig)
1329 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY})
1330 MARK_AS_ADVANCED(QT_FONTCONFIG_LIBRARY)
1331 ENDIF(QT_QCONFIG MATCHES "fontconfig")
1334 IF(QT_QCONFIG MATCHES "system-zlib")
1335 FIND_LIBRARY(QT_ZLIB_LIBRARY NAMES z)
1336 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY})
1337 MARK_AS_ADVANCED(QT_ZLIB_LIBRARY)
1338 ENDIF(QT_QCONFIG MATCHES "system-zlib")
1341 IF(QT_QCONFIG MATCHES "glib")
1342 # Qt 4.2.0+ uses glib-2.0
1343 EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L glib-2.0 gthread-2.0
1344 OUTPUT_VARIABLE _glib_query_output
1345 RESULT_VARIABLE _glib_result
1346 ERROR_VARIABLE _glib_query_output )
1348 IF(_glib_result MATCHES 0)
1349 STRING(REPLACE "-L" "" _glib_query_output "${_glib_query_output}")
1350 SEPARATE_ARGUMENTS(_glib_query_output)
1351 ELSE(_glib_result MATCHES 0)
1352 SET(_glib_query_output)
1353 MESSAGE(WARNING "When querying pkg-config for glib-2.0. An error was reported:\n${_glib_query_output}")
1354 ENDIF(_glib_result MATCHES 0)
1356 FIND_LIBRARY(QT_GLIB_LIBRARY NAMES glib-2.0 PATHS ${_glib_query_output} )
1357 FIND_LIBRARY(QT_GTHREAD_LIBRARY NAMES gthread-2.0 PATHS ${_glib_query_output} )
1359 IF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY)
1360 MESSAGE(WARNING "Unable to find glib 2.0 to satisfy Qt dependency.")
1361 ELSE(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY)
1362 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES}
1363 ${QT_GTHREAD_LIBRARY} ${QT_GLIB_LIBRARY})
1364 ENDIF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY)
1366 MARK_AS_ADVANCED(QT_GLIB_LIBRARY)
1367 MARK_AS_ADVANCED(QT_GTHREAD_LIBRARY)
1368 ENDIF(QT_QCONFIG MATCHES "glib")
1370 ## clock-monotonic, just see if we need to link with rt
1371 IF(QT_QCONFIG MATCHES "clock-monotonic")
1372 SET(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
1373 SET(CMAKE_REQUIRED_LIBRARIES rt)
1374 CHECK_SYMBOL_EXISTS(_POSIX_TIMERS "unistd.h;time.h" QT_POSIX_TIMERS)
1375 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
1377 FIND_LIBRARY(QT_RT_LIBRARY NAMES rt)
1378 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QT_RT_LIBRARY})
1379 MARK_AS_ADVANCED(QT_RT_LIBRARY)
1380 ENDIF(QT_POSIX_TIMERS)
1381 ENDIF(QT_QCONFIG MATCHES "clock-monotonic")
1384 # X11 libraries Qt absolutely depends on
1385 QT_QUERY_QMAKE(QT_LIBS_X11 "QMAKE_LIBS_X11")
1386 SEPARATE_ARGUMENTS(QT_LIBS_X11)
1387 FOREACH(QT_X11_LIB ${QT_LIBS_X11})
1388 STRING(REGEX REPLACE "-l" "" QT_X11_LIB "${QT_X11_LIB}")
1389 SET(QT_TMP_STR "QT_X11_${QT_X11_LIB}_LIBRARY")
1390 FIND_LIBRARY(${QT_TMP_STR} NAMES "${QT_X11_LIB}" PATHS ${QMAKE_LIBDIR_X11})
1391 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${${QT_TMP_STR}})
1392 MARK_AS_ADVANCED(${QT_TMP_STR})
1393 ENDFOREACH(QT_X11_LIB)
1395 QT_QUERY_QMAKE(QT_LIBS_THREAD "QMAKE_LIBS_THREAD")
1396 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QT_LIBS_THREAD})
1398 QT_QUERY_QMAKE(QMAKE_LIBS_DYNLOAD "QMAKE_LIBS_DYNLOAD")
1399 SET (QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QMAKE_LIBS_DYNLOAD})
1404 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} imm32 winmm)
1405 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ws2_32)
1409 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} "-framework Carbon" "-framework QuickTime")
1410 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} "-framework ApplicationServices")
1413 #######################################
1415 # compatibility settings
1417 #######################################
1418 # Backwards compatibility for CMake1.4 and 1.2
1419 SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} )
1420 SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} )
1422 SET( QT_QT_LIBRARY "")
1424 ELSE(QT4_QMAKE_FOUND)
1426 SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1427 IF(Qt4_FIND_REQUIRED)
1428 IF(QT4_INSTALLED_VERSION_TOO_OLD)
1429 MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1430 ELSE(QT4_INSTALLED_VERSION_TOO_OLD)
1431 MESSAGE( FATAL_ERROR "Qt qmake not found!")
1432 ENDIF(QT4_INSTALLED_VERSION_TOO_OLD)
1433 ELSE(Qt4_FIND_REQUIRED)
1434 IF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1435 MESSAGE(STATUS "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1436 ENDIF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1437 ENDIF(Qt4_FIND_REQUIRED)
1439 ENDIF (QT4_QMAKE_FOUND)