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 QT_RCC_EXECUTABLE QT_DBUSXML2CPP_EXECUTABLE QT_DBUSCPP2XML_EXECUTABLE)
879 ######################################
881 # Macros for building Qt files
883 ######################################
885 MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
888 SET(_QT4_DOING_OPTIONS FALSE)
889 FOREACH(_currentArg ${ARGN})
890 IF ("${_currentArg}" STREQUAL "OPTIONS")
891 SET(_QT4_DOING_OPTIONS TRUE)
892 ELSE ("${_currentArg}" STREQUAL "OPTIONS")
893 IF(_QT4_DOING_OPTIONS)
894 LIST(APPEND ${_qt4_options} "${_currentArg}")
895 ELSE(_QT4_DOING_OPTIONS)
896 LIST(APPEND ${_qt4_files} "${_currentArg}")
897 ENDIF(_QT4_DOING_OPTIONS)
898 ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
899 ENDFOREACH(_currentArg)
900 ENDMACRO (QT4_EXTRACT_OPTIONS)
902 MACRO (QT4_GET_MOC_INC_DIRS _moc_INC_DIRS)
903 SET(${_moc_INC_DIRS})
904 GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES)
906 FOREACH(_current ${_inc_DIRS})
907 SET(${_moc_INC_DIRS} ${${_moc_INC_DIRS}} "-I" ${_current})
908 ENDFOREACH(_current ${_inc_DIRS})
910 ENDMACRO(QT4_GET_MOC_INC_DIRS)
912 # helper macro to set up a moc rule
913 MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_includes moc_options)
914 # For Windows, create a parameters file to work around command line length limit
916 SET (_moc_parameters_file ${outfile}_parameters)
917 SET (_moc_parameters ${moc_includes} ${moc_options} -o "${outfile}" "${infile}")
918 FILE (REMOVE ${_moc_parameters_file})
919 FOREACH(arg ${_moc_parameters})
920 FILE (APPEND ${_moc_parameters_file} "${arg}\n")
922 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
923 COMMAND ${QT_MOC_EXECUTABLE}
924 ARGS @"${_moc_parameters_file}"
927 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
928 COMMAND ${QT_MOC_EXECUTABLE}
929 ARGS ${moc_includes} ${moc_options} -o ${outfile} ${infile}
932 ENDMACRO (QT4_CREATE_MOC_COMMAND)
935 MACRO (QT4_GENERATE_MOC infile outfile )
936 QT4_GET_MOC_INC_DIRS(moc_includes)
937 GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE)
938 QT4_CREATE_MOC_COMMAND(${abs_infile} ${outfile} "${moc_includes}" "")
939 SET_SOURCE_FILES_PROPERTIES(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file
940 ENDMACRO (QT4_GENERATE_MOC)
943 # QT4_WRAP_CPP(outfiles inputfile ... )
945 MACRO (QT4_WRAP_CPP outfiles )
947 QT4_GET_MOC_INC_DIRS(moc_includes)
948 QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
950 FOREACH (it ${moc_files})
951 GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
952 GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
953 SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/moc_${outfile}.cxx)
954 QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_includes}" "${moc_options}")
955 SET(${outfiles} ${${outfiles}} ${outfile})
958 ENDMACRO (QT4_WRAP_CPP)
961 # QT4_WRAP_UI(outfiles inputfile ... )
963 MACRO (QT4_WRAP_UI outfiles )
964 QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
966 FOREACH (it ${ui_files})
967 GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
968 GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
969 SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
970 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
971 COMMAND ${QT_UIC_EXECUTABLE}
972 ARGS ${ui_options} -o ${outfile} ${infile}
973 MAIN_DEPENDENCY ${infile})
974 SET(${outfiles} ${${outfiles}} ${outfile})
977 ENDMACRO (QT4_WRAP_UI)
980 # QT4_ADD_RESOURCES(outfiles inputfile ... )
982 MACRO (QT4_ADD_RESOURCES outfiles )
983 QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN})
985 FOREACH (it ${rcc_files})
986 GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
987 GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
988 GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
989 SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
990 # parse file for dependencies
991 # all files are absolute paths or relative to the location of the qrc file
992 FILE(READ "${infile}" _RC_FILE_CONTENTS)
993 STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
995 FOREACH(_RC_FILE ${_RC_FILES})
996 STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
997 STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}")
998 IF(NOT _ABS_PATH_INDICATOR)
999 SET(_RC_FILE "${rc_path}/${_RC_FILE}")
1000 ENDIF(NOT _ABS_PATH_INDICATOR)
1001 SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
1002 ENDFOREACH(_RC_FILE)
1003 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1004 COMMAND ${QT_RCC_EXECUTABLE}
1005 ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
1006 MAIN_DEPENDENCY ${infile}
1007 DEPENDS ${_RC_DEPENDS})
1008 SET(${outfiles} ${${outfiles}} ${outfile})
1011 ENDMACRO (QT4_ADD_RESOURCES)
1013 MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename)
1014 GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE)
1015 SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
1016 SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
1017 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
1019 ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1020 COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -p ${_basename} ${_infile}
1023 SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
1025 QT4_GENERATE_MOC(${_header} ${_moc})
1027 SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
1028 MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
1030 ENDMACRO(QT4_ADD_DBUS_INTERFACE)
1033 MACRO(QT4_ADD_DBUS_INTERFACES _sources)
1034 FOREACH (_current_FILE ${ARGN})
1035 GET_FILENAME_COMPONENT(_infile ${_current_FILE} ABSOLUTE)
1036 # get the part before the ".xml" suffix
1037 STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2" _basename ${_current_FILE})
1038 STRING(TOLOWER ${_basename} _basename)
1039 QT4_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface)
1040 ENDFOREACH (_current_FILE)
1041 ENDMACRO(QT4_ADD_DBUS_INTERFACES)
1044 MACRO(QT4_GENERATE_DBUS_INTERFACE _header) # _customName )
1045 SET(_customName "${ARGV1}")
1046 GET_FILENAME_COMPONENT(_in_file ${_header} ABSOLUTE)
1047 GET_FILENAME_COMPONENT(_basename ${_header} NAME_WE)
1050 SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName})
1052 SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml)
1055 ADD_CUSTOM_COMMAND(OUTPUT ${_target}
1056 COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_in_file} > ${_target}
1059 ENDMACRO(QT4_GENERATE_DBUS_INTERFACE)
1062 MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename )
1063 GET_FILENAME_COMPONENT(_infile ${_xml_file} ABSOLUTE)
1065 SET(_optionalBasename "${ARGV4}")
1066 IF (_optionalBasename)
1067 SET(_basename ${_optionalBasename} )
1068 ELSE (_optionalBasename)
1069 STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile})
1070 STRING(TOLOWER ${_basename} _basename)
1071 ENDIF (_optionalBasename)
1073 SET(_optionalClassName "${ARGV5}")
1074 SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
1075 SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
1076 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
1078 IF(_optionalClassName)
1079 ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1080 COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
1083 ELSE(_optionalClassName)
1084 ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1085 COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
1088 ENDIF(_optionalClassName)
1090 QT4_GENERATE_MOC(${_header} ${_moc})
1091 SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
1092 MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
1094 SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
1095 ENDMACRO(QT4_ADD_DBUS_ADAPTOR)
1098 QT4_GET_MOC_INC_DIRS(_moc_INCS)
1100 SET(_matching_FILES )
1101 FOREACH (_current_FILE ${ARGN})
1103 GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
1104 # if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
1105 # here. this is required to make bouic work correctly:
1106 # we need to add generated .cpp files to the sources (to compile them),
1107 # but we cannot let automoc handle them, as the .cpp files don't exist yet when
1108 # cmake is run for the very first time on them -> however the .cpp files might
1109 # exist at a later run. at that time we need to skip them, so that we don't add two
1110 # different rules for the same moc file
1111 GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC)
1113 IF ( NOT _skip AND EXISTS ${_abs_FILE} )
1115 FILE(READ ${_abs_FILE} _contents)
1117 GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH)
1119 STRING(REGEX MATCHALL "#include +[^ ]+\\.moc[\">]" _match "${_contents}")
1121 FOREACH (_current_MOC_INC ${_match})
1122 STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
1123 GET_FILENAME_COMPONENT(_basename ${_current_MOC} NAME_WE)
1124 SET(_header ${_abs_PATH}/${_basename}.h)
1125 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
1126 QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${moc_INCS}" "")
1127 MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
1128 ENDFOREACH (_current_MOC_INC)
1130 ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} )
1131 ENDFOREACH (_current_FILE)
1132 ENDMACRO(QT4_AUTOMOC)
1134 MACRO(QT4_CREATE_TRANSLATION _qm_files)
1137 FOREACH (_file ${ARGN})
1138 GET_FILENAME_COMPONENT(_ext ${_file} EXT)
1139 GET_FILENAME_COMPONENT(_abs_FILE ${_file} ABSOLUTE)
1140 IF(_ext MATCHES "ts")
1141 LIST(APPEND _my_tsfiles ${_abs_FILE})
1142 ELSE(_ext MATCHES "ts")
1143 LIST(APPEND _my_sources ${_abs_FILE})
1144 ENDIF(_ext MATCHES "ts")
1146 FOREACH(_ts_file ${_my_tsfiles})
1147 ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file}
1148 COMMAND ${QT_LUPDATE_EXECUTABLE}
1149 ARGS ${_my_sources} -ts ${_ts_file}
1150 DEPENDS ${_my_sources})
1151 ENDFOREACH(_ts_file)
1152 QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles})
1153 ENDMACRO(QT4_CREATE_TRANSLATION)
1155 MACRO(QT4_ADD_TRANSLATION _qm_files)
1156 FOREACH (_current_FILE ${ARGN})
1157 GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
1158 GET_FILENAME_COMPONENT(qm ${_abs_FILE} NAME_WE)
1159 SET(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm")
1161 ADD_CUSTOM_COMMAND(OUTPUT ${qm}
1162 COMMAND ${QT_LRELEASE_EXECUTABLE}
1163 ARGS ${_abs_FILE} -qm ${qm}
1164 DEPENDS ${_abs_FILE}
1166 SET(${_qm_files} ${${_qm_files}} ${qm})
1167 ENDFOREACH (_current_FILE)
1168 ENDMACRO(QT4_ADD_TRANSLATION)
1174 ######################################
1176 # decide if Qt got found
1178 ######################################
1180 # if the includes,libraries,moc,uic and rcc are found then we have it
1181 IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1182 SET( QT4_FOUND "YES" )
1183 IF( NOT Qt4_FIND_QUIETLY)
1184 MESSAGE(STATUS "Found Qt-Version ${QTVERSION}")
1185 ENDIF( NOT Qt4_FIND_QUIETLY)
1186 ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1187 SET( QT4_FOUND "NO")
1188 SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1189 IF( Qt4_FIND_REQUIRED)
1190 MESSAGE( FATAL_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!")
1191 ENDIF( Qt4_FIND_REQUIRED)
1192 ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1193 SET(QT_FOUND ${QT4_FOUND})
1196 #######################################
1200 #######################################
1201 IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
1202 FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents)
1203 STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG ${_qconfig_FILE_contents})
1204 STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG ${_qconfig_FILE_contents})
1205 STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION ${_qconfig_FILE_contents})
1206 ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
1207 IF("${QT_EDITION}" MATCHES "DesktopLight")
1208 SET(QT_EDITION_DESKTOPLIGHT 1)
1209 ENDIF("${QT_EDITION}" MATCHES "DesktopLight")
1212 ###############################################
1214 # configuration/system dependent settings
1216 ###############################################
1218 SET(QT_GUI_LIB_DEPENDENCIES "")
1219 SET(QT_CORE_LIB_DEPENDENCIES "")
1221 # build using shared Qt needs -DQT_DLL
1222 IF(NOT QT_CONFIG MATCHES "static")
1223 # warning currently only qconfig.pri on Windows potentially contains "static"
1224 # so QT_DLL might not get defined properly on other platforms.
1225 SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_DLL)
1226 ENDIF(NOT QT_CONFIG MATCHES "static")
1229 IF(QT_QCONFIG MATCHES "system-png")
1230 FIND_LIBRARY(QT_PNG_LIBRARY NAMES png)
1231 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY})
1232 MARK_AS_ADVANCED(QT_PNG_LIBRARY)
1233 ENDIF(QT_QCONFIG MATCHES "system-png")
1235 # for X11, get X11 library directory
1237 QT_QUERY_QMAKE(QMAKE_LIBDIR_X11 "QMAKE_LIBDIR_X11")
1241 IF(QT_QCONFIG MATCHES "x11sm")
1242 # ask qmake where the x11 libs are
1243 FIND_LIBRARY(QT_X11_SM_LIBRARY NAMES SM PATHS ${QMAKE_LIBDIR_X11})
1244 FIND_LIBRARY(QT_X11_ICE_LIBRARY NAMES ICE PATHS ${QMAKE_LIBDIR_X11})
1245 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_X11_SM_LIBRARY} ${QT_X11_ICE_LIBRARY})
1246 MARK_AS_ADVANCED(QT_X11_SM_LIBRARY)
1247 MARK_AS_ADVANCED(QT_X11_ICE_LIBRARY)
1248 ENDIF(QT_QCONFIG MATCHES "x11sm")
1251 IF(QT_QCONFIG MATCHES "tablet")
1252 FIND_LIBRARY(QT_XI_LIBRARY NAMES Xi PATHS ${QMAKE_LIBDIR_X11})
1253 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XI_LIBRARY})
1254 MARK_AS_ADVANCED(QT_XI_LIBRARY)
1255 ENDIF(QT_QCONFIG MATCHES "tablet")
1258 IF(QT_QCONFIG MATCHES "xrender")
1259 FIND_LIBRARY(QT_XRENDER_LIBRARY NAMES Xrender PATHS ${QMAKE_LIBDIR_X11})
1260 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XRENDER_LIBRARY})
1261 MARK_AS_ADVANCED(QT_XRENDER_LIBRARY)
1262 ENDIF(QT_QCONFIG MATCHES "xrender")
1265 IF(QT_QCONFIG MATCHES "xrandr")
1266 FIND_LIBRARY(QT_XRANDR_LIBRARY NAMES Xrandr PATHS ${QMAKE_LIBDIR_X11})
1267 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XRANDR_LIBRARY})
1268 MARK_AS_ADVANCED(QT_XRANDR_LIBRARY)
1269 ENDIF(QT_QCONFIG MATCHES "xrandr")
1272 IF(QT_QCONFIG MATCHES "xcursor")
1273 FIND_LIBRARY(QT_XCURSOR_LIBRARY NAMES Xcursor PATHS ${QMAKE_LIBDIR_X11})
1274 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XCURSOR_LIBRARY})
1275 MARK_AS_ADVANCED(QT_XCURSOR_LIBRARY)
1276 ENDIF(QT_QCONFIG MATCHES "xcursor")
1279 IF(QT_QCONFIG MATCHES "xinerama")
1280 FIND_LIBRARY(QT_XINERAMA_LIBRARY NAMES Xinerama PATHS ${QMAKE_LIBDIR_X11})
1281 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XINERAMA_LIBRARY})
1282 MARK_AS_ADVANCED(QT_XINERAMA_LIBRARY)
1283 ENDIF(QT_QCONFIG MATCHES "xinerama")
1286 IF(QT_QCONFIG MATCHES "xfixes")
1287 FIND_LIBRARY(QT_XFIXES_LIBRARY NAMES Xfixes PATHS ${QMAKE_LIBDIR_X11})
1288 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XFIXES_LIBRARY})
1289 MARK_AS_ADVANCED(QT_XFIXES_LIBRARY)
1290 ENDIF(QT_QCONFIG MATCHES "xfixes")
1293 IF(QT_QCONFIG MATCHES "system-freetype")
1294 FIND_LIBRARY(QT_FREETYPE_LIBRARY NAMES freetype)
1295 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY})
1296 MARK_AS_ADVANCED(QT_FREETYPE_LIBRARY)
1297 ENDIF(QT_QCONFIG MATCHES "system-freetype")
1300 IF(QT_QCONFIG MATCHES "fontconfig")
1301 FIND_LIBRARY(QT_FONTCONFIG_LIBRARY NAMES fontconfig)
1302 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY})
1303 MARK_AS_ADVANCED(QT_FONTCONFIG_LIBRARY)
1304 ENDIF(QT_QCONFIG MATCHES "fontconfig")
1307 IF(QT_QCONFIG MATCHES "system-zlib")
1308 FIND_LIBRARY(QT_ZLIB_LIBRARY NAMES z)
1309 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY})
1310 MARK_AS_ADVANCED(QT_ZLIB_LIBRARY)
1311 ENDIF(QT_QCONFIG MATCHES "system-zlib")
1314 IF(QT_QCONFIG MATCHES "glib")
1315 # Qt less than Qt 4.2.0 doesn't use glib
1316 # Qt 4.2.0 uses glib-2.0 (wish we could ask Qt that it uses 2.0)
1317 FIND_LIBRARY(QT_GLIB_LIBRARY NAMES glib-2.0)
1318 FIND_LIBRARY(QT_GTHREAD_LIBRARY NAMES gthread-2.0)
1319 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES}
1320 ${QT_GTHREAD_LIBRARY} ${QT_GLIB_LIBRARY})
1321 MARK_AS_ADVANCED(QT_GLIB_LIBRARY)
1322 MARK_AS_ADVANCED(QT_GTHREAD_LIBRARY)
1323 ENDIF(QT_QCONFIG MATCHES "glib")
1325 ## clock-monotonic, just see if we need to link with rt
1326 IF(QT_QCONFIG MATCHES "clock-monotonic")
1327 SET(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
1328 SET(CMAKE_REQUIRED_LIBRARIES rt)
1329 CHECK_SYMBOL_EXISTS(_POSIX_TIMERS "unistd.h;time.h" QT_POSIX_TIMERS)
1330 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
1332 FIND_LIBRARY(QT_RT_LIBRARY NAMES rt)
1333 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QT_RT_LIBRARY})
1334 MARK_AS_ADVANCED(QT_RT_LIBRARY)
1335 ENDIF(QT_POSIX_TIMERS)
1336 ENDIF(QT_QCONFIG MATCHES "clock-monotonic")
1339 # X11 libraries Qt absolutely depends on
1340 QT_QUERY_QMAKE(QT_LIBS_X11 "QMAKE_LIBS_X11")
1341 SEPARATE_ARGUMENTS(QT_LIBS_X11)
1342 FOREACH(QT_X11_LIB ${QT_LIBS_X11})
1343 STRING(REGEX REPLACE "-l" "" QT_X11_LIB "${QT_X11_LIB}")
1344 SET(QT_TMP_STR "QT_X11_${QT_X11_LIB}_LIBRARY")
1345 FIND_LIBRARY(${QT_TMP_STR} NAMES "${QT_X11_LIB}" PATHS ${QMAKE_LIBDIR_X11})
1346 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${${QT_TMP_STR}})
1347 MARK_AS_ADVANCED(${QT_TMP_STR})
1348 ENDFOREACH(QT_X11_LIB)
1350 QT_QUERY_QMAKE(QT_LIBS_THREAD "QMAKE_LIBS_THREAD")
1351 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QT_LIBS_THREAD})
1353 QT_QUERY_QMAKE(QMAKE_LIBS_DYNLOAD "QMAKE_LIBS_DYNLOAD")
1354 SET (QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QMAKE_LIBS_DYNLOAD})
1359 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} imm32 winmm)
1360 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ws2_32)
1364 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} "-framework Carbon" "-framework QuickTime")
1365 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} "-framework ApplicationServices")
1368 #######################################
1370 # compatibility settings
1372 #######################################
1373 # Backwards compatibility for CMake1.4 and 1.2
1374 SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} )
1375 SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} )
1377 SET( QT_QT_LIBRARY "")
1379 ELSE(QT4_QMAKE_FOUND)
1381 SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1382 IF(Qt4_FIND_REQUIRED)
1383 IF(QT4_INSTALLED_VERSION_TOO_OLD)
1384 MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1385 ELSE(QT4_INSTALLED_VERSION_TOO_OLD)
1386 MESSAGE( FATAL_ERROR "Qt qmake not found!")
1387 ENDIF(QT4_INSTALLED_VERSION_TOO_OLD)
1388 ELSE(Qt4_FIND_REQUIRED)
1389 IF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1390 MESSAGE(STATUS "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1391 ENDIF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1392 ENDIF(Qt4_FIND_REQUIRED)
1394 ENDIF (QT4_QMAKE_FOUND)