2 # This module can be used to find Qt4.
3 # The most important issue is that the Qt4 qmake is available via the system path.
4 # This qmake is then used to detect basically everything else.
5 # This module defines a number of key variables and macros.
6 # First is QT_USE_FILE which is the path to a CMake file that can be included
7 # to compile Qt 4 applications and libraries. By default, the QtCore and QtGui
8 # libraries are loaded. This behavior can be changed by setting one or more
9 # of the following variables to true before doing INCLUDE(${QT_USE_FILE}):
27 # QT_USE_QTASSISTANTCLIENT
30 # QT_USE_QTXMLPATTERNS
33 # The file pointed to by QT_USE_FILE will set up your compile environment
34 # by adding include directories, preprocessor defines, and populate a
35 # QT_LIBRARIES variable containing all the Qt libraries and their dependencies.
36 # Add the QT_LIBRARIES variable to your TARGET_LINK_LIBRARIES.
38 # Typical usage could be something like:
41 # INCLUDE(${QT_USE_FILE})
42 # ADD_EXECUTABLE(myexe main.cpp)
43 # TARGET_LINK_LIBRARIES(myexe ${QT_LIBRARIES})
46 # There are also some files that need processing by some Qt tools such as moc
47 # and uic. Listed below are macros that may be used to process those files.
49 # macro QT4_WRAP_CPP(outfiles inputfile ... OPTIONS ...)
50 # create moc code from a list of files containing Qt class with
51 # the Q_OBJECT declaration. Options may be given to moc, such as those found
52 # when executing "moc -help"
54 # macro QT4_WRAP_UI(outfiles inputfile ... OPTIONS ...)
55 # create code from a list of Qt designer ui files.
56 # Options may be given to uic, such as those found
57 # when executing "uic -help"
59 # macro QT4_ADD_RESOURCES(outfiles inputfile ... OPTIONS ...)
60 # create code from a list of Qt resource files.
61 # Options may be given to rcc, such as those found
62 # when executing "rcc -help"
64 # macro QT4_GENERATE_MOC(inputfile outputfile )
65 # creates a rule to run moc on infile and create outfile.
66 # Use this if for some reason QT4_WRAP_CPP() isn't appropriate, e.g.
67 # because you need a custom filename for the moc file or something similar.
69 # macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... )
70 # This macro is still experimental.
71 # It can be used to have moc automatically handled.
72 # So if you have the files foo.h and foo.cpp, and in foo.h a
73 # a class uses the Q_OBJECT macro, moc has to run on it. If you don't
74 # want to use QT4_WRAP_CPP() (which is reliable and mature), you can insert
76 # in foo.cpp and then give foo.cpp as argument to QT4_AUTOMOC(). This will the
77 # scan all listed files at cmake-time for such included moc files and if it finds
78 # them cause a rule to be generated to run moc at build time on the
79 # accompanying header file foo.h.
80 # If a source file has the SKIP_AUTOMOC property set it will be ignored by this macro.
82 # macro QT4_ADD_DBUS_INTERFACE(outfiles interface basename)
83 # create a the interface header and implementation files with the
84 # given basename from the given interface xml file and add it to
85 # the list of sources.
86 # To disable generating a namespace header, set the source file property
87 # NO_NAMESPACE to TRUE on the interface file.
89 # macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... )
90 # create the interface header and implementation files
91 # for all listed interface xml files
92 # the name will be automatically determined from the name of the xml file
93 # To disable generating namespace headers, set the source file property
94 # NO_NAMESPACE to TRUE for these inputfiles.
96 # macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname [basename] [classname])
97 # create a dbus adaptor (header and implementation file) from the xml file
98 # describing the interface, and add it to the list of sources. The adaptor
99 # forwards the calls to a parent class, defined in parentheader and named
100 # parentclassname. The name of the generated files will be
101 # <basename>adaptor.{cpp,h} where basename defaults to the basename of the xml file.
102 # If <classname> is provided, then it will be used as the classname of the
105 # macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] OPTIONS ...)
106 # generate the xml interface file from the given header.
107 # If the optional argument interfacename is omitted, the name of the
108 # interface file is constructed from the basename of the header with
109 # the suffix .xml appended.
110 # Options may be given to qdbuscpp2xml, such as those found when executing "qdbuscpp2xml --help"
112 # QT_FOUND If false, don't try to use Qt.
113 # QT4_FOUND If false, don't try to use Qt 4.
115 # QT_QTCORE_FOUND True if QtCore was found.
116 # QT_QTGUI_FOUND True if QtGui was found.
117 # QT_QT3SUPPORT_FOUND True if Qt3Support was found.
118 # QT_QTASSISTANT_FOUND True if QtAssistant was found.
119 # QT_QTDBUS_FOUND True if QtDBus was found.
120 # QT_QTDESIGNER_FOUND True if QtDesigner was found.
121 # QT_QTDESIGNERCOMPONENTS True if QtDesignerComponents was found.
122 # QT_QTMOTIF_FOUND True if QtMotif was found.
123 # QT_QTNETWORK_FOUND True if QtNetwork was found.
124 # QT_QTNSPLUGIN_FOUND True if QtNsPlugin was found.
125 # QT_QTOPENGL_FOUND True if QtOpenGL was found.
126 # QT_QTSQL_FOUND True if QtSql was found.
127 # QT_QTXML_FOUND True if QtXml was found.
128 # QT_QTSVG_FOUND True if QtSvg was found.
129 # QT_QTSCRIPT_FOUND True if QtScript was found.
130 # QT_QTTEST_FOUND True if QtTest was found.
131 # QT_QTUITOOLS_FOUND True if QtUiTools was found.
132 # QT_QTASSISTANTCLIENT_FOUND True if QtAssistantClient was found.
133 # QT_QTHELP_FOUND True if QtHelp was found.
134 # QT_QTWEBKIT_FOUND True if QtWebKit was found.
135 # QT_QTXMLPATTERNS_FOUND True if QtXmlPatterns was found.
136 # QT_PHONON_FOUND True if phonon was found.
139 # QT_DEFINITIONS Definitions to use when compiling code that uses Qt.
140 # You do not need to use this if you include QT_USE_FILE.
141 # The QT_USE_FILE will also define QT_DEBUG and QT_NO_DEBUG
142 # to fit your current build type. Those are not contained
145 # QT_INCLUDES List of paths to all include directories of
146 # Qt4 QT_INCLUDE_DIR and QT_QTCORE_INCLUDE_DIR are
147 # always in this variable even if NOTFOUND,
148 # all other INCLUDE_DIRS are
149 # only added if they are found.
150 # You do not need to use this if you include QT_USE_FILE.
153 # Include directories for the Qt modules are listed here.
154 # You do not need to use these variables if you include QT_USE_FILE.
156 # QT_INCLUDE_DIR Path to "include" of Qt4
157 # QT_QT_INCLUDE_DIR Path to "include/Qt"
158 # QT_QT3SUPPORT_INCLUDE_DIR Path to "include/Qt3Support"
159 # QT_QTASSISTANT_INCLUDE_DIR Path to "include/QtAssistant"
160 # QT_QTCORE_INCLUDE_DIR Path to "include/QtCore"
161 # QT_QTDESIGNER_INCLUDE_DIR Path to "include/QtDesigner"
162 # QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR Path to "include/QtDesigner"
163 # QT_QTDBUS_INCLUDE_DIR Path to "include/QtDBus"
164 # QT_QTGUI_INCLUDE_DIR Path to "include/QtGui"
165 # QT_QTMOTIF_INCLUDE_DIR Path to "include/QtMotif"
166 # QT_QTNETWORK_INCLUDE_DIR Path to "include/QtNetwork"
167 # QT_QTNSPLUGIN_INCLUDE_DIR Path to "include/QtNsPlugin"
168 # QT_QTOPENGL_INCLUDE_DIR Path to "include/QtOpenGL"
169 # QT_QTSQL_INCLUDE_DIR Path to "include/QtSql"
170 # QT_QTXML_INCLUDE_DIR Path to "include/QtXml"
171 # QT_QTSVG_INCLUDE_DIR Path to "include/QtSvg"
172 # QT_QTSCRIPT_INCLUDE_DIR Path to "include/QtScript"
173 # QT_QTTEST_INCLUDE_DIR Path to "include/QtTest"
174 # QT_QTASSISTANTCLIENT_INCLUDE_DIR Path to "include/QtAssistant"
175 # QT_QTHELP_INCLUDE_DIR Path to "include/QtHelp"
176 # QT_QTWEBKIT_INCLUDE_DIR Path to "include/QtWebKit"
177 # QT_QTXMLPATTERNS_INCLUDE_DIR Path to "include/QtXmlPatterns"
178 # QT_PHONON_INCLUDE_DIR Path to "include/phonon"
180 # QT_LIBRARY_DIR Path to "lib" of Qt4
182 # QT_PLUGINS_DIR Path to "plugins" for Qt4
184 # For every library of Qt, a QT_QTFOO_LIBRARY variable is defined, with the full path to the library.
186 # So there are the following variables:
187 # The Qt3Support library: QT_QT3SUPPORT_LIBRARY
189 # The QtAssistant library: QT_QTASSISTANT_LIBRARY
191 # The QtCore library: QT_QTCORE_LIBRARY
193 # The QtDBus library: QT_QTDBUS_LIBRARY
195 # The QtDesigner library: QT_QTDESIGNER_LIBRARY
197 # The QtDesignerComponents library: QT_QTDESIGNERCOMPONENTS_LIBRARY
199 # The QtGui library: QT_QTGUI_LIBRARY
201 # The QtMotif library: QT_QTMOTIF_LIBRARY
203 # The QtNetwork library: QT_QTNETWORK_LIBRARY
205 # The QtNsPLugin library: QT_QTNSPLUGIN_LIBRARY
207 # The QtOpenGL library: QT_QTOPENGL_LIBRARY
209 # The QtSql library: QT_QTSQL_LIBRARY
211 # The QtXml library: QT_QTXML_LIBRARY
213 # The QtSvg library: QT_QTSVG_LIBRARY
215 # The QtScript library: QT_QTSCRIPT_LIBRARY
217 # The QtTest library: QT_QTTEST_LIBRARY
219 # The qtmain library for Windows QT_QTMAIN_LIBRARY
221 # The QtUiTools library: QT_QTUITOOLS_LIBRARY
224 # The QtAssistantClient library: QT_QTASSISTANTCLIENT_LIBRARY
226 # The QtHelp library: QT_QTHELP_LIBRARY
228 # The QtWebKit library: QT_QTWEBKIT_LIBRARY
230 # The QtXmlPatterns library: QT_QTXMLPATTERNS_LIBRARY
232 # The Phonon library: QT_PHONON_LIBRARY
237 # also defined, but NOT for general use are
238 # QT_MOC_EXECUTABLE Where to find the moc tool.
239 # QT_UIC_EXECUTABLE Where to find the uic tool.
240 # QT_UIC3_EXECUTABLE Where to find the uic3 tool.
241 # QT_RCC_EXECUTABLE Where to find the rcc tool
242 # QT_DBUSCPP2XML_EXECUTABLE Where to find the qdbuscpp2xml tool.
243 # QT_DBUSXML2CPP_EXECUTABLE Where to find the qdbusxml2cpp tool.
244 # QT_LUPDATE_EXECUTABLE Where to find the lupdate tool.
245 # QT_LRELEASE_EXECUTABLE Where to find the lrelease tool.
247 # QT_DOC_DIR Path to "doc" of Qt4
248 # QT_MKSPECS_DIR Path to "mkspecs" of Qt4
251 # These are around for backwards compatibility
253 # QT_WRAP_CPP Set true if QT_MOC_EXECUTABLE is found
254 # QT_WRAP_UI Set true if QT_UIC_EXECUTABLE is found
256 # These variables do _NOT_ have any effect anymore (compared to FindQt.cmake)
257 # QT_MT_REQUIRED Qt4 is now always multithreaded
259 # These variables are set to "" Because Qt structure changed
260 # (They make no sense in Qt4)
261 # QT_QT_LIBRARY Qt-Library is now split
263 # Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
264 # See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
267 # Check already done in this cmake run, nothing more to do
269 else (QT4_QMAKE_FOUND)
271 # check that QT_NO_DEBUG is defined for release configurations
272 MACRO(QT_CHECK_FLAG_EXISTS FLAG VAR DOC)
273 IF(NOT ${VAR} MATCHES "${FLAG}")
274 SET(${VAR} "${${VAR}} ${FLAG}"
275 CACHE STRING "Flags used by the compiler during ${DOC} builds." FORCE)
276 ENDIF(NOT ${VAR} MATCHES "${FLAG}")
277 ENDMACRO(QT_CHECK_FLAG_EXISTS FLAG VAR)
278 QT_CHECK_FLAG_EXISTS(-DQT_NO_DEBUG CMAKE_CXX_FLAGS_RELWITHDEBINFO "Release with Debug Info")
279 QT_CHECK_FLAG_EXISTS(-DQT_NO_DEBUG CMAKE_CXX_FLAGS_RELEASE "release")
280 QT_CHECK_FLAG_EXISTS(-DQT_NO_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL "release minsize")
282 INCLUDE(CheckSymbolExists)
283 INCLUDE(MacroAddFileDependencies)
284 INCLUDE(MacroPushRequiredVars)
286 SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake)
288 SET( QT_DEFINITIONS "")
290 IF (WIN32 AND NOT STATIC)
291 SET(QT_DEFINITIONS -DQT_DLL)
292 ENDIF(WIN32 AND NOT STATIC)
294 SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE)
296 # macro for asking qmake to process pro files
297 MACRO(QT_QUERY_QMAKE outvar invar)
298 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake/tmp.pro
299 "message(CMAKE_MESSAGE<$$${invar}>)")
301 # Invoke qmake with the tmp.pro program to get the desired
302 # information. Use the same variable for both stdout and stderr
303 # to make sure we get the output on all platforms.
304 EXECUTE_PROCESS(COMMAND ${QT_QMAKE_EXECUTABLE}
306 ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake
307 OUTPUT_VARIABLE _qmake_query_output
308 RESULT_VARIABLE _qmake_result
309 ERROR_VARIABLE _qmake_query_output )
312 "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake")
315 MESSAGE(WARNING " querying qmake for ${invar}. qmake reported:\n${_qmake_query_output}")
317 STRING(REGEX REPLACE ".*CMAKE_MESSAGE<([^>]*).*" "\\1" ${outvar} "${_qmake_query_output}")
320 ENDMACRO(QT_QUERY_QMAKE)
322 GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME)
324 FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 PATHS
325 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
326 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
327 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]/bin"
331 IF (QT_QMAKE_EXECUTABLE)
333 SET(QT4_QMAKE_FOUND FALSE)
335 EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
337 # check for qt3 qmake and then try and find qmake4 or qmake-qt4 in the path
338 IF("${QTVERSION}" MATCHES "Unknown")
339 SET(QT_QMAKE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE)
340 FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 PATHS
341 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
342 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
345 IF(QT_QMAKE_EXECUTABLE)
346 EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE}
347 ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
348 ENDIF(QT_QMAKE_EXECUTABLE)
349 ENDIF("${QTVERSION}" MATCHES "Unknown")
351 # check that we found the Qt4 qmake, Qt3 qmake output won't match here
352 STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" qt_version_tmp "${QTVERSION}")
355 # we need at least version 4.0.0
356 IF (NOT QT_MIN_VERSION)
357 SET(QT_MIN_VERSION "4.0.0")
358 ENDIF (NOT QT_MIN_VERSION)
360 #now parse the parts of the user given version string into variables
361 STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" req_qt_major_vers "${QT_MIN_VERSION}")
362 IF (NOT req_qt_major_vers)
363 MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"4.0.1\"")
364 ENDIF (NOT req_qt_major_vers)
366 # now parse the parts of the user given version string into variables
367 STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}")
368 STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers "${QT_MIN_VERSION}")
369 STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}")
371 IF (NOT req_qt_major_vers EQUAL 4)
372 MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", major version 4 is required, e.g. \"4.0.1\"")
373 ENDIF (NOT req_qt_major_vers EQUAL 4)
375 # and now the version string given by qmake
376 STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" found_qt_major_vers "${QTVERSION}")
377 STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" found_qt_minor_vers "${QTVERSION}")
378 STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" found_qt_patch_vers "${QTVERSION}")
380 # compute an overall version number which can be compared at once
381 MATH(EXPR req_vers "${req_qt_major_vers}*10000 + ${req_qt_minor_vers}*100 + ${req_qt_patch_vers}")
382 MATH(EXPR found_vers "${found_qt_major_vers}*10000 + ${found_qt_minor_vers}*100 + ${found_qt_patch_vers}")
384 IF (found_vers LESS req_vers)
385 SET(QT4_QMAKE_FOUND FALSE)
386 SET(QT4_INSTALLED_VERSION_TOO_OLD TRUE)
387 ELSE (found_vers LESS req_vers)
388 SET(QT4_QMAKE_FOUND TRUE)
389 ENDIF (found_vers LESS req_vers)
390 ENDIF (qt_version_tmp)
392 ENDIF (QT_QMAKE_EXECUTABLE)
398 get_filename_component(_DIR ${QT_QMAKE_EXECUTABLE} PATH )
399 get_filename_component(QT_INSTALL_DIR ${_DIR} PATH )
402 # ask qmake for the library dir
404 IF (NOT QT_LIBRARY_DIR)
405 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
406 ARGS "-query QT_INSTALL_LIBS"
407 OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP )
408 # make sure we have / and not \ as qmake gives on windows
409 FILE(TO_CMAKE_PATH "${QT_LIBRARY_DIR_TMP}" QT_LIBRARY_DIR_TMP)
410 IF(EXISTS "${QT_LIBRARY_DIR_TMP}")
411 SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir")
412 ELSE(EXISTS "${QT_LIBRARY_DIR_TMP}")
413 MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}")
414 MESSAGE("Warning: ${QT_LIBRARY_DIR_TMP} does NOT exist, Qt must NOT be installed correctly.")
415 ENDIF(EXISTS "${QT_LIBRARY_DIR_TMP}")
416 ENDIF(NOT QT_LIBRARY_DIR)
419 IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
420 SET(QT_USE_FRAMEWORKS ON
421 CACHE BOOL "Set to ON if Qt build uses frameworks.")
422 ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
423 SET(QT_USE_FRAMEWORKS OFF
424 CACHE BOOL "Set to ON if Qt build uses frameworks.")
425 ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
427 MARK_AS_ADVANCED(QT_USE_FRAMEWORKS)
430 # ask qmake for the binary dir
431 IF (QT_LIBRARY_DIR AND NOT QT_BINARY_DIR)
432 EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE}
433 ARGS "-query QT_INSTALL_BINS"
434 OUTPUT_VARIABLE qt_bins )
435 # make sure we have / and not \ as qmake gives on windows
436 FILE(TO_CMAKE_PATH "${qt_bins}" qt_bins)
437 SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "")
438 ENDIF (QT_LIBRARY_DIR AND NOT QT_BINARY_DIR)
440 # ask qmake for the include dir
441 IF (QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR)
442 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
443 ARGS "-query QT_INSTALL_HEADERS"
444 OUTPUT_VARIABLE qt_headers )
445 # make sure we have / and not \ as qmake gives on windows
446 FILE(TO_CMAKE_PATH "${qt_headers}" qt_headers)
447 SET(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "")
448 ENDIF(QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR)
451 # ask qmake for the documentation directory
452 IF (QT_LIBRARY_DIR AND NOT QT_DOC_DIR)
453 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
454 ARGS "-query QT_INSTALL_DOCS"
455 OUTPUT_VARIABLE qt_doc_dir )
456 # make sure we have / and not \ as qmake gives on windows
457 FILE(TO_CMAKE_PATH "${qt_doc_dir}" qt_doc_dir)
458 SET(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs")
459 ENDIF (QT_LIBRARY_DIR AND NOT QT_DOC_DIR)
461 # ask qmake for the mkspecs directory
462 IF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR)
463 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
464 ARGS "-query QMAKE_MKSPECS"
465 OUTPUT_VARIABLE qt_mkspecs_dirs )
466 # do not replace : on windows as it might be a drive letter
467 # and windows should already use ; as a separator
469 STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}")
471 FIND_PATH(QT_MKSPECS_DIR qconfig.pri PATHS ${qt_mkspecs_dirs}
472 DOC "The location of the Qt mkspecs containing qconfig.pri"
474 ENDIF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR)
476 # ask qmake for the plugins directory
477 IF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR)
478 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
479 ARGS "-query QT_INSTALL_PLUGINS"
480 OUTPUT_VARIABLE qt_plugins_dir )
481 # make sure we have / and not \ as qmake gives on windows
482 FILE(TO_CMAKE_PATH "${qt_plugins_dir}" qt_plugins_dir)
483 SET(QT_PLUGINS_DIR ${qt_plugins_dir} CACHE PATH "The location of the Qt plugins")
484 ENDIF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR)
485 ########################################
487 # Setting the INCLUDE-Variables
489 ########################################
491 FIND_PATH(QT_QTCORE_INCLUDE_DIR QtGlobal
492 ${QT_HEADERS_DIR}/QtCore
493 ${QT_LIBRARY_DIR}/QtCore.framework/Headers
497 # Set QT_INCLUDE_DIR by removine "/QtCore" in the string ${QT_QTCORE_INCLUDE_DIR}
498 IF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
499 IF (QT_USE_FRAMEWORKS)
500 SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR})
501 ELSE (QT_USE_FRAMEWORKS)
502 STRING( REGEX REPLACE "/QtCore$" "" qt4_include_dir ${QT_QTCORE_INCLUDE_DIR})
503 SET( QT_INCLUDE_DIR ${qt4_include_dir} CACHE PATH "")
504 ENDIF (QT_USE_FRAMEWORKS)
505 ENDIF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
507 IF( NOT QT_INCLUDE_DIR)
508 IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
509 MESSAGE( FATAL_ERROR "Could NOT find QtGlobal header")
510 ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
511 ENDIF( NOT QT_INCLUDE_DIR)
513 #############################################
515 # Find out what window system we're using
517 #############################################
518 # Save required includes and required_flags variables
519 macro_push_required_vars()
520 # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES
521 SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}")
522 # On Mac OS X when Qt has framework support, also add the framework path
523 IF( QT_USE_FRAMEWORKS )
524 SET(CMAKE_REQUIRED_FLAGS "-F${QT_LIBRARY_DIR} ")
525 ENDIF( QT_USE_FRAMEWORKS )
526 # Check for Window system symbols (note: only one should end up being set)
527 CHECK_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11)
528 CHECK_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN)
529 CHECK_SYMBOL_EXISTS(Q_WS_QWS "QtCore/qglobal.h" Q_WS_QWS)
530 CHECK_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC)
532 IF (QT_QTCOPY_REQUIRED)
533 CHECK_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY)
534 IF (NOT QT_IS_QTCOPY)
535 MESSAGE(FATAL_ERROR "qt-copy is required, but hasn't been found")
536 ENDIF (NOT QT_IS_QTCOPY)
537 ENDIF (QT_QTCOPY_REQUIRED)
539 # Restore CMAKE_REQUIRED_INCLUDES+CMAKE_REQUIRED_FLAGS variables
540 macro_pop_required_vars()
542 #############################################
544 IF (QT_USE_FRAMEWORKS)
545 SET(QT_DEFINITIONS ${QT_DEFINITIONS} -F${QT_LIBRARY_DIR} -L${QT_LIBRARY_DIR} )
546 ENDIF (QT_USE_FRAMEWORKS)
548 # Set QT_QT3SUPPORT_INCLUDE_DIR
549 FIND_PATH(QT_QT3SUPPORT_INCLUDE_DIR Qt3Support
551 ${QT_INCLUDE_DIR}/Qt3Support
552 ${QT_LIBRARY_DIR}/Qt3Support.framework/Headers
556 # Set QT_QT_INCLUDE_DIR
557 FIND_PATH(QT_QT_INCLUDE_DIR qglobal.h
560 ${QT_LIBRARY_DIR}/QtCore.framework/Headers
564 # Set QT_QTGUI_INCLUDE_DIR
565 FIND_PATH(QT_QTGUI_INCLUDE_DIR QtGui
567 ${QT_INCLUDE_DIR}/QtGui
568 ${QT_LIBRARY_DIR}/QtGui.framework/Headers
572 # Set QT_QTSVG_INCLUDE_DIR
573 FIND_PATH(QT_QTSVG_INCLUDE_DIR QtSvg
575 ${QT_INCLUDE_DIR}/QtSvg
576 ${QT_LIBRARY_DIR}/QtSvg.framework/Headers
580 # Set QT_QTSCRIPT_INCLUDE_DIR
581 FIND_PATH(QT_QTSCRIPT_INCLUDE_DIR QtScript
583 ${QT_INCLUDE_DIR}/QtScript
584 ${QT_LIBRARY_DIR}/QtScript.framework/Headers
588 # Set QT_QTTEST_INCLUDE_DIR
589 FIND_PATH(QT_QTTEST_INCLUDE_DIR QtTest
591 ${QT_INCLUDE_DIR}/QtTest
592 ${QT_LIBRARY_DIR}/QtTest.framework/Headers
596 # Set QT_QTUITOOLS_INCLUDE_DIR
597 FIND_PATH(QT_QTUITOOLS_INCLUDE_DIR QtUiTools
599 ${QT_INCLUDE_DIR}/QtUiTools
600 ${QT_LIBRARY_DIR}/QtUiTools.framework/Headers
604 # Set QT_QTMOTIF_INCLUDE_DIR
606 FIND_PATH(QT_QTMOTIF_INCLUDE_DIR QtMotif
608 ${QT_INCLUDE_DIR}/QtMotif
612 # Set QT_QTNETWORK_INCLUDE_DIR
613 FIND_PATH(QT_QTNETWORK_INCLUDE_DIR QtNetwork
615 ${QT_INCLUDE_DIR}/QtNetwork
616 ${QT_LIBRARY_DIR}/QtNetwork.framework/Headers
620 # Set QT_QTNSPLUGIN_INCLUDE_DIR
621 FIND_PATH(QT_QTNSPLUGIN_INCLUDE_DIR QtNsPlugin
623 ${QT_INCLUDE_DIR}/QtNsPlugin
624 ${QT_LIBRARY_DIR}/QtNsPlugin.framework/Headers
628 # Set QT_QTOPENGL_INCLUDE_DIR
629 FIND_PATH(QT_QTOPENGL_INCLUDE_DIR QtOpenGL
631 ${QT_INCLUDE_DIR}/QtOpenGL
632 ${QT_LIBRARY_DIR}/QtOpenGL.framework/Headers
636 # Set QT_QTSQL_INCLUDE_DIR
637 FIND_PATH(QT_QTSQL_INCLUDE_DIR QtSql
639 ${QT_INCLUDE_DIR}/QtSql
640 ${QT_LIBRARY_DIR}/QtSql.framework/Headers
644 # Set QT_QTXML_INCLUDE_DIR
645 FIND_PATH(QT_QTXML_INCLUDE_DIR QtXml
647 ${QT_INCLUDE_DIR}/QtXml
648 ${QT_LIBRARY_DIR}/QtXml.framework/Headers
652 # Set QT_QTASSISTANT_INCLUDE_DIR
653 FIND_PATH(QT_QTASSISTANT_INCLUDE_DIR QtAssistant
655 ${QT_INCLUDE_DIR}/QtAssistant
656 ${QT_HEADERS_DIR}/QtAssistant
657 ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers
661 # Set QT_QTDESIGNER_INCLUDE_DIR
662 FIND_PATH(QT_QTDESIGNER_INCLUDE_DIR QDesignerComponents
664 ${QT_INCLUDE_DIR}/QtDesigner
665 ${QT_HEADERS_DIR}/QtDesigner
666 ${QT_LIBRARY_DIR}/QtDesigner.framework/Headers
670 # Set QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR
671 FIND_PATH(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR QDesignerComponents
673 ${QT_INCLUDE_DIR}/QtDesigner
674 ${QT_HEADERS_DIR}/QtDesigner
678 # Set QT_QTDBUS_INCLUDE_DIR
679 FIND_PATH(QT_QTDBUS_INCLUDE_DIR QtDBus
681 ${QT_INCLUDE_DIR}/QtDBus
682 ${QT_HEADERS_DIR}/QtDBus
683 ${QT_LIBRARY_DIR}/QtDBus.framework/Headers
687 # Set QT_QTASSISTANTCLIENT_INCLUDE_DIR
688 FIND_PATH(QT_QTASSISTANTCLIENT_INCLUDE_DIR QAssistantClient
690 ${QT_INCLUDE_DIR}/QtAssistant
691 ${QT_HEADERS_DIR}/QtAssistant
695 # Set QT_QTHELP_INCLUDE_DIR
696 FIND_PATH(QT_QTHELP_INCLUDE_DIR QtHelp
698 ${QT_INCLUDE_DIR}/QtHelp
699 ${QT_HEADERS_DIR}/QtHelp
703 # Set QT_QTWEBKIT_INCLUDE_DIR
704 FIND_PATH(QT_QTWEBKIT_INCLUDE_DIR QtWebKit
706 ${QT_INCLUDE_DIR}/QtWebKit
707 ${QT_HEADERS_DIR}/QtWebKit
711 # Set QT_QTXMLPATTERNS_INCLUDE_DIR
712 FIND_PATH(QT_QTXMLPATTERNS_INCLUDE_DIR QtXmlPatterns
714 ${QT_INCLUDE_DIR}/QtXmlPatterns
715 ${QT_HEADERS_DIR}/QtXmlPatterns
719 # Set QT_PHONON_INCLUDE_DIR
720 FIND_PATH(QT_PHONON_INCLUDE_DIR phonon
722 ${QT_INCLUDE_DIR}/phonon
726 # Make variables changeble to the advanced user
727 MARK_AS_ADVANCED( QT_LIBRARY_DIR QT_INCLUDE_DIR QT_QT_INCLUDE_DIR QT_DOC_DIR QT_MKSPECS_DIR QT_PLUGINS_DIR)
730 SET( QT_INCLUDES ${QT_QT_INCLUDE_DIR} ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} )
732 ########################################
734 # Setting the LIBRARY-Variables
736 ########################################
738 IF (QT_USE_FRAMEWORKS)
739 # If FIND_LIBRARY found libraries in Apple frameworks, we would NOT have
740 # to jump through these hoops.
741 IF(EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
742 SET(QT_QTCORE_FOUND TRUE)
743 SET(QT_QTCORE_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtCore" CACHE STRING "The QtCore library.")
744 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
745 SET(QT_QTCORE_FOUND FALSE)
746 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
748 IF(EXISTS ${QT_LIBRARY_DIR}/QtGui.framework)
749 SET(QT_QTGUI_FOUND TRUE)
750 SET(QT_QTGUI_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtGui" CACHE STRING "The QtGui library.")
751 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtGui.framework)
752 SET(QT_QTGUI_FOUND FALSE)
753 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtGui.framework)
755 IF(EXISTS ${QT_LIBRARY_DIR}/Qt3Support.framework)
756 SET(QT_QT3SUPPORT_FOUND TRUE)
757 SET(QT_QT3SUPPORT_LIBRARY "-F${QT_LIBRARY_DIR} -framework Qt3Support" CACHE STRING "The Qt3Support library.")
758 ELSE(EXISTS ${QT_LIBRARY_DIR}/Qt3Support.framework)
759 SET(QT_QT3SUPPORT_FOUND FALSE)
760 ENDIF(EXISTS ${QT_LIBRARY_DIR}/Qt3Support.framework)
762 IF(EXISTS ${QT_LIBRARY_DIR}/QtNetwork.framework)
763 SET(QT_QTNETWORK_FOUND TRUE)
764 SET(QT_QTNETWORK_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtNetwork" CACHE STRING "The QtNetwork library.")
765 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtNetwork.framework)
766 SET(QT_QTNETWORK_FOUND FALSE)
767 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtNetwork.framework)
769 IF(EXISTS ${QT_LIBRARY_DIR}/QtOpenGL.framework)
770 SET(QT_QTOPENGL_FOUND TRUE)
771 SET(QT_QTOPENGL_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtOpenGL" CACHE STRING "The QtOpenGL library.")
772 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtOpenGL.framework)
773 SET(QT_QTOPENGL_FOUND FALSE)
774 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtOpenGL.framework)
776 IF(EXISTS ${QT_LIBRARY_DIR}/QtSql.framework)
777 SET(QT_QTSQL_FOUND TRUE)
778 SET(QT_QTSQL_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtSql" CACHE STRING "The QtSql library.")
779 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtSql.framework)
780 SET(QT_QTSQL_FOUND FALSE)
781 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtSql.framework)
783 IF(EXISTS ${QT_LIBRARY_DIR}/QtXml.framework)
784 SET(QT_QTXML_FOUND TRUE)
785 SET(QT_QTXML_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtXml" CACHE STRING "The QtXml library.")
786 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtXml.framework)
787 SET(QT_QTXML_FOUND FALSE)
788 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtXml.framework)
790 IF(EXISTS ${QT_LIBRARY_DIR}/QtSvg.framework)
791 SET(QT_QTSVG_FOUND TRUE)
792 SET(QT_QTSVG_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtSvg" CACHE STRING "The QtSvg library.")
793 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtSvg.framework)
794 SET(QT_QTSVG_FOUND FALSE)
795 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtSvg.framework)
797 IF(EXISTS ${QT_LIBRARY_DIR}/QtDBus.framework)
798 SET(QT_QTDBUS_FOUND TRUE)
799 SET(QT_QTDBUS_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtDBus" CACHE STRING "The QtDBus library.")
800 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtDBus.framework)
801 SET(QT_QTDBUS_FOUND FALSE)
802 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtDBus.framework)
804 IF(EXISTS ${QT_LIBRARY_DIR}/QtTest.framework)
805 SET(QT_QTTEST_FOUND TRUE)
806 SET(QT_QTTEST_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtTest" CACHE STRING "The QtTest library.")
807 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtTest.framework)
808 SET(QT_QTTEST_FOUND FALSE)
809 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtTest.framework)
811 IF(EXISTS ${QT_LIBRARY_DIR}/QtAssistantClient.framework)
812 SET(QT_QTASSISTANTCLIENT_FOUND TRUE)
813 SET(QT_QTASSISTANTCLIENT_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtAssistantClient" CACHE STRING "The QtAssistantClient library.")
814 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtAssistantClient.framework)
815 SET(QT_QTASSISTANTCLIENT_FOUND FALSE)
816 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtAssistantClient.framework)
818 IF(EXISTS ${QT_LIBRARY_DIR}/QtWebKit.framework)
819 SET(QT_QTWEBKIT_FOUND TRUE)
820 SET(QT_QTWEBKIT_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtWebKit" CACHE STRING "The QtWebKit library.")
821 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtWebKit.framework)
822 SET(QT_QTWEBKIT_FOUND FALSE)
823 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtWebKit.framework)
825 IF(EXISTS ${QT_LIBRARY_DIR}/QtXmlPatterns.framework)
826 SET(QT_QTXMLPATTERNS_FOUND TRUE)
827 SET(QT_QTXMLPATTERNS_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtXmlPatterns" CACHE STRING "The QtXmlPatterns library.")
828 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtXmlPatterns.framework)
829 SET(QT_QTXMLPATTERNS_FOUND FALSE)
830 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtXmlPatterns.framework)
833 # WTF? why don't we have frameworks? :P
834 # Set QT_QTUITOOLS_LIBRARY
835 FIND_LIBRARY(QT_QTUITOOLS_LIBRARY NAMES QtUiTools QtUiTools4 PATHS ${QT_LIBRARY_DIR} )
836 # Set QT_QTSCRIPT_LIBRARY
837 FIND_LIBRARY(QT_QTSCRIPT_LIBRARY NAMES QtScript QtScript4 PATHS ${QT_LIBRARY_DIR} )
839 ELSE (QT_USE_FRAMEWORKS)
841 # Set QT_QTCORE_LIBRARY by searching for a lib with "QtCore." as part of the filename
842 FIND_LIBRARY(QT_QTCORE_LIBRARY NAMES QtCore QtCore4 QtCored4 QtCore_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH )
844 # Set QT_QT3SUPPORT_LIBRARY
845 FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY NAMES Qt3Support Qt3Support_debug Qt3Support4 Qt3Supportd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
847 # Set QT_QTGUI_LIBRARY
848 FIND_LIBRARY(QT_QTGUI_LIBRARY NAMES QtGui QtGui_debug QtGui_debug QtGui4 QtGuid4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
850 # Set QT_QTMOTIF_LIBRARY
852 FIND_LIBRARY(QT_QTMOTIF_LIBRARY NAMES QtMotif QtMotif_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
855 # Set QT_QTNETWORK_LIBRARY
856 FIND_LIBRARY(QT_QTNETWORK_LIBRARY NAMES QtNetwork QtNetwork_debug QtNetwork4 QtNetworkd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
858 # Set QT_QTNSPLUGIN_LIBRARY
859 FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY NAMES QtNsPlugin QtNsPlugin_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
861 # Set QT_QTOPENGL_LIBRARY
862 FIND_LIBRARY(QT_QTOPENGL_LIBRARY NAMES QtOpenGL QtOpenGL_debug QtOpenGL4 QtOpenGLd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
864 # Set QT_QTSQL_LIBRARY
865 FIND_LIBRARY(QT_QTSQL_LIBRARY NAMES QtSql QtSql_debug QtSql4 QtSqld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
867 # Set QT_QTXML_LIBRARY
868 FIND_LIBRARY(QT_QTXML_LIBRARY NAMES QtXml QtXml_debug QtXml4 QtXmld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
870 # Set QT_QTSVG_LIBRARY
871 FIND_LIBRARY(QT_QTSVG_LIBRARY NAMES QtSvg QtSvg_debug QtSvg4 QtSvgd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
873 # Set QT_QTSCRIPT_LIBRARY
874 FIND_LIBRARY(QT_QTSCRIPT_LIBRARY NAMES QtScript QtScript_debug QtScript4 QtScriptd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
876 # Set QT_QTUITOOLS_LIBRARY
877 FIND_LIBRARY(QT_QTUITOOLS_LIBRARY NAMES QtUiTools QtUiTools_debug QtUiTools4 QtUiToolsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
879 # Set QT_QTTEST_LIBRARY
880 FIND_LIBRARY(QT_QTTEST_LIBRARY NAMES QtTest QtTest_debug QtTest4 QtTestd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
882 FIND_LIBRARY(QT_QTDBUS_LIBRARY NAMES QtDBus QtDBus_debug QtDBus4 QtDBusd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
884 FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY NAMES QtAssistantClient QtAssistantClient_debug QtAssistantClient4 QtAssistantClientd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
886 FIND_LIBRARY(QT_QTHELP_LIBRARY NAMES QtHelp QtHelp_debug QtHelp4 QtHelpd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
888 FIND_LIBRARY(QT_QTWEBKIT_LIBRARY NAMES QtWebKit QtWebKit_debug QtWebKit4 QtWebKitd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
890 FIND_LIBRARY(QT_QTXMLPATTERNS_LIBRARY NAMES QtXmlPatterns QtXmlPatterns_debug QtXmlPatterns4 QtXmlPatternsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
892 FIND_LIBRARY(QT_PHONON_LIBRARY NAMES phonon phonon4 phonon_debug phonond4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
896 FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE NAMES QtCore4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
897 FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG NAMES QtCored4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
898 FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_RELEASE NAMES Qt3Support4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
899 FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG NAMES Qt3Supportd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
900 FIND_LIBRARY(QT_QTGUI_LIBRARY_RELEASE NAMES QtGui4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
901 FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG NAMES QtGuid4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
902 FIND_LIBRARY(QT_QTNETWORK_LIBRARY_RELEASE NAMES QtNetwork4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
903 FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG NAMES QtNetworkd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
904 FIND_LIBRARY(QT_QTOPENGL_LIBRARY_RELEASE NAMES QtOpenGL4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
905 FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG NAMES QtOpenGLd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
906 FIND_LIBRARY(QT_QTSQL_LIBRARY_RELEASE NAMES QtSql4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
907 FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG NAMES QtSqld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
908 FIND_LIBRARY(QT_QTXML_LIBRARY_RELEASE NAMES QtXml4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
909 FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG NAMES QtXmld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
910 FIND_LIBRARY(QT_QTSVG_LIBRARY_RELEASE NAMES QtSvg4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
911 FIND_LIBRARY(QT_QTSVG_LIBRARY_DEBUG NAMES QtSvgd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
912 FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_RELEASE NAMES QtScript4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
913 FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_DEBUG NAMES QtScriptd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
914 FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools QtUiTools4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
915 FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_DEBUG NAMES QtUiToolsd QtUiToolsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
916 FIND_LIBRARY(QT_QTTEST_LIBRARY_RELEASE NAMES QtTest4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
917 FIND_LIBRARY(QT_QTTEST_LIBRARY_DEBUG NAMES QtTestd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
918 FIND_LIBRARY(QT_QTDBUS_LIBRARY_RELEASE NAMES QtDBus4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
919 FIND_LIBRARY(QT_QTDBUS_LIBRARY_DEBUG NAMES QtDBusd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
920 FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
921 FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistantClientd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
922 FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_RELEASE NAMES QtDesigner4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
923 FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_DEBUG NAMES QtDesignerd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
924 FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
925 FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NAMES QtDesignerComponentsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
926 FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
927 FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmaind PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
929 ENDIF (QT_USE_FRAMEWORKS)
931 IF( NOT QT_QTCORE_LIBRARY )
932 IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
933 MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.")
934 ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
935 ENDIF( NOT QT_QTCORE_LIBRARY )
937 # Set QT_QTASSISTANT_LIBRARY
938 FIND_LIBRARY(QT_QTASSISTANT_LIBRARY NAMES QtAssistantClient QtAssistantClient4 QtAssistant QtAssistant4 QtAssistantd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
940 # Set QT_QTDESIGNER_LIBRARY
941 FIND_LIBRARY(QT_QTDESIGNER_LIBRARY NAMES QtDesigner QtDesigner_debug QtDesigner4 QtDesignerd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
943 # Set QT_QTDESIGNERCOMPONENTS_LIBRARY
944 FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY NAMES QtDesignerComponents QtDesignerComponents_debug QtDesignerComponents4 QtDesignerComponentsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
946 # Set QT_QTMAIN_LIBRARY
948 FIND_LIBRARY(QT_QTMAIN_LIBRARY NAMES qtmain qtmaind PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
951 ############################################
953 # Check the existence of the libraries.
955 ############################################
957 MACRO (_QT4_ADJUST_LIB_VARS basename)
958 IF (QT_${basename}_LIBRARY OR QT_${basename}_LIBRARY_DEBUG)
962 IF (QT_${basename}_LIBRARY_RELEASE AND QT_${basename}_LIBRARY_DEBUG)
963 SET(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
964 ENDIF (QT_${basename}_LIBRARY_RELEASE AND QT_${basename}_LIBRARY_DEBUG)
966 # Only debug was found
967 IF (NOT QT_${basename}_LIBRARY_RELEASE AND QT_${basename}_LIBRARY_DEBUG)
968 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG})
969 ENDIF (NOT QT_${basename}_LIBRARY_RELEASE AND QT_${basename}_LIBRARY_DEBUG)
971 # Only release was found
972 IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
973 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE})
974 ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
976 # Hmm, is this used anywhere ? Yes, in UseQt4.cmake. We are currently incompatible :-(
977 SET(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY} debug ${QT_${basename}_LIBRARY_DEBUG})
981 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE FILEPATH "The Qt ${basename} library")
983 IF (QT_${basename}_LIBRARY)
984 SET(QT_${basename}_FOUND 1)
985 ENDIF (QT_${basename}_LIBRARY)
987 ENDIF (QT_${basename}_LIBRARY OR QT_${basename}_LIBRARY_DEBUG)
989 IF (QT_${basename}_INCLUDE_DIR)
990 #add the include directory to QT_INCLUDES
991 SET(QT_INCLUDES "${QT_${basename}_INCLUDE_DIR}" ${QT_INCLUDES})
992 ENDIF (QT_${basename}_INCLUDE_DIR)
994 # Make variables changeble to the advanced user
995 MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_INCLUDE_DIR)
996 ENDMACRO (_QT4_ADJUST_LIB_VARS)
999 # Set QT_xyz_LIBRARY variable and add
1000 # library include path to QT_INCLUDES
1001 _QT4_ADJUST_LIB_VARS(QTCORE)
1002 _QT4_ADJUST_LIB_VARS(QTGUI)
1003 _QT4_ADJUST_LIB_VARS(QT3SUPPORT)
1004 _QT4_ADJUST_LIB_VARS(QTASSISTANT)
1005 _QT4_ADJUST_LIB_VARS(QTDESIGNER)
1006 _QT4_ADJUST_LIB_VARS(QTDESIGNERCOMPONENTS)
1007 _QT4_ADJUST_LIB_VARS(QTNETWORK)
1008 _QT4_ADJUST_LIB_VARS(QTNSPLUGIN)
1009 _QT4_ADJUST_LIB_VARS(QTOPENGL)
1010 _QT4_ADJUST_LIB_VARS(QTSQL)
1011 _QT4_ADJUST_LIB_VARS(QTXML)
1012 _QT4_ADJUST_LIB_VARS(QTSVG)
1013 _QT4_ADJUST_LIB_VARS(QTSCRIPT)
1014 _QT4_ADJUST_LIB_VARS(QTUITOOLS)
1015 _QT4_ADJUST_LIB_VARS(QTTEST)
1016 _QT4_ADJUST_LIB_VARS(QTDBUS)
1017 _QT4_ADJUST_LIB_VARS(QTASSISTANTCLIENT)
1018 _QT4_ADJUST_LIB_VARS(QTHELP)
1019 _QT4_ADJUST_LIB_VARS(QTWEBKIT)
1020 _QT4_ADJUST_LIB_VARS(QTXMLPATTERNS)
1021 _QT4_ADJUST_LIB_VARS(PHONON)
1023 # platform dependent libraries
1025 _QT4_ADJUST_LIB_VARS(QTMOTIF)
1028 _QT4_ADJUST_LIB_VARS(QTMAIN)
1032 #######################################
1034 # Check the executables of Qt
1037 #######################################
1040 # find moc and uic using qmake
1041 QT_QUERY_QMAKE(QT_MOC_EXECUTABLE_INTERNAL "QMAKE_MOC")
1042 QT_QUERY_QMAKE(QT_UIC_EXECUTABLE_INTERNAL "QMAKE_UIC")
1044 # make sure we have / and not \ as qmake gives on windows
1046 "${QT_MOC_EXECUTABLE_INTERNAL}" QT_MOC_EXECUTABLE_INTERNAL)
1047 # make sure we have / and not \ as qmake gives on windows
1049 "${QT_UIC_EXECUTABLE_INTERNAL}" QT_UIC_EXECUTABLE_INTERNAL)
1051 SET(QT_MOC_EXECUTABLE
1052 ${QT_MOC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The moc executable")
1053 SET(QT_UIC_EXECUTABLE
1054 ${QT_UIC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The uic executable")
1056 FIND_PROGRAM(QT_UIC3_EXECUTABLE
1058 PATHS ${QT_BINARY_DIR}
1062 FIND_PROGRAM(QT_RCC_EXECUTABLE
1064 PATHS ${QT_BINARY_DIR}
1068 FIND_PROGRAM(QT_DBUSCPP2XML_EXECUTABLE
1070 PATHS ${QT_BINARY_DIR}
1074 FIND_PROGRAM(QT_DBUSXML2CPP_EXECUTABLE
1076 PATHS ${QT_BINARY_DIR}
1080 FIND_PROGRAM(QT_LUPDATE_EXECUTABLE
1081 NAMES lupdate-qt4 lupdate
1082 PATHS ${QT_BINARY_DIR}
1086 FIND_PROGRAM(QT_LRELEASE_EXECUTABLE
1087 NAMES lrelease-qt4 lrelease
1088 PATHS ${QT_BINARY_DIR}
1092 IF (QT_MOC_EXECUTABLE)
1093 SET(QT_WRAP_CPP "YES")
1094 ENDIF (QT_MOC_EXECUTABLE)
1096 IF (QT_UIC_EXECUTABLE)
1097 SET(QT_WRAP_UI "YES")
1098 ENDIF (QT_UIC_EXECUTABLE)
1102 MARK_AS_ADVANCED( QT_UIC_EXECUTABLE QT_UIC3_EXECUTABLE QT_MOC_EXECUTABLE
1103 QT_RCC_EXECUTABLE QT_DBUSXML2CPP_EXECUTABLE QT_DBUSCPP2XML_EXECUTABLE
1104 QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE)
1106 ######################################
1108 # Macros for building Qt files
1110 ######################################
1112 MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
1114 SET(${_qt4_options})
1115 SET(_QT4_DOING_OPTIONS FALSE)
1116 FOREACH(_currentArg ${ARGN})
1117 IF ("${_currentArg}" STREQUAL "OPTIONS")
1118 SET(_QT4_DOING_OPTIONS TRUE)
1119 ELSE ("${_currentArg}" STREQUAL "OPTIONS")
1120 IF(_QT4_DOING_OPTIONS)
1121 LIST(APPEND ${_qt4_options} "${_currentArg}")
1122 ELSE(_QT4_DOING_OPTIONS)
1123 LIST(APPEND ${_qt4_files} "${_currentArg}")
1124 ENDIF(_QT4_DOING_OPTIONS)
1125 ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
1126 ENDFOREACH(_currentArg)
1127 ENDMACRO (QT4_EXTRACT_OPTIONS)
1129 MACRO (QT4_GET_MOC_INC_DIRS _moc_INC_DIRS)
1130 SET(${_moc_INC_DIRS})
1131 GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES)
1133 FOREACH(_current ${_inc_DIRS})
1134 SET(${_moc_INC_DIRS} ${${_moc_INC_DIRS}} "-I" ${_current})
1135 ENDFOREACH(_current ${_inc_DIRS})
1137 # if Qt is installed only as framework, add -F /library/Frameworks to the moc arguments
1138 # otherwise moc can't find the headers in the framework include dirs
1139 IF(APPLE AND "${QT_QTCORE_INCLUDE_DIR}" MATCHES "/Library/Frameworks/")
1140 SET(${_moc_INC_DIRS} ${${_moc_INC_DIRS}} "-F/Library/Frameworks")
1141 ENDIF(APPLE AND "${QT_QTCORE_INCLUDE_DIR}" MATCHES "/Library/Frameworks/")
1143 ENDMACRO(QT4_GET_MOC_INC_DIRS)
1145 # Added by Sput to provide definitions to moc calls
1146 MACRO (QT4_GET_MOC_DEFINES _moc_DEFINES)
1147 SET(${_moc_DEFINES})
1148 GET_DIRECTORY_PROPERTY(_defines COMPILE_DEFINITIONS)
1149 FOREACH(_current ${_defines})
1150 SET(${_moc_DEFINES} ${${_moc_DEFINES}} -D${_current})
1151 ENDFOREACH(_current ${_defines})
1153 ENDMACRO(QT4_GET_MOC_DEFINES)
1155 MACRO (QT4_GENERATE_MOC infile outfile )
1157 # QT4_GET_MOC_INC_DIRS(moc_includes) # Not needed...
1158 QT4_GET_MOC_DEFINES(moc_defines)
1160 GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE)
1163 SET (_moc_parameter_file ${outfile}_parameters)
1164 SET (_moc_param "${moc_includes} \n-o${outfile} \n${abs_infile}")
1165 STRING(REGEX REPLACE ";-I;" "\\n-I" _moc_param "${_moc_param}")
1166 FILE (WRITE ${_moc_parameter_file} "${_moc_param}")
1167 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1168 COMMAND ${QT_MOC_EXECUTABLE}
1169 ARGS @"${_moc_parameter_file}"
1170 DEPENDS ${abs_infile})
1172 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1173 COMMAND ${QT_MOC_EXECUTABLE}
1174 ARGS ${moc_includes} ${moc_defines} -o ${outfile} ${abs_infile}
1175 DEPENDS ${abs_infile})
1178 SET_SOURCE_FILES_PROPERTIES(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file
1180 MACRO_ADD_FILE_DEPENDENCIES(${abs_infile} ${outfile})
1181 ENDMACRO (QT4_GENERATE_MOC)
1184 # QT4_WRAP_CPP(outfiles inputfile ... )
1186 MACRO (QT4_WRAP_CPP outfiles )
1188 # QT4_GET_MOC_INC_DIRS(moc_includes) # Not needed
1189 QT4_GET_MOC_DEFINES(moc_defines)
1190 QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
1192 FOREACH (it ${moc_files})
1193 GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
1194 GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
1196 SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/moc_${outfile}.cxx)
1197 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1198 COMMAND ${QT_MOC_EXECUTABLE}
1199 ARGS ${moc_includes} ${moc_defines} ${moc_options} -o ${outfile} ${it}
1201 SET(${outfiles} ${${outfiles}} ${outfile})
1204 ENDMACRO (QT4_WRAP_CPP)
1207 # QT4_WRAP_UI(outfiles inputfile ... )
1209 MACRO (QT4_WRAP_UI outfiles )
1210 QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
1212 FOREACH (it ${ui_files})
1213 GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
1214 GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
1215 SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
1216 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1217 COMMAND ${QT_UIC_EXECUTABLE}
1218 ARGS ${ui_options} -o ${outfile} ${infile}
1219 MAIN_DEPENDENCY ${infile})
1220 SET(${outfiles} ${${outfiles}} ${outfile})
1223 ENDMACRO (QT4_WRAP_UI)
1226 # QT4_ADD_RESOURCES(outfiles inputfile ... )
1228 MACRO (QT4_ADD_RESOURCES outfiles )
1229 QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN})
1231 FOREACH (it ${rcc_files})
1232 GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
1233 GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
1234 GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
1235 SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
1236 # parse file for dependencies
1237 # all files are absolute paths or relative to the location of the qrc file
1238 FILE(READ "${infile}" _RC_FILE_CONTENTS)
1239 STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
1241 FOREACH(_RC_FILE ${_RC_FILES})
1242 STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
1243 STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}")
1244 IF(NOT _ABS_PATH_INDICATOR)
1245 SET(_RC_FILE "${rc_path}/${_RC_FILE}")
1246 ENDIF(NOT _ABS_PATH_INDICATOR)
1247 SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
1248 ENDFOREACH(_RC_FILE)
1249 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1250 COMMAND ${QT_RCC_EXECUTABLE}
1251 ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
1252 MAIN_DEPENDENCY ${infile}
1253 DEPENDS ${_RC_DEPENDS})
1254 SET(${outfiles} ${${outfiles}} ${outfile})
1257 ENDMACRO (QT4_ADD_RESOURCES)
1259 MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename)
1260 GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE)
1261 SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
1262 SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
1263 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
1265 GET_SOURCE_FILE_PROPERTY(_nonamespace ${_interface} NO_NAMESPACE)
1268 ELSE ( _nonamespace )
1270 ENDIF ( _nonamespace )
1272 GET_SOURCE_FILE_PROPERTY(_include ${_interface} INCLUDE)
1274 SET(_params ${_params} -i ${_include})
1277 ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1278 COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile}
1281 SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
1283 QT4_GENERATE_MOC(${_header} ${_moc})
1285 SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
1286 MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
1288 ENDMACRO(QT4_ADD_DBUS_INTERFACE)
1291 MACRO(QT4_ADD_DBUS_INTERFACES _sources)
1292 FOREACH (_current_FILE ${ARGN})
1293 GET_FILENAME_COMPONENT(_infile ${_current_FILE} ABSOLUTE)
1294 # get the part before the ".xml" suffix
1295 STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2" _basename ${_current_FILE})
1296 STRING(TOLOWER ${_basename} _basename)
1297 QT4_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface)
1298 ENDFOREACH (_current_FILE)
1299 ENDMACRO(QT4_ADD_DBUS_INTERFACES)
1302 MACRO(QT4_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options )
1303 QT4_EXTRACT_OPTIONS(_customName _qt4_dbus_options ${ARGN})
1305 GET_FILENAME_COMPONENT(_in_file ${_header} ABSOLUTE)
1306 GET_FILENAME_COMPONENT(_basename ${_header} NAME_WE)
1309 SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName})
1311 SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml)
1314 ADD_CUSTOM_COMMAND(OUTPUT ${_target}
1315 COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} > ${_target}
1318 ENDMACRO(QT4_GENERATE_DBUS_INTERFACE)
1321 MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName)
1322 GET_FILENAME_COMPONENT(_infile ${_xml_file} ABSOLUTE)
1324 SET(_optionalBasename "${ARGV4}")
1325 IF (_optionalBasename)
1326 SET(_basename ${_optionalBasename} )
1327 ELSE (_optionalBasename)
1328 STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile})
1329 STRING(TOLOWER ${_basename} _basename)
1330 ENDIF (_optionalBasename)
1332 SET(_optionalClassName "${ARGV5}")
1333 SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
1334 SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
1335 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
1337 IF(_optionalClassName)
1338 ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1339 COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
1342 ELSE(_optionalClassName)
1343 ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1344 COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
1347 ENDIF(_optionalClassName)
1349 QT4_GENERATE_MOC(${_header} ${_moc})
1350 SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
1351 MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
1353 SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
1354 ENDMACRO(QT4_ADD_DBUS_ADAPTOR)
1357 # QT4_GET_MOC_INC_DIRS(_moc_INCS)
1358 QT4_GET_MOC_DEFINES(_moc_DEFINES)
1361 SET(_matching_FILES )
1362 FOREACH (_current_FILE ${ARGN})
1364 GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
1365 # if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
1366 # This is required to make uic work correctly:
1367 # we need to add generated .cpp files to the sources (to compile them),
1368 # but we cannot let automoc handle them, as the .cpp files don't exist yet when
1369 # cmake is run for the very first time on them -> however the .cpp files might
1370 # exist at a later run. at that time we need to skip them, so that we don't add two
1371 # different rules for the same moc file
1372 GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC)
1374 IF ( NOT _skip AND EXISTS ${_abs_FILE} )
1376 FILE(READ ${_abs_FILE} _contents)
1378 GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH)
1380 STRING(REGEX MATCHALL "#include +[^ ]+\\.moc[\">]" _match "${_contents}")
1382 FOREACH (_current_MOC_INC ${_match})
1383 STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
1385 GET_filename_component(_basename ${_current_MOC} NAME_WE)
1386 # SET(_header ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h)
1387 SET(_header ${_abs_PATH}/${_basename}.h)
1388 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
1389 ADD_CUSTOM_COMMAND(OUTPUT ${_moc}
1390 COMMAND ${QT_MOC_EXECUTABLE}
1391 ARGS ${_moc_INCS} ${_moc_DEFINES} ${_header} -o ${_moc}
1395 MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
1396 ENDFOREACH (_current_MOC_INC)
1398 ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} )
1399 ENDFOREACH (_current_FILE)
1400 ENDMACRO(QT4_AUTOMOC)
1404 ######################################
1406 # decide if Qt got found
1408 ######################################
1410 # if the includes,libraries,moc,uic and rcc are found then we have it
1411 IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1412 SET( QT4_FOUND "YES" )
1413 IF( NOT Qt4_FIND_QUIETLY)
1414 MESSAGE(STATUS "Found Qt-Version ${QTVERSION} (using ${QT_QMAKE_EXECUTABLE})")
1415 ENDIF( NOT Qt4_FIND_QUIETLY)
1416 ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1417 SET( QT4_FOUND "NO")
1418 SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1419 IF( Qt4_FIND_REQUIRED)
1420 IF ( NOT QT_LIBRARY_DIR )
1421 MESSAGE(STATUS "Qt libraries NOT found!")
1422 ENDIF(NOT QT_LIBRARY_DIR )
1423 IF ( NOT QT_INCLUDE_DIR )
1424 MESSAGE(STATUS "Qt includes NOT found!")
1425 ENDIF( NOT QT_INCLUDE_DIR )
1426 IF ( NOT QT_MOC_EXECUTABLE )
1427 MESSAGE(STATUS "Qt's moc NOT found!")
1428 ENDIF( NOT QT_MOC_EXECUTABLE )
1429 IF ( NOT QT_UIC_EXECUTABLE )
1430 MESSAGE(STATUS "Qt's uic NOT found!")
1431 ENDIF( NOT QT_UIC_EXECUTABLE )
1432 IF ( NOT QT_RCC_EXECUTABLE )
1433 MESSAGE(STATUS "Qt's rcc NOT found!")
1434 ENDIF( NOT QT_RCC_EXECUTABLE )
1435 MESSAGE( FATAL_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!")
1436 ENDIF( Qt4_FIND_REQUIRED)
1437 ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1438 SET(QT_FOUND ${QT4_FOUND})
1441 #######################################
1445 #######################################
1446 IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
1447 FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents)
1448 STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG ${_qconfig_FILE_contents})
1449 STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG ${_qconfig_FILE_contents})
1450 STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION ${_qconfig_FILE_contents})
1451 ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
1452 IF("${QT_EDITION}" MATCHES "DesktopLight")
1453 SET(QT_EDITION_DESKTOPLIGHT 1)
1454 ENDIF("${QT_EDITION}" MATCHES "DesktopLight")
1456 ###############################################
1458 # configuration/system dependent settings
1460 ###############################################
1462 SET(QT_GUI_LIB_DEPENDENCIES "")
1463 SET(QT_CORE_LIB_DEPENDENCIES "")
1465 # shared build needs -DQT_SHARED
1466 IF(NOT QT_CONFIG MATCHES "static")
1467 # warning currently only qconfig.pri on Windows potentially contains "static"
1468 # so QT_SHARED might not get defined properly on Mac/X11 (which seems harmless right now)
1469 # Trolltech said they'd consider exporting it for all platforms in future releases.
1470 SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_SHARED)
1471 ENDIF(NOT QT_CONFIG MATCHES "static")
1474 IF(NOT QT_QCONFIG MATCHES "openssl")
1475 SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_NO_OPENSSL)
1476 ENDIF(NOT QT_QCONFIG MATCHES "openssl")
1479 IF(QT_QCONFIG MATCHES "system-png")
1480 FIND_LIBRARY(QT_PNG_LIBRARY NAMES png)
1481 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY})
1482 MARK_AS_ADVANCED(QT_PNG_LIBRARY)
1483 ENDIF(QT_QCONFIG MATCHES "system-png")
1485 # for X11, get X11 library directory
1487 QT_QUERY_QMAKE(QMAKE_LIBDIR_X11 "QMAKE_LIBDIR_X11")
1491 IF(QT_QCONFIG MATCHES "x11sm")
1492 # ask qmake where the x11 libs are
1493 FIND_LIBRARY(QT_X11_SM_LIBRARY NAMES SM PATHS ${QMAKE_LIBDIR_X11})
1494 FIND_LIBRARY(QT_X11_ICE_LIBRARY NAMES ICE PATHS ${QMAKE_LIBDIR_X11})
1495 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_X11_SM_LIBRARY} ${QT_X11_ICE_LIBRARY})
1496 MARK_AS_ADVANCED(QT_X11_SM_LIBRARY)
1497 MARK_AS_ADVANCED(QT_X11_ICE_LIBRARY)
1498 ENDIF(QT_QCONFIG MATCHES "x11sm")
1501 IF(QT_QCONFIG MATCHES "tablet")
1502 FIND_LIBRARY(QT_XI_LIBRARY NAMES Xi PATHS ${QMAKE_LIBDIR_X11})
1503 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XI_LIBRARY})
1504 MARK_AS_ADVANCED(QT_XI_LIBRARY)
1505 ENDIF(QT_QCONFIG MATCHES "tablet")
1508 IF(QT_QCONFIG MATCHES "xrender")
1509 FIND_LIBRARY(QT_XRENDER_LIBRARY NAMES Xrender PATHS ${QMAKE_LIBDIR_X11})
1510 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XRENDER_LIBRARY})
1511 MARK_AS_ADVANCED(QT_XRENDER_LIBRARY)
1512 ENDIF(QT_QCONFIG MATCHES "xrender")
1515 IF(QT_QCONFIG MATCHES "xrandr")
1516 FIND_LIBRARY(QT_XRANDR_LIBRARY NAMES Xrandr PATHS ${QMAKE_LIBDIR_X11})
1517 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XRANDR_LIBRARY})
1518 MARK_AS_ADVANCED(QT_XRANDR_LIBRARY)
1519 ENDIF(QT_QCONFIG MATCHES "xrandr")
1522 IF(QT_QCONFIG MATCHES "xcursor")
1523 FIND_LIBRARY(QT_XCURSOR_LIBRARY NAMES Xcursor PATHS ${QMAKE_LIBDIR_X11})
1524 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XCURSOR_LIBRARY})
1525 MARK_AS_ADVANCED(QT_XCURSOR_LIBRARY)
1526 ENDIF(QT_QCONFIG MATCHES "xcursor")
1529 IF(QT_QCONFIG MATCHES "xinerama")
1530 FIND_LIBRARY(QT_XINERAMA_LIBRARY NAMES Xinerama PATHS ${QMAKE_LIBDIR_X11})
1531 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XINERAMA_LIBRARY})
1532 MARK_AS_ADVANCED(QT_XINERAMA_LIBRARY)
1533 ENDIF(QT_QCONFIG MATCHES "xinerama")
1536 IF(QT_QCONFIG MATCHES "xfixes")
1537 FIND_LIBRARY(QT_XFIXES_LIBRARY NAMES Xfixes PATHS ${QMAKE_LIBDIR_X11})
1538 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XFIXES_LIBRARY})
1539 MARK_AS_ADVANCED(QT_XFIXES_LIBRARY)
1540 ENDIF(QT_QCONFIG MATCHES "xfixes")
1543 IF(QT_QCONFIG MATCHES "system-freetype")
1544 FIND_LIBRARY(QT_FREETYPE_LIBRARY NAMES freetype)
1545 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY})
1546 MARK_AS_ADVANCED(QT_FREETYPE_LIBRARY)
1547 ENDIF(QT_QCONFIG MATCHES "system-freetype")
1550 IF(QT_QCONFIG MATCHES "fontconfig")
1551 FIND_LIBRARY(QT_FONTCONFIG_LIBRARY NAMES fontconfig)
1552 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY})
1553 MARK_AS_ADVANCED(QT_FONTCONFIG_LIBRARY)
1554 ENDIF(QT_QCONFIG MATCHES "fontconfig")
1557 IF(QT_QCONFIG MATCHES "system-zlib")
1558 FIND_LIBRARY(QT_ZLIB_LIBRARY NAMES z)
1559 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY})
1560 MARK_AS_ADVANCED(QT_ZLIB_LIBRARY)
1561 ENDIF(QT_QCONFIG MATCHES "system-zlib")
1564 IF(QT_QCONFIG MATCHES "glib")
1565 # Qt less than Qt 4.2.0 doesn't use glib
1566 # Qt 4.2.0 uses glib-2.0 (wish we could ask Qt that it uses 2.0)
1567 FIND_LIBRARY(QT_GLIB_LIBRARY NAMES glib-2.0)
1568 FIND_LIBRARY(QT_GTHREAD_LIBRARY NAMES gthread-2.0)
1569 IF(QT_GTHREAD_LIBRARY AND QT_GLIB_LIBRARY) #TEMP: need more robust find of glib2
1570 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES}
1571 ${QT_GTHREAD_LIBRARY} ${QT_GLIB_LIBRARY})
1572 ENDIF(QT_GTHREAD_LIBRARY AND QT_GLIB_LIBRARY)
1573 MARK_AS_ADVANCED(QT_GLIB_LIBRARY)
1574 MARK_AS_ADVANCED(QT_GTHREAD_LIBRARY)
1575 ENDIF(QT_QCONFIG MATCHES "glib")
1577 ## clock-monotonic, just see if we need to link with rt
1578 IF(QT_QCONFIG MATCHES "clock-monotonic")
1579 SET(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
1580 SET(CMAKE_REQUIRED_LIBRARIES rt)
1581 CHECK_SYMBOL_EXISTS(_POSIX_TIMERS "unistd.h;time.h" QT_POSIX_TIMERS)
1582 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
1584 FIND_LIBRARY(QT_RT_LIBRARY NAMES rt)
1585 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QT_RT_LIBRARY})
1586 MARK_AS_ADVANCED(QT_RT_LIBRARY)
1587 ENDIF(QT_POSIX_TIMERS)
1588 ENDIF(QT_QCONFIG MATCHES "clock-monotonic")
1591 # X11 libraries Qt absolutely depends on
1592 QT_QUERY_QMAKE(QT_LIBS_X11 "QMAKE_LIBS_X11")
1593 SEPARATE_ARGUMENTS(QT_LIBS_X11)
1594 FOREACH(QT_X11_LIB ${QT_LIBS_X11})
1595 STRING(REGEX REPLACE "-l" "" QT_X11_LIB "${QT_X11_LIB}")
1596 SET(QT_TMP_STR "QT_X11_${QT_X11_LIB}_LIBRARY")
1597 FIND_LIBRARY(${QT_TMP_STR} NAMES "${QT_X11_LIB}" PATHS ${QMAKE_LIBDIR_X11})
1598 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${${QT_TMP_STR}})
1599 MARK_AS_ADVANCED(${QT_TMP_STR})
1600 ENDFOREACH(QT_X11_LIB)
1602 QT_QUERY_QMAKE(QT_LIBS_THREAD "QMAKE_LIBS_THREAD")
1603 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QT_LIBS_THREAD})
1605 QT_QUERY_QMAKE(QMAKE_LIBS_DYNLOAD "QMAKE_LIBS_DYNLOAD")
1606 SET (QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QMAKE_LIBS_DYNLOAD})
1611 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} imm32 winmm)
1612 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ws2_32)
1616 SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} "-framework Carbon" "-framework QuickTime")
1617 SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} "-framework ApplicationServices")
1620 #######################################
1622 # compatibility settings
1624 #######################################
1625 # Backwards compatibility for CMake1.4 and 1.2
1626 SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} )
1627 SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} )
1629 SET( QT_QT_LIBRARY "")
1631 ELSE(QT4_QMAKE_FOUND)
1633 SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1634 IF(Qt4_FIND_REQUIRED)
1635 IF(QT4_INSTALLED_VERSION_TOO_OLD)
1636 MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1637 ELSE(QT4_INSTALLED_VERSION_TOO_OLD)
1638 MESSAGE( FATAL_ERROR "Qt qmake not found!")
1639 ENDIF(QT4_INSTALLED_VERSION_TOO_OLD)
1640 ELSE(Qt4_FIND_REQUIRED)
1641 IF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1642 MESSAGE(STATUS "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1643 ENDIF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1644 ENDIF(Qt4_FIND_REQUIRED)
1646 ENDIF (QT4_QMAKE_FOUND)
1647 ENDIF (QT4_QMAKE_FOUND)