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.
88 # To include a header in the interface header, set the source file property
89 # INCLUDE to the name of the header.
90 # To specify a class name to use, set the source file property CLASSNAME
91 # to the name of the class.
93 # macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... )
94 # create the interface header and implementation files
95 # for all listed interface xml files
96 # the name will be automatically determined from the name of the xml file
97 # To disable generating namespace headers, set the source file property
98 # NO_NAMESPACE to TRUE for these inputfiles.
99 # To include a header in the interface header, set the source file property
100 # INCLUDE to the name of the header.
101 # To specify a class name to use, set the source file property CLASSNAME
102 # to the name of the class.
104 # macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname [basename] [classname])
105 # create a dbus adaptor (header and implementation file) from the xml file
106 # describing the interface, and add it to the list of sources. The adaptor
107 # forwards the calls to a parent class, defined in parentheader and named
108 # parentclassname. The name of the generated files will be
109 # <basename>adaptor.{cpp,h} where basename defaults to the basename of the xml file.
110 # If <classname> is provided, then it will be used as the classname of the
113 # macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] OPTIONS ...)
114 # generate the xml interface file from the given header.
115 # If the optional argument interfacename is omitted, the name of the
116 # interface file is constructed from the basename of the header with
117 # the suffix .xml appended.
118 # Options may be given to qdbuscpp2xml, such as those found when executing "qdbuscpp2xml --help"
120 # QT_FOUND If false, don't try to use Qt.
121 # QT4_FOUND If false, don't try to use Qt 4.
123 # QT_QTCORE_FOUND True if QtCore was found.
124 # QT_QTGUI_FOUND True if QtGui was found.
125 # QT_QT3SUPPORT_FOUND True if Qt3Support was found.
126 # QT_QTASSISTANT_FOUND True if QtAssistant was found.
127 # QT_QTDBUS_FOUND True if QtDBus was found.
128 # QT_QTDESIGNER_FOUND True if QtDesigner was found.
129 # QT_QTDESIGNERCOMPONENTS True if QtDesignerComponents was found.
130 # QT_QTMOTIF_FOUND True if QtMotif was found.
131 # QT_QTNETWORK_FOUND True if QtNetwork was found.
132 # QT_QTNSPLUGIN_FOUND True if QtNsPlugin was found.
133 # QT_QTOPENGL_FOUND True if QtOpenGL was found.
134 # QT_QTSQL_FOUND True if QtSql was found.
135 # QT_QTXML_FOUND True if QtXml was found.
136 # QT_QTSVG_FOUND True if QtSvg was found.
137 # QT_QTSCRIPT_FOUND True if QtScript was found.
138 # QT_QTTEST_FOUND True if QtTest was found.
139 # QT_QTUITOOLS_FOUND True if QtUiTools was found.
140 # QT_QTASSISTANTCLIENT_FOUND True if QtAssistantClient was found.
141 # QT_QTHELP_FOUND True if QtHelp was found.
142 # QT_QTWEBKIT_FOUND True if QtWebKit was found.
143 # QT_QTXMLPATTERNS_FOUND True if QtXmlPatterns was found.
144 # QT_PHONON_FOUND True if phonon was found.
147 # QT_DEFINITIONS Definitions to use when compiling code that uses Qt.
148 # You do not need to use this if you include QT_USE_FILE.
149 # The QT_USE_FILE will also define QT_DEBUG and QT_NO_DEBUG
150 # to fit your current build type. Those are not contained
153 # QT_INCLUDES List of paths to all include directories of
154 # Qt4 QT_INCLUDE_DIR and QT_QTCORE_INCLUDE_DIR are
155 # always in this variable even if NOTFOUND,
156 # all other INCLUDE_DIRS are
157 # only added if they are found.
158 # You do not need to use this if you include QT_USE_FILE.
161 # Include directories for the Qt modules are listed here.
162 # You do not need to use these variables if you include QT_USE_FILE.
164 # QT_INCLUDE_DIR Path to "include" of Qt4
165 # QT_QT_INCLUDE_DIR Path to "include/Qt"
166 # QT_QT3SUPPORT_INCLUDE_DIR Path to "include/Qt3Support"
167 # QT_QTASSISTANT_INCLUDE_DIR Path to "include/QtAssistant"
168 # QT_QTCORE_INCLUDE_DIR Path to "include/QtCore"
169 # QT_QTDESIGNER_INCLUDE_DIR Path to "include/QtDesigner"
170 # QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR Path to "include/QtDesigner"
171 # QT_QTDBUS_INCLUDE_DIR Path to "include/QtDBus"
172 # QT_QTGUI_INCLUDE_DIR Path to "include/QtGui"
173 # QT_QTMOTIF_INCLUDE_DIR Path to "include/QtMotif"
174 # QT_QTNETWORK_INCLUDE_DIR Path to "include/QtNetwork"
175 # QT_QTNSPLUGIN_INCLUDE_DIR Path to "include/QtNsPlugin"
176 # QT_QTOPENGL_INCLUDE_DIR Path to "include/QtOpenGL"
177 # QT_QTSQL_INCLUDE_DIR Path to "include/QtSql"
178 # QT_QTXML_INCLUDE_DIR Path to "include/QtXml"
179 # QT_QTSVG_INCLUDE_DIR Path to "include/QtSvg"
180 # QT_QTSCRIPT_INCLUDE_DIR Path to "include/QtScript"
181 # QT_QTTEST_INCLUDE_DIR Path to "include/QtTest"
182 # QT_QTASSISTANTCLIENT_INCLUDE_DIR Path to "include/QtAssistant"
183 # QT_QTHELP_INCLUDE_DIR Path to "include/QtHelp"
184 # QT_QTWEBKIT_INCLUDE_DIR Path to "include/QtWebKit"
185 # QT_QTXMLPATTERNS_INCLUDE_DIR Path to "include/QtXmlPatterns"
186 # QT_PHONON_INCLUDE_DIR Path to "include/phonon"
188 # QT_LIBRARY_DIR Path to "lib" of Qt4
190 # QT_PLUGINS_DIR Path to "plugins" for Qt4
192 # For every library of Qt, a QT_QTFOO_LIBRARY variable is defined, with the full path to the library.
194 # So there are the following variables:
195 # The Qt3Support library: QT_QT3SUPPORT_LIBRARY
197 # The QtAssistant library: QT_QTASSISTANT_LIBRARY
199 # The QtCore library: QT_QTCORE_LIBRARY
201 # The QtDBus library: QT_QTDBUS_LIBRARY
203 # The QtDesigner library: QT_QTDESIGNER_LIBRARY
205 # The QtDesignerComponents library: QT_QTDESIGNERCOMPONENTS_LIBRARY
207 # The QtGui library: QT_QTGUI_LIBRARY
209 # The QtMotif library: QT_QTMOTIF_LIBRARY
211 # The QtNetwork library: QT_QTNETWORK_LIBRARY
213 # The QtNsPLugin library: QT_QTNSPLUGIN_LIBRARY
215 # The QtOpenGL library: QT_QTOPENGL_LIBRARY
217 # The QtSql library: QT_QTSQL_LIBRARY
219 # The QtXml library: QT_QTXML_LIBRARY
221 # The QtSvg library: QT_QTSVG_LIBRARY
223 # The QtScript library: QT_QTSCRIPT_LIBRARY
225 # The QtTest library: QT_QTTEST_LIBRARY
227 # The qtmain library for Windows QT_QTMAIN_LIBRARY
229 # The QtUiTools library: QT_QTUITOOLS_LIBRARY
231 # The QtAssistantClient library: QT_QTASSISTANTCLIENT_LIBRARY
233 # The QtHelp library: QT_QTHELP_LIBRARY
235 # The QtWebKit library: QT_QTWEBKIT_LIBRARY
237 # The QtXmlPatterns library: QT_QTXMLPATTERNS_LIBRARY
239 # The Phonon library: QT_PHONON_LIBRARY
241 # also defined, but NOT for general use are
242 # QT_MOC_EXECUTABLE Where to find the moc tool.
243 # QT_UIC_EXECUTABLE Where to find the uic tool.
244 # QT_UIC3_EXECUTABLE Where to find the uic3 tool.
245 # QT_RCC_EXECUTABLE Where to find the rcc tool
246 # QT_DBUSCPP2XML_EXECUTABLE Where to find the qdbuscpp2xml tool.
247 # QT_DBUSXML2CPP_EXECUTABLE Where to find the qdbusxml2cpp tool.
248 # QT_LUPDATE_EXECUTABLE Where to find the lupdate tool.
249 # QT_LRELEASE_EXECUTABLE Where to find the lrelease tool.
251 # QT_DOC_DIR Path to "doc" of Qt4
252 # QT_MKSPECS_DIR Path to "mkspecs" of Qt4
255 # These are around for backwards compatibility
257 # QT_WRAP_CPP Set true if QT_MOC_EXECUTABLE is found
258 # QT_WRAP_UI Set true if QT_UIC_EXECUTABLE is found
260 # These variables do _NOT_ have any effect anymore (compared to FindQt.cmake)
261 # QT_MT_REQUIRED Qt4 is now always multithreaded
263 # These variables are set to "" Because Qt structure changed
264 # (They make no sense in Qt4)
265 # QT_QT_LIBRARY Qt-Library is now split
267 # Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
268 # See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
271 # If Qt3 has already been found, fail.
273 IF(Qt4_FIND_REQUIRED)
274 MESSAGE( FATAL_ERROR "Qt3 and Qt4 cannot be used together in one project.")
275 ELSE(Qt4_FIND_REQUIRED)
276 IF(NOT Qt4_FIND_QUIETLY)
277 MESSAGE( STATUS "Qt3 and Qt4 cannot be used together in one project.")
278 ENDIF(NOT Qt4_FIND_QUIETLY)
280 ENDIF(Qt4_FIND_REQUIRED)
285 # Check already done in this cmake run, nothing more to do
287 ENDIF (QT4_QMAKE_FOUND)
289 # check that QT_NO_DEBUG is defined for release configurations
290 MACRO(QT_CHECK_FLAG_EXISTS FLAG VAR DOC)
291 IF(NOT ${VAR} MATCHES "${FLAG}")
292 SET(${VAR} "${${VAR}} ${FLAG}"
293 CACHE STRING "Flags used by the compiler during ${DOC} builds." FORCE)
294 ENDIF(NOT ${VAR} MATCHES "${FLAG}")
295 ENDMACRO(QT_CHECK_FLAG_EXISTS FLAG VAR)
296 QT_CHECK_FLAG_EXISTS(-DQT_NO_DEBUG CMAKE_CXX_FLAGS_RELWITHDEBINFO "Release with Debug Info")
297 QT_CHECK_FLAG_EXISTS(-DQT_NO_DEBUG CMAKE_CXX_FLAGS_RELEASE "release")
298 QT_CHECK_FLAG_EXISTS(-DQT_NO_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL "release minsize")
300 INCLUDE(CheckSymbolExists)
301 INCLUDE(MacroAddFileDependencies)
302 INCLUDE(MacroPushRequiredVars)
304 SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake)
306 SET( QT_DEFINITIONS "")
309 SET(QT_DEFINITIONS -DQT_DLL)
312 SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE)
314 # macro for asking qmake to process pro files
315 MACRO(QT_QUERY_QMAKE outvar invar)
316 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake/tmp.pro
317 "message(CMAKE_MESSAGE<$$${invar}>)")
319 # Invoke qmake with the tmp.pro program to get the desired
320 # information. Use the same variable for both stdout and stderr
321 # to make sure we get the output on all platforms.
322 EXECUTE_PROCESS(COMMAND ${QT_QMAKE_EXECUTABLE}
324 ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake
325 OUTPUT_VARIABLE _qmake_query_output
326 RESULT_VARIABLE _qmake_result
327 ERROR_VARIABLE _qmake_query_output )
330 "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake")
333 MESSAGE(WARNING " querying qmake for ${invar}. qmake reported:\n${_qmake_query_output}")
335 STRING(REGEX REPLACE ".*CMAKE_MESSAGE<([^>]*).*" "\\1" ${outvar} "${_qmake_query_output}")
338 ENDMACRO(QT_QUERY_QMAKE)
340 GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME)
342 FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 PATHS
343 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
344 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
345 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]/bin"
349 IF (QT_QMAKE_EXECUTABLE)
351 SET(QT4_QMAKE_FOUND FALSE)
353 EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
355 # check for qt3 qmake and then try and find qmake4 or qmake-qt4 in the path
356 IF("${QTVERSION}" MATCHES "Unknown")
357 SET(QT_QMAKE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE)
358 FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 PATHS
359 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
360 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
363 IF(QT_QMAKE_EXECUTABLE)
364 EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE}
365 ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
366 ENDIF(QT_QMAKE_EXECUTABLE)
367 ENDIF("${QTVERSION}" MATCHES "Unknown")
369 # check that we found the Qt4 qmake, Qt3 qmake output won't match here
370 STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" qt_version_tmp "${QTVERSION}")
373 # we need at least version 4.0.0
374 IF (NOT QT_MIN_VERSION)
375 SET(QT_MIN_VERSION "4.0.0")
376 ENDIF (NOT QT_MIN_VERSION)
378 #now parse the parts of the user given version string into variables
379 STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" req_qt_major_vers "${QT_MIN_VERSION}")
380 IF (NOT req_qt_major_vers)
381 MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"4.0.1\"")
382 ENDIF (NOT req_qt_major_vers)
384 # now parse the parts of the user given version string into variables
385 STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}")
386 STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers "${QT_MIN_VERSION}")
387 STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}")
389 IF (NOT req_qt_major_vers EQUAL 4)
390 MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", major version 4 is required, e.g. \"4.0.1\"")
391 ENDIF (NOT req_qt_major_vers EQUAL 4)
393 # and now the version string given by qmake
394 STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" found_qt_major_vers "${QTVERSION}")
395 STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" found_qt_minor_vers "${QTVERSION}")
396 STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" found_qt_patch_vers "${QTVERSION}")
398 # compute an overall version number which can be compared at once
399 MATH(EXPR req_vers "${req_qt_major_vers}*10000 + ${req_qt_minor_vers}*100 + ${req_qt_patch_vers}")
400 MATH(EXPR found_vers "${found_qt_major_vers}*10000 + ${found_qt_minor_vers}*100 + ${found_qt_patch_vers}")
402 IF (found_vers LESS req_vers)
403 SET(QT4_QMAKE_FOUND FALSE)
404 SET(QT4_INSTALLED_VERSION_TOO_OLD TRUE)
405 ELSE (found_vers LESS req_vers)
406 SET(QT4_QMAKE_FOUND TRUE)
407 ENDIF (found_vers LESS req_vers)
408 ENDIF (qt_version_tmp)
410 ENDIF (QT_QMAKE_EXECUTABLE)
416 get_filename_component(_DIR ${QT_QMAKE_EXECUTABLE} PATH )
417 get_filename_component(QT_INSTALL_DIR ${_DIR} PATH )
420 # ask qmake for the library dir
422 IF (NOT QT_LIBRARY_DIR)
423 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
424 ARGS "-query QT_INSTALL_LIBS"
425 OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP )
426 # make sure we have / and not \ as qmake gives on windows
427 FILE(TO_CMAKE_PATH "${QT_LIBRARY_DIR_TMP}" QT_LIBRARY_DIR_TMP)
428 IF(EXISTS "${QT_LIBRARY_DIR_TMP}")
429 SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir")
430 ELSE(EXISTS "${QT_LIBRARY_DIR_TMP}")
431 MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}")
432 MESSAGE("Warning: ${QT_LIBRARY_DIR_TMP} does NOT exist, Qt must NOT be installed correctly.")
433 ENDIF(EXISTS "${QT_LIBRARY_DIR_TMP}")
434 ENDIF(NOT QT_LIBRARY_DIR)
437 IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
438 SET(QT_USE_FRAMEWORKS ON
439 CACHE BOOL "Set to ON if Qt build uses frameworks.")
440 ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
441 SET(QT_USE_FRAMEWORKS OFF
442 CACHE BOOL "Set to ON if Qt build uses frameworks.")
443 ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
445 MARK_AS_ADVANCED(QT_USE_FRAMEWORKS)
448 # ask qmake for the binary dir
449 IF (QT_LIBRARY_DIR AND NOT QT_BINARY_DIR)
450 EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE}
451 ARGS "-query QT_INSTALL_BINS"
452 OUTPUT_VARIABLE qt_bins )
453 # make sure we have / and not \ as qmake gives on windows
454 FILE(TO_CMAKE_PATH "${qt_bins}" qt_bins)
455 SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "")
456 ENDIF (QT_LIBRARY_DIR AND NOT QT_BINARY_DIR)
458 # ask qmake for the include dir
459 IF (QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR)
460 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
461 ARGS "-query QT_INSTALL_HEADERS"
462 OUTPUT_VARIABLE qt_headers )
463 # make sure we have / and not \ as qmake gives on windows
464 FILE(TO_CMAKE_PATH "${qt_headers}" qt_headers)
465 SET(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "")
466 ENDIF(QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR)
469 # ask qmake for the documentation directory
470 IF (QT_LIBRARY_DIR AND NOT QT_DOC_DIR)
471 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
472 ARGS "-query QT_INSTALL_DOCS"
473 OUTPUT_VARIABLE qt_doc_dir )
474 # make sure we have / and not \ as qmake gives on windows
475 FILE(TO_CMAKE_PATH "${qt_doc_dir}" qt_doc_dir)
476 SET(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs")
477 ENDIF (QT_LIBRARY_DIR AND NOT QT_DOC_DIR)
479 # ask qmake for the mkspecs directory
480 IF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR)
481 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
482 ARGS "-query QMAKE_MKSPECS"
483 OUTPUT_VARIABLE qt_mkspecs_dirs )
484 # do not replace : on windows as it might be a drive letter
485 # and windows should already use ; as a separator
487 STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}")
489 FIND_PATH(QT_MKSPECS_DIR qconfig.pri PATHS ${qt_mkspecs_dirs}
490 DOC "The location of the Qt mkspecs containing qconfig.pri"
492 ENDIF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR)
494 # ask qmake for the plugins directory
495 IF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR)
496 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
497 ARGS "-query QT_INSTALL_PLUGINS"
498 OUTPUT_VARIABLE qt_plugins_dir )
499 # make sure we have / and not \ as qmake gives on windows
500 FILE(TO_CMAKE_PATH "${qt_plugins_dir}" qt_plugins_dir)
501 SET(QT_PLUGINS_DIR ${qt_plugins_dir} CACHE PATH "The location of the Qt plugins")
502 ENDIF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR)
503 ########################################
505 # Setting the INCLUDE-Variables
507 ########################################
509 FIND_PATH(QT_QTCORE_INCLUDE_DIR QtGlobal
510 ${QT_HEADERS_DIR}/QtCore
511 ${QT_LIBRARY_DIR}/QtCore.framework/Headers
515 # Set QT_INCLUDE_DIR by removine "/QtCore" in the string ${QT_QTCORE_INCLUDE_DIR}
516 IF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
517 IF (QT_USE_FRAMEWORKS)
518 SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR})
519 ELSE (QT_USE_FRAMEWORKS)
520 STRING( REGEX REPLACE "/QtCore$" "" qt4_include_dir ${QT_QTCORE_INCLUDE_DIR})
521 SET( QT_INCLUDE_DIR ${qt4_include_dir} CACHE PATH "")
522 ENDIF (QT_USE_FRAMEWORKS)
523 ENDIF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
525 IF( NOT QT_INCLUDE_DIR)
526 IF(Qt4_FIND_REQUIRED)
527 MESSAGE( FATAL_ERROR "Could NOT find QtGlobal header")
528 ENDIF(Qt4_FIND_REQUIRED)
529 ENDIF( NOT QT_INCLUDE_DIR)
531 #############################################
533 # Find out what window system we're using
535 #############################################
536 # Save required includes and required_flags variables
537 macro_push_required_vars()
538 # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES
539 SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}")
540 # On Mac OS X when Qt has framework support, also add the framework path
541 IF( QT_USE_FRAMEWORKS )
542 SET(CMAKE_REQUIRED_FLAGS "-F${QT_LIBRARY_DIR} ")
543 ENDIF( QT_USE_FRAMEWORKS )
544 # Check for Window system symbols (note: only one should end up being set)
545 CHECK_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11)
546 CHECK_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN)
547 CHECK_SYMBOL_EXISTS(Q_WS_QWS "QtCore/qglobal.h" Q_WS_QWS)
548 CHECK_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC)
550 IF (QT_QTCOPY_REQUIRED)
551 CHECK_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY)
552 IF (NOT QT_IS_QTCOPY)
553 MESSAGE(FATAL_ERROR "qt-copy is required, but hasn't been found")
554 ENDIF (NOT QT_IS_QTCOPY)
555 ENDIF (QT_QTCOPY_REQUIRED)
557 # Restore CMAKE_REQUIRED_INCLUDES+CMAKE_REQUIRED_FLAGS variables
558 macro_pop_required_vars()
560 #############################################
562 IF (QT_USE_FRAMEWORKS)
563 SET(QT_DEFINITIONS ${QT_DEFINITIONS} -F${QT_LIBRARY_DIR} -L${QT_LIBRARY_DIR} )
564 ENDIF (QT_USE_FRAMEWORKS)
566 # Set QT_QT3SUPPORT_INCLUDE_DIR
567 FIND_PATH(QT_QT3SUPPORT_INCLUDE_DIR Qt3Support
569 ${QT_INCLUDE_DIR}/Qt3Support
570 ${QT_LIBRARY_DIR}/Qt3Support.framework/Headers
574 # Set QT_QT_INCLUDE_DIR
575 FIND_PATH(QT_QT_INCLUDE_DIR qglobal.h
578 ${QT_LIBRARY_DIR}/QtCore.framework/Headers
582 # Set QT_QTGUI_INCLUDE_DIR
583 FIND_PATH(QT_QTGUI_INCLUDE_DIR QtGui
585 ${QT_INCLUDE_DIR}/QtGui
586 ${QT_LIBRARY_DIR}/QtGui.framework/Headers
590 # Set QT_QTSVG_INCLUDE_DIR
591 FIND_PATH(QT_QTSVG_INCLUDE_DIR QtSvg
593 ${QT_INCLUDE_DIR}/QtSvg
594 ${QT_LIBRARY_DIR}/QtSvg.framework/Headers
598 # Set QT_QTSCRIPT_INCLUDE_DIR
599 FIND_PATH(QT_QTSCRIPT_INCLUDE_DIR QtScript
601 ${QT_INCLUDE_DIR}/QtScript
602 ${QT_LIBRARY_DIR}/QtScript.framework/Headers
606 # Set QT_QTTEST_INCLUDE_DIR
607 FIND_PATH(QT_QTTEST_INCLUDE_DIR QtTest
609 ${QT_INCLUDE_DIR}/QtTest
610 ${QT_LIBRARY_DIR}/QtTest.framework/Headers
614 # Set QT_QTUITOOLS_INCLUDE_DIR
615 FIND_PATH(QT_QTUITOOLS_INCLUDE_DIR QtUiTools
617 ${QT_INCLUDE_DIR}/QtUiTools
618 ${QT_LIBRARY_DIR}/QtUiTools.framework/Headers
622 # Set QT_QTMOTIF_INCLUDE_DIR
624 FIND_PATH(QT_QTMOTIF_INCLUDE_DIR QtMotif
626 ${QT_INCLUDE_DIR}/QtMotif
630 # Set QT_QTNETWORK_INCLUDE_DIR
631 FIND_PATH(QT_QTNETWORK_INCLUDE_DIR QtNetwork
633 ${QT_INCLUDE_DIR}/QtNetwork
634 ${QT_LIBRARY_DIR}/QtNetwork.framework/Headers
638 # Set QT_QTNSPLUGIN_INCLUDE_DIR
639 FIND_PATH(QT_QTNSPLUGIN_INCLUDE_DIR QtNsPlugin
641 ${QT_INCLUDE_DIR}/QtNsPlugin
642 ${QT_LIBRARY_DIR}/QtNsPlugin.framework/Headers
646 # Set QT_QTOPENGL_INCLUDE_DIR
647 FIND_PATH(QT_QTOPENGL_INCLUDE_DIR QtOpenGL
649 ${QT_INCLUDE_DIR}/QtOpenGL
650 ${QT_LIBRARY_DIR}/QtOpenGL.framework/Headers
654 # Set QT_QTSQL_INCLUDE_DIR
655 FIND_PATH(QT_QTSQL_INCLUDE_DIR QtSql
657 ${QT_INCLUDE_DIR}/QtSql
658 ${QT_LIBRARY_DIR}/QtSql.framework/Headers
662 # Set QT_QTXML_INCLUDE_DIR
663 FIND_PATH(QT_QTXML_INCLUDE_DIR QtXml
665 ${QT_INCLUDE_DIR}/QtXml
666 ${QT_LIBRARY_DIR}/QtXml.framework/Headers
670 # Set QT_QTASSISTANT_INCLUDE_DIR
671 FIND_PATH(QT_QTASSISTANT_INCLUDE_DIR QtAssistant
673 ${QT_INCLUDE_DIR}/QtAssistant
674 ${QT_HEADERS_DIR}/QtAssistant
675 ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers
679 # Set QT_QTDESIGNER_INCLUDE_DIR
680 FIND_PATH(QT_QTDESIGNER_INCLUDE_DIR QDesignerComponents
682 ${QT_INCLUDE_DIR}/QtDesigner
683 ${QT_HEADERS_DIR}/QtDesigner
684 ${QT_LIBRARY_DIR}/QtDesigner.framework/Headers
688 # Set QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR
689 FIND_PATH(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR QDesignerComponents
691 ${QT_INCLUDE_DIR}/QtDesigner
692 ${QT_HEADERS_DIR}/QtDesigner
696 # Set QT_QTDBUS_INCLUDE_DIR
697 FIND_PATH(QT_QTDBUS_INCLUDE_DIR QtDBus
699 ${QT_INCLUDE_DIR}/QtDBus
700 ${QT_HEADERS_DIR}/QtDBus
701 ${QT_LIBRARY_DIR}/QtDBus.framework/Headers
705 # Set QT_QTASSISTANTCLIENT_INCLUDE_DIR
706 FIND_PATH(QT_QTASSISTANTCLIENT_INCLUDE_DIR QAssistantClient
708 ${QT_INCLUDE_DIR}/QtAssistant
709 ${QT_HEADERS_DIR}/QtAssistant
713 # Set QT_QTHELP_INCLUDE_DIR
714 FIND_PATH(QT_QTHELP_INCLUDE_DIR QtHelp
716 ${QT_INCLUDE_DIR}/QtHelp
717 ${QT_HEADERS_DIR}/QtHelp
721 # Set QT_QTWEBKIT_INCLUDE_DIR
722 FIND_PATH(QT_QTWEBKIT_INCLUDE_DIR QtWebKit
724 ${QT_INCLUDE_DIR}/QtWebKit
725 ${QT_HEADERS_DIR}/QtWebKit
729 # Set QT_QTXMLPATTERNS_INCLUDE_DIR
730 FIND_PATH(QT_QTXMLPATTERNS_INCLUDE_DIR QtXmlPatterns
732 ${QT_INCLUDE_DIR}/QtXmlPatterns
733 ${QT_HEADERS_DIR}/QtXmlPatterns
737 # Set QT_PHONON_INCLUDE_DIR
738 FIND_PATH(QT_PHONON_INCLUDE_DIR phonon
740 ${QT_INCLUDE_DIR}/phonon
744 # Make variables changeble to the advanced user
745 MARK_AS_ADVANCED( QT_LIBRARY_DIR QT_INCLUDE_DIR QT_QT_INCLUDE_DIR QT_DOC_DIR QT_MKSPECS_DIR QT_PLUGINS_DIR)
748 SET( QT_INCLUDES ${QT_QT_INCLUDE_DIR} ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} )
750 ########################################
752 # Setting the LIBRARY-Variables
754 ########################################
756 IF (QT_USE_FRAMEWORKS)
757 # If FIND_LIBRARY found libraries in Apple frameworks, we would NOT have
758 # to jump through these hoops.
759 IF(EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
760 SET(QT_QTCORE_FOUND TRUE)
761 SET(QT_QTCORE_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtCore" CACHE STRING "The QtCore library.")
762 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
763 SET(QT_QTCORE_FOUND FALSE)
764 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
766 IF(EXISTS ${QT_LIBRARY_DIR}/QtGui.framework)
767 SET(QT_QTGUI_FOUND TRUE)
768 SET(QT_QTGUI_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtGui" CACHE STRING "The QtGui library.")
769 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtGui.framework)
770 SET(QT_QTGUI_FOUND FALSE)
771 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtGui.framework)
773 IF(EXISTS ${QT_LIBRARY_DIR}/Qt3Support.framework)
774 SET(QT_QT3SUPPORT_FOUND TRUE)
775 SET(QT_QT3SUPPORT_LIBRARY "-F${QT_LIBRARY_DIR} -framework Qt3Support" CACHE STRING "The Qt3Support library.")
776 ELSE(EXISTS ${QT_LIBRARY_DIR}/Qt3Support.framework)
777 SET(QT_QT3SUPPORT_FOUND FALSE)
778 ENDIF(EXISTS ${QT_LIBRARY_DIR}/Qt3Support.framework)
780 IF(EXISTS ${QT_LIBRARY_DIR}/QtNetwork.framework)
781 SET(QT_QTNETWORK_FOUND TRUE)
782 SET(QT_QTNETWORK_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtNetwork" CACHE STRING "The QtNetwork library.")
783 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtNetwork.framework)
784 SET(QT_QTNETWORK_FOUND FALSE)
785 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtNetwork.framework)
787 IF(EXISTS ${QT_LIBRARY_DIR}/QtOpenGL.framework)
788 SET(QT_QTOPENGL_FOUND TRUE)
789 SET(QT_QTOPENGL_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtOpenGL" CACHE STRING "The QtOpenGL library.")
790 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtOpenGL.framework)
791 SET(QT_QTOPENGL_FOUND FALSE)
792 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtOpenGL.framework)
794 IF(EXISTS ${QT_LIBRARY_DIR}/QtSql.framework)
795 SET(QT_QTSQL_FOUND TRUE)
796 SET(QT_QTSQL_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtSql" CACHE STRING "The QtSql library.")
797 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtSql.framework)
798 SET(QT_QTSQL_FOUND FALSE)
799 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtSql.framework)
801 IF(EXISTS ${QT_LIBRARY_DIR}/QtXml.framework)
802 SET(QT_QTXML_FOUND TRUE)
803 SET(QT_QTXML_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtXml" CACHE STRING "The QtXml library.")
804 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtXml.framework)
805 SET(QT_QTXML_FOUND FALSE)
806 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtXml.framework)
808 IF(EXISTS ${QT_LIBRARY_DIR}/QtSvg.framework)
809 SET(QT_QTSVG_FOUND TRUE)
810 SET(QT_QTSVG_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtSvg" CACHE STRING "The QtSvg library.")
811 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtSvg.framework)
812 SET(QT_QTSVG_FOUND FALSE)
813 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtSvg.framework)
815 IF(EXISTS ${QT_LIBRARY_DIR}/QtDBus.framework)
816 SET(QT_QTDBUS_FOUND TRUE)
817 SET(QT_QTDBUS_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtDBus" CACHE STRING "The QtDBus library.")
818 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtDBus.framework)
819 SET(QT_QTDBUS_FOUND FALSE)
820 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtDBus.framework)
822 IF(EXISTS ${QT_LIBRARY_DIR}/QtTest.framework)
823 SET(QT_QTTEST_FOUND TRUE)
824 SET(QT_QTTEST_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtTest" CACHE STRING "The QtTest library.")
825 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtTest.framework)
826 SET(QT_QTTEST_FOUND FALSE)
827 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtTest.framework)
829 IF(EXISTS ${QT_LIBRARY_DIR}/QtAssistantClient.framework)
830 SET(QT_QTASSISTANTCLIENT_FOUND TRUE)
831 SET(QT_QTASSISTANTCLIENT_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtAssistantClient" CACHE STRING "The QtAssistantClient library.")
832 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtAssistantClient.framework)
833 SET(QT_QTASSISTANTCLIENT_FOUND FALSE)
834 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtAssistantClient.framework)
836 IF(EXISTS ${QT_LIBRARY_DIR}/QtWebKit.framework)
837 SET(QT_QTWEBKIT_FOUND TRUE)
838 SET(QT_QTWEBKIT_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtWebKit" CACHE STRING "The QtWebKit library.")
839 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtWebKit.framework)
840 SET(QT_QTWEBKIT_FOUND FALSE)
841 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtWebKit.framework)
843 IF(EXISTS ${QT_LIBRARY_DIR}/QtXmlPatterns.framework)
844 SET(QT_QTXMLPATTERNS_FOUND TRUE)
845 SET(QT_QTXMLPATTERNS_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtXmlPatterns" CACHE STRING "The QtXmlPatterns library.")
846 ELSE(EXISTS ${QT_LIBRARY_DIR}/QtXmlPatterns.framework)
847 SET(QT_QTXMLPATTERNS_FOUND FALSE)
848 ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtXmlPatterns.framework)
851 # WTF? why don't we have frameworks? :P
852 # Set QT_QTUITOOLS_LIBRARY
853 FIND_LIBRARY(QT_QTUITOOLS_LIBRARY NAMES QtUiTools QtUiTools4 PATHS ${QT_LIBRARY_DIR} )
854 # Set QT_QTSCRIPT_LIBRARY
855 FIND_LIBRARY(QT_QTSCRIPT_LIBRARY NAMES QtScript QtScript4 PATHS ${QT_LIBRARY_DIR} )
857 ELSE (QT_USE_FRAMEWORKS)
859 # Set QT_QTCORE_LIBRARY by searching for a lib with "QtCore." as part of the filename
860 FIND_LIBRARY(QT_QTCORE_LIBRARY NAMES QtCore QtCore4 QtCored4 QtCore_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH )
862 # Set QT_QT3SUPPORT_LIBRARY
863 FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY NAMES Qt3Support Qt3Support_debug Qt3Support4 Qt3Supportd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
865 # Set QT_QTGUI_LIBRARY
866 FIND_LIBRARY(QT_QTGUI_LIBRARY NAMES QtGui QtGui_debug QtGui_debug QtGui4 QtGuid4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
868 # Set QT_QTMOTIF_LIBRARY
870 FIND_LIBRARY(QT_QTMOTIF_LIBRARY NAMES QtMotif QtMotif_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
873 # Set QT_QTNETWORK_LIBRARY
874 FIND_LIBRARY(QT_QTNETWORK_LIBRARY NAMES QtNetwork QtNetwork_debug QtNetwork4 QtNetworkd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
876 # Set QT_QTNSPLUGIN_LIBRARY
877 FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY NAMES QtNsPlugin QtNsPlugin_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
879 # Set QT_QTOPENGL_LIBRARY
880 FIND_LIBRARY(QT_QTOPENGL_LIBRARY NAMES QtOpenGL QtOpenGL_debug QtOpenGL4 QtOpenGLd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
882 # Set QT_QTSQL_LIBRARY
883 FIND_LIBRARY(QT_QTSQL_LIBRARY NAMES QtSql QtSql_debug QtSql4 QtSqld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
885 # Set QT_QTXML_LIBRARY
886 FIND_LIBRARY(QT_QTXML_LIBRARY NAMES QtXml QtXml_debug QtXml4 QtXmld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
888 # Set QT_QTSVG_LIBRARY
889 FIND_LIBRARY(QT_QTSVG_LIBRARY NAMES QtSvg QtSvg_debug QtSvg4 QtSvgd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
891 # Set QT_QTSCRIPT_LIBRARY
892 FIND_LIBRARY(QT_QTSCRIPT_LIBRARY NAMES QtScript QtScript_debug QtScript4 QtScriptd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
894 # Set QT_QTUITOOLS_LIBRARY
895 FIND_LIBRARY(QT_QTUITOOLS_LIBRARY NAMES QtUiTools QtUiTools_debug QtUiTools4 QtUiToolsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
897 # Set QT_QTTEST_LIBRARY
898 FIND_LIBRARY(QT_QTTEST_LIBRARY NAMES QtTest QtTest_debug QtTest4 QtTestd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
900 FIND_LIBRARY(QT_QTDBUS_LIBRARY NAMES QtDBus QtDBus_debug QtDBus4 QtDBusd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
902 FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY NAMES QtAssistantClient QtAssistantClient_debug QtAssistantClient4 QtAssistantClientd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
904 FIND_LIBRARY(QT_QTHELP_LIBRARY NAMES QtHelp QtHelp_debug QtHelp4 QtHelpd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
906 FIND_LIBRARY(QT_QTWEBKIT_LIBRARY NAMES QtWebKit QtWebKit_debug QtWebKit4 QtWebKitd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
908 FIND_LIBRARY(QT_QTXMLPATTERNS_LIBRARY NAMES QtXmlPatterns QtXmlPatterns_debug QtXmlPatterns4 QtXmlPatternsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
910 FIND_LIBRARY(QT_PHONON_LIBRARY NAMES phonon phonon4 phonon_debug phonond4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
914 FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE NAMES QtCore4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
915 FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG NAMES QtCored4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
916 FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_RELEASE NAMES Qt3Support4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
917 FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG NAMES Qt3Supportd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
918 FIND_LIBRARY(QT_QTGUI_LIBRARY_RELEASE NAMES QtGui4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
919 FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG NAMES QtGuid4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
920 FIND_LIBRARY(QT_QTNETWORK_LIBRARY_RELEASE NAMES QtNetwork4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
921 FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG NAMES QtNetworkd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
922 FIND_LIBRARY(QT_QTOPENGL_LIBRARY_RELEASE NAMES QtOpenGL4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
923 FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG NAMES QtOpenGLd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
924 FIND_LIBRARY(QT_QTSQL_LIBRARY_RELEASE NAMES QtSql4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
925 FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG NAMES QtSqld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
926 FIND_LIBRARY(QT_QTXML_LIBRARY_RELEASE NAMES QtXml4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
927 FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG NAMES QtXmld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
928 FIND_LIBRARY(QT_QTSVG_LIBRARY_RELEASE NAMES QtSvg4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
929 FIND_LIBRARY(QT_QTSVG_LIBRARY_DEBUG NAMES QtSvgd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
930 FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_RELEASE NAMES QtScript4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
931 FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_DEBUG NAMES QtScriptd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
932 FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools QtUiTools4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
933 FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_DEBUG NAMES QtUiToolsd QtUiToolsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
934 FIND_LIBRARY(QT_QTTEST_LIBRARY_RELEASE NAMES QtTest4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
935 FIND_LIBRARY(QT_QTTEST_LIBRARY_DEBUG NAMES QtTestd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
936 FIND_LIBRARY(QT_QTDBUS_LIBRARY_RELEASE NAMES QtDBus4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
937 FIND_LIBRARY(QT_QTDBUS_LIBRARY_DEBUG NAMES QtDBusd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
938 FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
939 FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistantClientd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
940 FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_RELEASE NAMES QtDesigner4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
941 FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_DEBUG NAMES QtDesignerd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
942 FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
943 FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NAMES QtDesignerComponentsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
944 FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
945 FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmaind PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
947 ENDIF (QT_USE_FRAMEWORKS)
949 IF( NOT QT_QTCORE_LIBRARY )
950 IF(Qt4_FIND_REQUIRED)
951 MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.")
952 ENDIF(Qt4_FIND_REQUIRED)
953 ENDIF( NOT QT_QTCORE_LIBRARY )
955 # Set QT_QTASSISTANT_LIBRARY
956 FIND_LIBRARY(QT_QTASSISTANT_LIBRARY NAMES QtAssistantClient QtAssistantClient4 QtAssistant QtAssistant4 QtAssistantd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
958 # Set QT_QTDESIGNER_LIBRARY
959 FIND_LIBRARY(QT_QTDESIGNER_LIBRARY NAMES QtDesigner QtDesigner_debug QtDesigner4 QtDesignerd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
961 # Set QT_QTDESIGNERCOMPONENTS_LIBRARY
962 FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY NAMES QtDesignerComponents QtDesignerComponents_debug QtDesignerComponents4 QtDesignerComponentsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
964 # Set QT_QTMAIN_LIBRARY
966 FIND_LIBRARY(QT_QTMAIN_LIBRARY NAMES qtmain qtmaind PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
969 ############################################
971 # Check the existence of the libraries.
973 ############################################
975 MACRO (_QT4_ADJUST_LIB_VARS basename)
976 IF (QT_${basename}_LIBRARY OR QT_${basename}_LIBRARY_DEBUG)
980 IF (QT_${basename}_LIBRARY_RELEASE AND QT_${basename}_LIBRARY_DEBUG)
981 SET(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
982 ENDIF (QT_${basename}_LIBRARY_RELEASE AND QT_${basename}_LIBRARY_DEBUG)
984 # Only debug was found
985 IF (NOT QT_${basename}_LIBRARY_RELEASE AND QT_${basename}_LIBRARY_DEBUG)
986 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG})
987 ENDIF (NOT QT_${basename}_LIBRARY_RELEASE AND QT_${basename}_LIBRARY_DEBUG)
989 # Only release was found
990 IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
991 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE})
992 ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
994 # Hmm, is this used anywhere ? Yes, in UseQt4.cmake. We are currently incompatible :-(
995 SET(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY} debug ${QT_${basename}_LIBRARY_DEBUG})
999 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE FILEPATH "The Qt ${basename} library")
1001 IF (QT_${basename}_LIBRARY)
1002 SET(QT_${basename}_FOUND 1)
1003 ENDIF (QT_${basename}_LIBRARY)
1005 ENDIF (QT_${basename}_LIBRARY OR QT_${basename}_LIBRARY_DEBUG)
1007 IF (QT_${basename}_INCLUDE_DIR)
1008 #add the include directory to QT_INCLUDES
1009 SET(QT_INCLUDES "${QT_${basename}_INCLUDE_DIR}" ${QT_INCLUDES})
1010 ENDIF (QT_${basename}_INCLUDE_DIR)
1012 # Make variables changeble to the advanced user
1013 MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_INCLUDE_DIR)
1014 ENDMACRO (_QT4_ADJUST_LIB_VARS)
1017 # Set QT_xyz_LIBRARY variable and add
1018 # library include path to QT_INCLUDES
1019 _QT4_ADJUST_LIB_VARS(QTCORE)
1020 _QT4_ADJUST_LIB_VARS(QTGUI)
1021 _QT4_ADJUST_LIB_VARS(QT3SUPPORT)
1022 _QT4_ADJUST_LIB_VARS(QTASSISTANT)
1023 _QT4_ADJUST_LIB_VARS(QTDESIGNER)
1024 _QT4_ADJUST_LIB_VARS(QTDESIGNERCOMPONENTS)
1025 _QT4_ADJUST_LIB_VARS(QTNETWORK)
1026 _QT4_ADJUST_LIB_VARS(QTNSPLUGIN)
1027 _QT4_ADJUST_LIB_VARS(QTOPENGL)
1028 _QT4_ADJUST_LIB_VARS(QTSQL)
1029 _QT4_ADJUST_LIB_VARS(QTXML)
1030 _QT4_ADJUST_LIB_VARS(QTSVG)
1031 _QT4_ADJUST_LIB_VARS(QTSCRIPT)
1032 _QT4_ADJUST_LIB_VARS(QTUITOOLS)
1033 _QT4_ADJUST_LIB_VARS(QTTEST)
1034 _QT4_ADJUST_LIB_VARS(QTDBUS)
1035 _QT4_ADJUST_LIB_VARS(QTASSISTANTCLIENT)
1036 _QT4_ADJUST_LIB_VARS(QTHELP)
1037 _QT4_ADJUST_LIB_VARS(QTWEBKIT)
1038 _QT4_ADJUST_LIB_VARS(QTXMLPATTERNS)
1039 _QT4_ADJUST_LIB_VARS(PHONON)
1041 # platform dependent libraries
1043 _QT4_ADJUST_LIB_VARS(QTMOTIF)
1046 _QT4_ADJUST_LIB_VARS(QTMAIN)
1050 #######################################
1052 # Check the executables of Qt
1055 #######################################
1058 # find moc and uic using qmake
1059 QT_QUERY_QMAKE(QT_MOC_EXECUTABLE_INTERNAL "QMAKE_MOC")
1060 QT_QUERY_QMAKE(QT_UIC_EXECUTABLE_INTERNAL "QMAKE_UIC")
1062 # make sure we have / and not \ as qmake gives on windows
1064 "${QT_MOC_EXECUTABLE_INTERNAL}" QT_MOC_EXECUTABLE_INTERNAL)
1065 # make sure we have / and not \ as qmake gives on windows
1067 "${QT_UIC_EXECUTABLE_INTERNAL}" QT_UIC_EXECUTABLE_INTERNAL)
1069 SET(QT_MOC_EXECUTABLE
1070 ${QT_MOC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The moc executable")
1071 SET(QT_UIC_EXECUTABLE
1072 ${QT_UIC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The uic executable")
1074 FIND_PROGRAM(QT_UIC3_EXECUTABLE
1076 PATHS ${QT_BINARY_DIR}
1080 FIND_PROGRAM(QT_RCC_EXECUTABLE
1082 PATHS ${QT_BINARY_DIR}
1086 FIND_PROGRAM(QT_DBUSCPP2XML_EXECUTABLE
1088 PATHS ${QT_BINARY_DIR}
1092 FIND_PROGRAM(QT_DBUSXML2CPP_EXECUTABLE
1094 PATHS ${QT_BINARY_DIR}
1098 FIND_PROGRAM(QT_LUPDATE_EXECUTABLE
1100 PATHS ${QT_BINARY_DIR}
1104 FIND_PROGRAM(QT_LRELEASE_EXECUTABLE
1106 PATHS ${QT_BINARY_DIR}
1110 IF (QT_MOC_EXECUTABLE)
1111 SET(QT_WRAP_CPP "YES")
1112 ENDIF (QT_MOC_EXECUTABLE)
1114 IF (QT_UIC_EXECUTABLE)
1115 SET(QT_WRAP_UI "YES")
1116 ENDIF (QT_UIC_EXECUTABLE)
1120 MARK_AS_ADVANCED( QT_UIC_EXECUTABLE QT_UIC3_EXECUTABLE QT_MOC_EXECUTABLE
1121 QT_RCC_EXECUTABLE QT_DBUSXML2CPP_EXECUTABLE QT_DBUSCPP2XML_EXECUTABLE
1122 QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE)
1124 ######################################
1126 # Macros for building Qt files
1128 ######################################
1130 MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
1132 SET(${_qt4_options})
1133 SET(_QT4_DOING_OPTIONS FALSE)
1134 FOREACH(_currentArg ${ARGN})
1135 IF ("${_currentArg}" STREQUAL "OPTIONS")
1136 SET(_QT4_DOING_OPTIONS TRUE)
1137 ELSE ("${_currentArg}" STREQUAL "OPTIONS")
1138 IF(_QT4_DOING_OPTIONS)
1139 LIST(APPEND ${_qt4_options} "${_currentArg}")
1140 ELSE(_QT4_DOING_OPTIONS)
1141 LIST(APPEND ${_qt4_files} "${_currentArg}")
1142 ENDIF(_QT4_DOING_OPTIONS)
1143 ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
1144 ENDFOREACH(_currentArg)
1145 ENDMACRO (QT4_EXTRACT_OPTIONS)
1147 MACRO (QT4_GET_MOC_INC_DIRS _moc_INC_DIRS)
1148 SET(${_moc_INC_DIRS})
1149 GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES)
1151 FOREACH(_current ${_inc_DIRS})
1152 SET(${_moc_INC_DIRS} ${${_moc_INC_DIRS}} "-I" ${_current})
1153 ENDFOREACH(_current ${_inc_DIRS})
1155 # if Qt is installed only as framework, add -F /library/Frameworks to the moc arguments
1156 # otherwise moc can't find the headers in the framework include dirs
1157 IF(APPLE AND "${QT_QTCORE_INCLUDE_DIR}" MATCHES "/Library/Frameworks/")
1158 SET(${_moc_INC_DIRS} ${${_moc_INC_DIRS}} "-F/Library/Frameworks")
1159 ENDIF(APPLE AND "${QT_QTCORE_INCLUDE_DIR}" MATCHES "/Library/Frameworks/")
1161 ENDMACRO(QT4_GET_MOC_INC_DIRS)
1164 MACRO (QT4_GENERATE_MOC infile outfile )
1166 QT4_GET_MOC_INC_DIRS(moc_includes)
1168 GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE)
1171 SET (_moc_parameter_file ${outfile}_parameters)
1172 SET (_moc_param "${moc_includes} \n-o${outfile} \n${abs_infile}")
1173 STRING(REGEX REPLACE ";-I;" "\\n-I" _moc_param "${_moc_param}")
1174 FILE (WRITE ${_moc_parameter_file} "${_moc_param}")
1175 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1176 COMMAND ${QT_MOC_EXECUTABLE}
1177 ARGS @"${_moc_parameter_file}"
1178 DEPENDS ${abs_infile})
1180 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1181 COMMAND ${QT_MOC_EXECUTABLE}
1182 ARGS ${moc_includes} -o ${outfile} ${abs_infile}
1183 DEPENDS ${abs_infile})
1186 SET_SOURCE_FILES_PROPERTIES(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file
1188 MACRO_ADD_FILE_DEPENDENCIES(${abs_infile} ${outfile})
1189 ENDMACRO (QT4_GENERATE_MOC)
1192 # QT4_WRAP_CPP(outfiles inputfile ... )
1194 MACRO (QT4_WRAP_CPP outfiles )
1196 QT4_GET_MOC_INC_DIRS(moc_includes)
1197 QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
1199 FOREACH (it ${moc_files})
1200 GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
1201 GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
1203 SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/moc_${outfile}.cxx)
1204 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1205 COMMAND ${QT_MOC_EXECUTABLE}
1206 ARGS ${moc_includes} ${moc_options} -o ${outfile} ${it}
1208 SET(${outfiles} ${${outfiles}} ${outfile})
1211 ENDMACRO (QT4_WRAP_CPP)
1214 # QT4_WRAP_UI(outfiles inputfile ... )
1216 MACRO (QT4_WRAP_UI outfiles )
1217 QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
1219 FOREACH (it ${ui_files})
1220 GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
1221 GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
1222 SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
1223 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1224 COMMAND ${QT_UIC_EXECUTABLE}
1225 ARGS ${ui_options} -o ${outfile} ${infile}
1226 MAIN_DEPENDENCY ${infile})
1227 SET(${outfiles} ${${outfiles}} ${outfile})
1230 ENDMACRO (QT4_WRAP_UI)
1233 # QT4_ADD_RESOURCES(outfiles inputfile ... )
1235 MACRO (QT4_ADD_RESOURCES outfiles )
1236 QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN})
1238 FOREACH (it ${rcc_files})
1239 GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
1240 GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
1241 GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
1242 SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
1243 # parse file for dependencies
1244 # all files are absolute paths or relative to the location of the qrc file
1245 FILE(READ "${infile}" _RC_FILE_CONTENTS)
1246 STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
1248 FOREACH(_RC_FILE ${_RC_FILES})
1249 STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
1250 STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}")
1251 IF(NOT _ABS_PATH_INDICATOR)
1252 SET(_RC_FILE "${rc_path}/${_RC_FILE}")
1253 ENDIF(NOT _ABS_PATH_INDICATOR)
1254 SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
1255 ENDFOREACH(_RC_FILE)
1256 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1257 COMMAND ${QT_RCC_EXECUTABLE}
1258 ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
1259 MAIN_DEPENDENCY ${infile}
1260 DEPENDS ${_RC_DEPENDS})
1261 SET(${outfiles} ${${outfiles}} ${outfile})
1264 ENDMACRO (QT4_ADD_RESOURCES)
1266 MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename)
1267 GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE)
1268 SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
1269 SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
1270 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
1272 GET_SOURCE_FILE_PROPERTY(_nonamespace ${_interface} NO_NAMESPACE)
1275 ELSE ( _nonamespace )
1277 ENDIF ( _nonamespace )
1279 GET_SOURCE_FILE_PROPERTY(_classname ${_interface} CLASSNAME)
1281 SET(_params ${_params} -c ${_classname})
1282 ENDIF ( _classname )
1284 GET_SOURCE_FILE_PROPERTY(_include ${_interface} INCLUDE)
1286 SET(_params ${_params} -i ${_include})
1289 ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1290 COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile}
1293 SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
1295 QT4_GENERATE_MOC(${_header} ${_moc})
1297 SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
1298 MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
1300 ENDMACRO(QT4_ADD_DBUS_INTERFACE)
1303 MACRO(QT4_ADD_DBUS_INTERFACES _sources)
1304 FOREACH (_current_FILE ${ARGN})
1305 GET_FILENAME_COMPONENT(_infile ${_current_FILE} ABSOLUTE)
1306 # get the part before the ".xml" suffix
1307 STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2" _basename ${_current_FILE})
1308 STRING(TOLOWER ${_basename} _basename)
1309 QT4_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface)
1310 ENDFOREACH (_current_FILE)
1311 ENDMACRO(QT4_ADD_DBUS_INTERFACES)
1314 MACRO(QT4_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options )
1315 QT4_EXTRACT_OPTIONS(_customName _qt4_dbus_options ${ARGN})
1317 GET_FILENAME_COMPONENT(_in_file ${_header} ABSOLUTE)
1318 GET_FILENAME_COMPONENT(_basename ${_header} NAME_WE)
1321 SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName})
1323 SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml)
1326 ADD_CUSTOM_COMMAND(OUTPUT ${_target}
1327 COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} > ${_target}
1330 ENDMACRO(QT4_GENERATE_DBUS_INTERFACE)
1333 MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName)
1334 GET_FILENAME_COMPONENT(_infile ${_xml_file} ABSOLUTE)
1336 SET(_optionalBasename "${ARGV4}")
1337 IF (_optionalBasename)
1338 SET(_basename ${_optionalBasename} )
1339 ELSE (_optionalBasename)
1340 STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile})
1341 STRING(TOLOWER ${_basename} _basename)
1342 ENDIF (_optionalBasename)
1344 SET(_optionalClassName "${ARGV5}")
1345 SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
1346 SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
1347 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
1349 IF(_optionalClassName)
1350 ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1351 COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
1354 ELSE(_optionalClassName)
1355 ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1356 COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
1359 ENDIF(_optionalClassName)
1361 QT4_GENERATE_MOC(${_header} ${_moc})
1362 SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
1363 MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
1365 SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
1366 ENDMACRO(QT4_ADD_DBUS_ADAPTOR)
1369 QT4_GET_MOC_INC_DIRS(_moc_INCS)
1371 SET(_matching_FILES )
1372 FOREACH (_current_FILE ${ARGN})
1374 GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
1375 # if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
1376 # This is required to make uic work correctly:
1377 # we need to add generated .cpp files to the sources (to compile them),
1378 # but we cannot let automoc handle them, as the .cpp files don't exist yet when
1379 # cmake is run for the very first time on them -> however the .cpp files might
1380 # exist at a later run. at that time we need to skip them, so that we don't add two
1381 # different rules for the same moc file
1382 GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC)
1384 IF ( NOT _skip AND EXISTS ${_abs_FILE} )
1386 FILE(READ ${_abs_FILE} _contents)
1388 GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH)
1390 STRING(REGEX MATCHALL "#include +[^ ]+\\.moc[\">]" _match "${_contents}")
1392 FOREACH (_current_MOC_INC ${_match})
1393 STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
1395 GET_filename_component(_basename ${_current_MOC} NAME_WE)
1396 # SET(_header ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h)
1397 SET(_header ${_abs_PATH}/${_basename}.h)
1398 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
1399 ADD_CUSTOM_COMMAND(OUTPUT ${_moc}
1400 COMMAND ${QT_MOC_EXECUTABLE}
1401 ARGS ${_moc_INCS} ${_header} -o ${_moc}
1405 MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
1406 ENDFOREACH (_current_MOC_INC)
1408 ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} )
1409 ENDFOREACH (_current_FILE)
1410 ENDMACRO(QT4_AUTOMOC)
1414 ######################################
1416 # decide if Qt got found
1418 ######################################
1420 # if the includes,libraries,moc,uic and rcc are found then we have it
1421 IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1422 SET( QT4_FOUND "YES" )
1423 IF( NOT Qt4_FIND_QUIETLY)
1424 MESSAGE(STATUS "Found Qt-Version ${QTVERSION} (using ${QT_QMAKE_EXECUTABLE})")
1425 ENDIF( NOT Qt4_FIND_QUIETLY)
1426 ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1427 SET( QT4_FOUND "NO")
1428 SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1429 IF( Qt4_FIND_REQUIRED)
1430 IF ( NOT QT_LIBRARY_DIR )
1431 MESSAGE(STATUS "Qt libraries NOT found!")
1432 ENDIF(NOT QT_LIBRARY_DIR )
1433 IF ( NOT QT_INCLUDE_DIR )
1434 MESSAGE(STATUS "Qt includes NOT found!")
1435 ENDIF( NOT QT_INCLUDE_DIR )
1436 IF ( NOT QT_MOC_EXECUTABLE )
1437 MESSAGE(STATUS "Qt's moc NOT found!")
1438 ENDIF( NOT QT_MOC_EXECUTABLE )
1439 IF ( NOT QT_UIC_EXECUTABLE )
1440 MESSAGE(STATUS "Qt's uic NOT found!")
1441 ENDIF( NOT QT_UIC_EXECUTABLE )
1442 IF ( NOT QT_RCC_EXECUTABLE )
1443 MESSAGE(STATUS "Qt's rcc NOT found!")
1444 ENDIF( NOT QT_RCC_EXECUTABLE )
1445 MESSAGE( FATAL_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!")
1446 ENDIF( Qt4_FIND_REQUIRED)
1447 ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1448 SET(QT_FOUND ${QT4_FOUND})
1451 #######################################
1453 # System dependent settings
1455 #######################################
1456 # for unix add X11 stuff
1458 # on OS X X11 may not be required
1460 FIND_PACKAGE(X11 REQUIRED)
1462 FIND_PACKAGE(Threads)
1463 SET(QT_QTCORE_LIBRARY ${QT_QTCORE_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
1467 #######################################
1469 # compatibility settings
1471 #######################################
1472 # Backwards compatibility for CMake1.4 and 1.2
1473 SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} )
1474 SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} )
1476 SET( QT_QT_LIBRARY "")
1478 ELSE(QT4_QMAKE_FOUND)
1480 SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1481 IF(Qt4_FIND_REQUIRED)
1482 IF(QT4_INSTALLED_VERSION_TOO_OLD)
1483 MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1484 ELSE(QT4_INSTALLED_VERSION_TOO_OLD)
1485 MESSAGE( FATAL_ERROR "Qt qmake not found!")
1486 ENDIF(QT4_INSTALLED_VERSION_TOO_OLD)
1487 ELSE(Qt4_FIND_REQUIRED)
1488 IF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1489 MESSAGE(STATUS "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1490 ENDIF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1491 ENDIF(Qt4_FIND_REQUIRED)
1493 ENDIF (QT4_QMAKE_FOUND)