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
87 # macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... )
88 # create the interface header and implementation files
89 # for all listed interface xml files
90 # the name will be automatically determined from the name of the xml file
92 # macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname [basename] )
93 # create a dbus adaptor (header and implementation file) from the xml file
94 # describing the interface, and add it to the list of sources. The adaptor
95 # forwards the calls to a parent class, defined in parentheader and named
96 # parentclassname. The name of the generated files will be
97 # <basename>adaptor.{cpp,h} where basename is the basename of the xml file.
99 # macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] )
100 # generate the xml interface file from the given header.
101 # If the optional argument interfacename is omitted, the name of the
102 # interface file is constructed from the basename of the header with
103 # the suffix .xml appended.
105 # macro QT4_CREATE_TRANSLATION( qm_files sources ... ts_files ... )
107 # in: sources ts_files
108 # generates commands to create .ts (vie lupdate) and .qm
109 # (via lrelease) - files from sources. The ts files are
110 # created and/or updated in the source tree (unless given with full paths).
111 # The qm files are generated in the build tree.
112 # Updating the translations can be done by adding the qm_files
113 # to the source list of your library/executable, so they are
114 # always updated, or by adding a custom target to control when
115 # they get updated/generated.
117 # macro QT4_ADD_TRANSLATION( qm_files ts_files ... )
120 # generates commands to create .qm from .ts - files. The generated
121 # filenames can be found in qm_files. The ts_files
122 # must exists and are not updated in any way.
125 # QT_FOUND If false, don't try to use Qt.
126 # QT4_FOUND If false, don't try to use Qt 4.
128 # QT_VERSION_MAJOR The major version of Qt found.
129 # QT_VERSION_MINOR The minor version of Qt found.
130 # QT_VERSION_PATCH The patch version of Qt found.
132 # QT_EDITION Set to the edition of Qt (i.e. DesktopLight)
133 # QT_EDITION_DESKTOPLIGHT True if QT_EDITION == DesktopLight
134 # QT_QTCORE_FOUND True if QtCore was found.
135 # QT_QTGUI_FOUND True if QtGui was found.
136 # QT_QT3SUPPORT_FOUND True if Qt3Support was found.
137 # QT_QTASSISTANT_FOUND True if QtAssistant was found.
138 # QT_QTDBUS_FOUND True if QtDBus was found.
139 # QT_QTDESIGNER_FOUND True if QtDesigner was found.
140 # QT_QTDESIGNERCOMPONENTS True if QtDesignerComponents was found.
141 # QT_QTMOTIF_FOUND True if QtMotif was found.
142 # QT_QTNETWORK_FOUND True if QtNetwork was found.
143 # QT_QTNSPLUGIN_FOUND True if QtNsPlugin was found.
144 # QT_QTOPENGL_FOUND True if QtOpenGL was found.
145 # QT_QTSQL_FOUND True if QtSql was found.
146 # QT_QTXML_FOUND True if QtXml was found.
147 # QT_QTSVG_FOUND True if QtSvg was found.
148 # QT_QTSCRIPT_FOUND True if QtScript was found.
149 # QT_QTTEST_FOUND True if QtTest was found.
150 # QT_QTUITOOLS_FOUND True if QtUiTools was found.
151 # QT_QTASSISTANTCLIENT_FOUND True if QtAssistantClient was found.
152 # QT_QTHELP_FOUND True if QtHelp was found.
153 # QT_QTWEBKIT_FOUND True if QtWebKit was found.
154 # QT_QTXMLPATTERNS_FOUND True if QtXmlPatterns was found.
155 # QT_PHONON_FOUND True if phonon was found.
158 # QT_DEFINITIONS Definitions to use when compiling code that uses Qt.
159 # You do not need to use this if you include QT_USE_FILE.
160 # The QT_USE_FILE will also define QT_DEBUG and QT_NO_DEBUG
161 # to fit your current build type. Those are not contained
164 # QT_INCLUDES List of paths to all include directories of
165 # Qt4 QT_INCLUDE_DIR and QT_QTCORE_INCLUDE_DIR are
166 # always in this variable even if NOTFOUND,
167 # all other INCLUDE_DIRS are
168 # only added if they are found.
169 # You do not need to use this if you include QT_USE_FILE.
172 # Include directories for the Qt modules are listed here.
173 # You do not need to use these variables if you include QT_USE_FILE.
175 # QT_INCLUDE_DIR Path to "include" of Qt4
176 # QT_QT_INCLUDE_DIR Path to "include/Qt"
177 # QT_QT3SUPPORT_INCLUDE_DIR Path to "include/Qt3Support"
178 # QT_QTASSISTANT_INCLUDE_DIR Path to "include/QtAssistant"
179 # QT_QTCORE_INCLUDE_DIR Path to "include/QtCore"
180 # QT_QTDESIGNER_INCLUDE_DIR Path to "include/QtDesigner"
181 # QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR Path to "include/QtDesigner"
182 # QT_QTDBUS_INCLUDE_DIR Path to "include/QtDBus"
183 # QT_QTGUI_INCLUDE_DIR Path to "include/QtGui"
184 # QT_QTMOTIF_INCLUDE_DIR Path to "include/QtMotif"
185 # QT_QTNETWORK_INCLUDE_DIR Path to "include/QtNetwork"
186 # QT_QTNSPLUGIN_INCLUDE_DIR Path to "include/QtNsPlugin"
187 # QT_QTOPENGL_INCLUDE_DIR Path to "include/QtOpenGL"
188 # QT_QTSQL_INCLUDE_DIR Path to "include/QtSql"
189 # QT_QTXML_INCLUDE_DIR Path to "include/QtXml"
190 # QT_QTSVG_INCLUDE_DIR Path to "include/QtSvg"
191 # QT_QTSCRIPT_INCLUDE_DIR Path to "include/QtScript"
192 # QT_QTTEST_INCLUDE_DIR Path to "include/QtTest"
193 # QT_QTASSISTANTCLIENT_INCLUDE_DIR Path to "include/QtAssistant"
194 # QT_QTHELP_INCLUDE_DIR Path to "include/QtHelp"
195 # QT_QTWEBKIT_INCLUDE_DIR Path to "include/QtWebKit"
196 # QT_QTXMLPATTERNS_INCLUDE_DIR Path to "include/QtXmlPatterns"
197 # QT_PHONON_INCLUDE_DIR Path to "include/phonon"
199 # QT_LIBRARY_DIR Path to "lib" of Qt4
201 # QT_PLUGINS_DIR Path to "plugins" for Qt4
204 # The Qt toolkit may contain both debug and release libraries.
205 # In that case, the following library variables will contain both.
206 # You do not need to use these variables if you include QT_USE_FILE,
207 # and use QT_LIBRARIES.
209 # QT_QT3SUPPORT_LIBRARY The Qt3Support library
210 # QT_QTASSISTANT_LIBRARY The QtAssistant library
211 # QT_QTCORE_LIBRARY The QtCore library
212 # QT_QTDBUS_LIBRARY The QtDBus library
213 # QT_QTDESIGNER_LIBRARY The QtDesigner library
214 # QT_QTDESIGNERCOMPONENTS_LIBRARY The QtDesignerComponents library
215 # QT_QTGUI_LIBRARY The QtGui library
216 # QT_QTMOTIF_LIBRARY The QtMotif library
217 # QT_QTNETWORK_LIBRARY The QtNetwork library
218 # QT_QTNSPLUGIN_LIBRARY The QtNsPLugin library
219 # QT_QTOPENGL_LIBRARY The QtOpenGL library
220 # QT_QTSQL_LIBRARY The QtSql library
221 # QT_QTXML_LIBRARY The QtXml library
222 # QT_QTSVG_LIBRARY The QtSvg library
223 # QT_QTSCRIPT_LIBRARY The QtScript library
224 # QT_QTTEST_LIBRARY The QtTest library
225 # QT_QTMAIN_LIBRARY The qtmain library for Windows
226 # QT_QTUITOOLS_LIBRARY The QtUiTools library
227 # QT_QTASSISTANTCLIENT_LIBRARY The QtAssistantClient library
228 # QT_QTHELP_LIBRARY The QtHelp library
229 # QT_QTWEBKIT_LIBRARY The QtWebKit library
230 # QT_QTXMLPATTERNS_LIBRARY The QtXmlPatterns library
231 # QT_PHONON_LIBRARY The phonon library
233 # also defined, but NOT for general use are
234 # QT_MOC_EXECUTABLE Where to find the moc tool.
235 # QT_UIC_EXECUTABLE Where to find the uic tool.
236 # QT_UIC3_EXECUTABLE Where to find the uic3 tool.
237 # QT_RCC_EXECUTABLE Where to find the rcc tool
238 # QT_DBUSCPP2XML_EXECUTABLE Where to find the qdbuscpp2xml tool.
239 # QT_DBUSXML2CPP_EXECUTABLE Where to find the qdbusxml2cpp tool.
240 # QT_LUPDATE_EXECUTABLE Where to find the lupdate tool.
241 # QT_LRELEASE_EXECUTABLE Where to find the lrelease tool.
243 # QT_DOC_DIR Path to "doc" of Qt4
244 # QT_MKSPECS_DIR Path to "mkspecs" of Qt4
247 # These are around for backwards compatibility
249 # QT_WRAP_CPP Set true if QT_MOC_EXECUTABLE is found
250 # QT_WRAP_UI Set true if QT_UIC_EXECUTABLE is found
252 # These variables do _NOT_ have any effect anymore (compared to FindQt.cmake)
253 # QT_MT_REQUIRED Qt4 is now always multithreaded
255 # These variables are set to "" Because Qt structure changed
256 # (They make no sense in Qt4)
257 # QT_QT_LIBRARY Qt-Library is now split
259 INCLUDE(CheckSymbolExists)
260 INCLUDE(MacroAddFileDependencies)
262 SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake)
264 SET( QT_DEFINITIONS "")
266 SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE)
268 # macro for asking qmake to process pro files
269 MACRO(QT_QUERY_QMAKE outvar invar)
270 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake/tmp.pro
271 "message(CMAKE_MESSAGE<$$${invar}>)")
273 # Invoke qmake with the tmp.pro program to get the desired
274 # information. Use the same variable for both stdout and stderr
275 # to make sure we get the output on all platforms.
276 EXECUTE_PROCESS(COMMAND ${QT_QMAKE_EXECUTABLE}
278 ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake
279 OUTPUT_VARIABLE _qmake_query_output
280 RESULT_VARIABLE _qmake_result
281 ERROR_VARIABLE _qmake_query_output )
284 "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake")
287 MESSAGE(WARNING " querying qmake for ${invar}. qmake reported:\n${_qmake_query_output}")
289 STRING(REGEX REPLACE ".*CMAKE_MESSAGE<([^>]*).*" "\\1" ${outvar} "${_qmake_query_output}")
292 ENDMACRO(QT_QUERY_QMAKE)
294 GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME)
296 FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 PATHS
297 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
298 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
299 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]/bin"
303 IF (QT_QMAKE_EXECUTABLE)
305 SET(QT4_QMAKE_FOUND FALSE)
307 EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
309 # check for qt3 qmake and then try and find qmake4 or qmake-qt4 in the path
310 IF("${QTVERSION}" MATCHES "Unknown")
311 SET(QT_QMAKE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE)
312 FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 PATHS
313 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
314 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
317 IF(QT_QMAKE_EXECUTABLE)
318 EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE}
319 ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
320 ENDIF(QT_QMAKE_EXECUTABLE)
321 ENDIF("${QTVERSION}" MATCHES "Unknown")
323 # check that we found the Qt4 qmake, Qt3 qmake output won't match here
324 STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" qt_version_tmp "${QTVERSION}")
327 # we need at least version 4.0.0
328 IF (NOT QT_MIN_VERSION)
329 SET(QT_MIN_VERSION "4.0.0")
330 ENDIF (NOT QT_MIN_VERSION)
332 #now parse the parts of the user given version string into variables
333 STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" req_qt_major_vers "${QT_MIN_VERSION}")
334 IF (NOT req_qt_major_vers)
335 MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"4.0.1\"")
336 ENDIF (NOT req_qt_major_vers)
338 # now parse the parts of the user given version string into variables
339 STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}")
340 STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers "${QT_MIN_VERSION}")
341 STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}")
343 IF (NOT req_qt_major_vers EQUAL 4)
344 MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", major version 4 is required, e.g. \"4.0.1\"")
345 ENDIF (NOT req_qt_major_vers EQUAL 4)
347 # and now the version string given by qmake
348 STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" QT_VERSION_MAJOR "${QTVERSION}")
349 STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" QT_VERSION_MINOR "${QTVERSION}")
350 STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" QT_VERSION_PATCH "${QTVERSION}")
352 # compute an overall version number which can be compared at once
353 MATH(EXPR req_vers "${req_qt_major_vers}*10000 + ${req_qt_minor_vers}*100 + ${req_qt_patch_vers}")
354 MATH(EXPR found_vers "${QT_VERSION_MAJOR}*10000 + ${QT_VERSION_MINOR}*100 + ${QT_VERSION_PATCH}")
356 IF (found_vers LESS req_vers)
357 SET(QT4_QMAKE_FOUND FALSE)
358 SET(QT4_INSTALLED_VERSION_TOO_OLD TRUE)
359 ELSE (found_vers LESS req_vers)
360 SET(QT4_QMAKE_FOUND TRUE)
361 ENDIF (found_vers LESS req_vers)
362 ENDIF (qt_version_tmp)
364 ENDIF (QT_QMAKE_EXECUTABLE)
368 # ask qmake for the library dir
370 IF (NOT QT_LIBRARY_DIR)
371 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
372 ARGS "-query QT_INSTALL_LIBS"
373 OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP )
374 # make sure we have / and not \ as qmake gives on windows
375 FILE(TO_CMAKE_PATH "${QT_LIBRARY_DIR_TMP}" QT_LIBRARY_DIR_TMP)
376 IF(EXISTS "${QT_LIBRARY_DIR_TMP}")
377 SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir")
378 ELSE(EXISTS "${QT_LIBRARY_DIR_TMP}")
379 MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}")
380 MESSAGE("Warning: ${QT_LIBRARY_DIR_TMP} does NOT exist, Qt must NOT be installed correctly.")
381 ENDIF(EXISTS "${QT_LIBRARY_DIR_TMP}")
382 ENDIF(NOT QT_LIBRARY_DIR)
385 IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
386 SET(QT_USE_FRAMEWORKS ON
387 CACHE BOOL "Set to ON if Qt build uses frameworks.")
388 ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
389 SET(QT_USE_FRAMEWORKS OFF
390 CACHE BOOL "Set to ON if Qt build uses frameworks.")
391 ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
393 MARK_AS_ADVANCED(QT_USE_FRAMEWORKS)
396 # ask qmake for the binary dir
397 IF (QT_LIBRARY_DIR AND NOT QT_BINARY_DIR)
398 EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE}
399 ARGS "-query QT_INSTALL_BINS"
400 OUTPUT_VARIABLE qt_bins )
401 # make sure we have / and not \ as qmake gives on windows
402 FILE(TO_CMAKE_PATH "${qt_bins}" qt_bins)
403 SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "")
404 ENDIF (QT_LIBRARY_DIR AND NOT QT_BINARY_DIR)
406 # ask qmake for the include dir
407 IF (QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR)
408 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
409 ARGS "-query QT_INSTALL_HEADERS"
410 OUTPUT_VARIABLE qt_headers )
411 # make sure we have / and not \ as qmake gives on windows
412 FILE(TO_CMAKE_PATH "${qt_headers}" qt_headers)
413 SET(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "")
414 ENDIF(QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR)
417 # ask qmake for the documentation directory
418 IF (QT_LIBRARY_DIR AND NOT QT_DOC_DIR)
419 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
420 ARGS "-query QT_INSTALL_DOCS"
421 OUTPUT_VARIABLE qt_doc_dir )
422 # make sure we have / and not \ as qmake gives on windows
423 FILE(TO_CMAKE_PATH "${qt_doc_dir}" qt_doc_dir)
424 SET(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs")
425 ENDIF (QT_LIBRARY_DIR AND NOT QT_DOC_DIR)
427 # ask qmake for the mkspecs directory
428 IF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR)
429 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
430 ARGS "-query QMAKE_MKSPECS"
431 OUTPUT_VARIABLE qt_mkspecs_dirs )
432 # do not replace : on windows as it might be a drive letter
433 # and windows should already use ; as a separator
435 STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}")
437 FIND_PATH(QT_MKSPECS_DIR qconfig.pri PATHS ${qt_mkspecs_dirs}
438 DOC "The location of the Qt mkspecs containing qconfig.pri"
440 ENDIF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR)
442 # ask qmake for the plugins directory
443 IF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR)
444 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
445 ARGS "-query QT_INSTALL_PLUGINS"
446 OUTPUT_VARIABLE qt_plugins_dir )
447 # make sure we have / and not \ as qmake gives on windows
448 FILE(TO_CMAKE_PATH "${qt_plugins_dir}" qt_plugins_dir)
449 SET(QT_PLUGINS_DIR ${qt_plugins_dir} CACHE PATH "The location of the Qt plugins")
450 ENDIF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR)
451 ########################################
453 # Setting the INCLUDE-Variables
455 ########################################
457 FIND_PATH(QT_QTCORE_INCLUDE_DIR QtGlobal
458 ${QT_HEADERS_DIR}/QtCore
459 ${QT_LIBRARY_DIR}/QtCore.framework/Headers
463 # Set QT_INCLUDE_DIR by removine "/QtCore" in the string ${QT_QTCORE_INCLUDE_DIR}
464 IF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
465 IF (QT_USE_FRAMEWORKS)
466 SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR})
467 ELSE (QT_USE_FRAMEWORKS)
468 STRING( REGEX REPLACE "/QtCore$" "" qt4_include_dir ${QT_QTCORE_INCLUDE_DIR})
469 SET( QT_INCLUDE_DIR ${qt4_include_dir} CACHE PATH "")
470 ENDIF (QT_USE_FRAMEWORKS)
471 ENDIF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
473 IF( NOT QT_INCLUDE_DIR)
474 IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
475 MESSAGE( FATAL_ERROR "Could NOT find QtGlobal header")
476 ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
477 ENDIF( NOT QT_INCLUDE_DIR)
479 #############################################
481 # Find out what window system we're using
483 #############################################
484 # Save required variable
485 SET(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
486 SET(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
487 # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES
488 SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}")
489 # On Mac OS X when Qt has framework support, also add the framework path
490 IF( QT_USE_FRAMEWORKS )
491 SET(CMAKE_REQUIRED_FLAGS "-F${QT_LIBRARY_DIR} ")
492 ENDIF( QT_USE_FRAMEWORKS )
493 # Check for Window system symbols (note: only one should end up being set)
494 CHECK_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11)
495 CHECK_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN)
496 CHECK_SYMBOL_EXISTS(Q_WS_QWS "QtCore/qglobal.h" Q_WS_QWS)
497 CHECK_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC)
499 IF (QT_QTCOPY_REQUIRED)
500 CHECK_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY)
501 IF (NOT QT_IS_QTCOPY)
502 MESSAGE(FATAL_ERROR "qt-copy is required, but hasn't been found")
503 ENDIF (NOT QT_IS_QTCOPY)
504 ENDIF (QT_QTCOPY_REQUIRED)
506 # Restore CMAKE_REQUIRED_INCLUDES and CMAKE_REQUIRED_FLAGS variables
507 SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
508 SET(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
510 #############################################
512 IF (QT_USE_FRAMEWORKS)
513 SET(QT_DEFINITIONS ${QT_DEFINITIONS} -F${QT_LIBRARY_DIR} -L${QT_LIBRARY_DIR} )
514 ENDIF (QT_USE_FRAMEWORKS)
516 # Set QT_QT3SUPPORT_INCLUDE_DIR
517 FIND_PATH(QT_QT3SUPPORT_INCLUDE_DIR Qt3Support
519 ${QT_INCLUDE_DIR}/Qt3Support
520 ${QT_LIBRARY_DIR}/Qt3Support.framework/Headers
524 # Set QT_QT_INCLUDE_DIR
525 FIND_PATH(QT_QT_INCLUDE_DIR qglobal.h
528 ${QT_LIBRARY_DIR}/QtCore.framework/Headers
532 # Set QT_QTGUI_INCLUDE_DIR
533 FIND_PATH(QT_QTGUI_INCLUDE_DIR QtGui
535 ${QT_INCLUDE_DIR}/QtGui
536 ${QT_LIBRARY_DIR}/QtGui.framework/Headers
540 # Set QT_QTSVG_INCLUDE_DIR
541 FIND_PATH(QT_QTSVG_INCLUDE_DIR QtSvg
543 ${QT_INCLUDE_DIR}/QtSvg
544 ${QT_LIBRARY_DIR}/QtSvg.framework/Headers
548 # Set QT_QTSCRIPT_INCLUDE_DIR
549 FIND_PATH(QT_QTSCRIPT_INCLUDE_DIR QtScript
551 ${QT_INCLUDE_DIR}/QtScript
552 ${QT_LIBRARY_DIR}/QtScript.framework/Headers
556 # Set QT_QTTEST_INCLUDE_DIR
557 FIND_PATH(QT_QTTEST_INCLUDE_DIR QtTest
559 ${QT_INCLUDE_DIR}/QtTest
560 ${QT_LIBRARY_DIR}/QtTest.framework/Headers
564 # Set QT_QTUITOOLS_INCLUDE_DIR
565 FIND_PATH(QT_QTUITOOLS_INCLUDE_DIR QtUiTools
567 ${QT_INCLUDE_DIR}/QtUiTools
568 ${QT_LIBRARY_DIR}/QtUiTools.framework/Headers
572 # Set QT_QTMOTIF_INCLUDE_DIR
574 FIND_PATH(QT_QTMOTIF_INCLUDE_DIR QtMotif
576 ${QT_INCLUDE_DIR}/QtMotif
580 # Set QT_QTNETWORK_INCLUDE_DIR
581 FIND_PATH(QT_QTNETWORK_INCLUDE_DIR QtNetwork
583 ${QT_INCLUDE_DIR}/QtNetwork
584 ${QT_LIBRARY_DIR}/QtNetwork.framework/Headers
588 # Set QT_QTNSPLUGIN_INCLUDE_DIR
589 FIND_PATH(QT_QTNSPLUGIN_INCLUDE_DIR QtNsPlugin
591 ${QT_INCLUDE_DIR}/QtNsPlugin
592 ${QT_LIBRARY_DIR}/QtNsPlugin.framework/Headers
596 # Set QT_QTOPENGL_INCLUDE_DIR
597 FIND_PATH(QT_QTOPENGL_INCLUDE_DIR QtOpenGL
599 ${QT_INCLUDE_DIR}/QtOpenGL
600 ${QT_LIBRARY_DIR}/QtOpenGL.framework/Headers
604 # Set QT_QTSQL_INCLUDE_DIR
605 FIND_PATH(QT_QTSQL_INCLUDE_DIR QtSql
607 ${QT_INCLUDE_DIR}/QtSql
608 ${QT_LIBRARY_DIR}/QtSql.framework/Headers
612 # Set QT_QTXML_INCLUDE_DIR
613 FIND_PATH(QT_QTXML_INCLUDE_DIR QtXml
615 ${QT_INCLUDE_DIR}/QtXml
616 ${QT_LIBRARY_DIR}/QtXml.framework/Headers
620 # Set QT_QTASSISTANT_INCLUDE_DIR
621 FIND_PATH(QT_QTASSISTANT_INCLUDE_DIR QtAssistant
623 ${QT_INCLUDE_DIR}/QtAssistant
624 ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers
628 # Set QT_QTDESIGNER_INCLUDE_DIR
629 FIND_PATH(QT_QTDESIGNER_INCLUDE_DIR QDesignerComponents
631 ${QT_INCLUDE_DIR}/QtDesigner
632 ${QT_LIBRARY_DIR}/QtDesigner.framework/Headers
636 # Set QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR
637 FIND_PATH(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR QDesignerComponents
639 ${QT_INCLUDE_DIR}/QtDesigner
640 ${QT_LIBRARY_DIR}/QtDesigner.framework/Headers
644 # Set QT_QTDBUS_INCLUDE_DIR
645 FIND_PATH(QT_QTDBUS_INCLUDE_DIR QtDBus
647 ${QT_INCLUDE_DIR}/QtDBus
651 # Set QT_QTASSISTANTCLIENT_INCLUDE_DIR
652 FIND_PATH(QT_QTASSISTANTCLIENT_INCLUDE_DIR QAssistantClient
654 ${QT_INCLUDE_DIR}/QtAssistant
655 ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers
659 # Set QT_QTHELP_INCLUDE_DIR
660 FIND_PATH(QT_QTHELP_INCLUDE_DIR QtHelp
662 ${QT_INCLUDE_DIR}/QtHelp
663 ${QT_LIBRARY_DIR}/QtHelp.framework/Headers
667 # Set QT_QTWEBKIT_INCLUDE_DIR
668 FIND_PATH(QT_QTWEBKIT_INCLUDE_DIR QtWebKit
670 ${QT_INCLUDE_DIR}/QtWebKit
671 ${QT_LIBRARY_DIR}/QtWebKit.framework/Headers
675 # Set QT_QTXMLPATTERNS_INCLUDE_DIR
676 FIND_PATH(QT_QTXMLPATTERNS_INCLUDE_DIR QtXmlPatterns
678 ${QT_INCLUDE_DIR}/QtXmlPatterns
679 ${QT_LIBRARY_DIR}/QtXmlPatterns.framework/Headers
683 # Set QT_PHONON_INCLUDE_DIR
684 FIND_PATH(QT_PHONON_INCLUDE_DIR phonon
686 ${QT_INCLUDE_DIR}/phonon
690 # Make variables changeble to the advanced user
691 MARK_AS_ADVANCED( QT_LIBRARY_DIR QT_INCLUDE_DIR QT_QT_INCLUDE_DIR QT_DOC_DIR QT_MKSPECS_DIR QT_PLUGINS_DIR)
694 SET( QT_INCLUDES ${QT_QT_INCLUDE_DIR} ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} )
696 # Set QT_QTCORE_LIBRARY by searching for a lib with "QtCore." as part of the filename
697 FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE NAMES QtCore QtCore4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH )
698 FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG NAMES QtCore_debug QtCored QtCored4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
700 # Set QT_QT3SUPPORT_LIBRARY
701 FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_RELEASE NAMES Qt3Support Qt3Support4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
702 FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG NAMES Qt3Support_debug Qt3Supportd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
704 # Set QT_QTGUI_LIBRARY
705 FIND_LIBRARY(QT_QTGUI_LIBRARY_RELEASE NAMES QtGui QtGui4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
706 FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG NAMES QtGui_debug QtGuid4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
708 # Set QT_QTMOTIF_LIBRARY
710 FIND_LIBRARY(QT_QTMOTIF_LIBRARY_RELEASE NAMES QtMotif PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
711 FIND_LIBRARY(QT_QTMOTIF_LIBRARY_DEBUG NAMES QtMotif_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
714 # Set QT_QTNETWORK_LIBRARY
715 FIND_LIBRARY(QT_QTNETWORK_LIBRARY_RELEASE NAMES QtNetwork QtNetwork4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
716 FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG NAMES QtNetwork_debug QtNetworkd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
718 # Set QT_QTNSPLUGIN_LIBRARY
719 FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_RELEASE NAMES QtNsPlugin PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
720 FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_DEBUG NAMES QtNsPlugin_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
722 # Set QT_QTOPENGL_LIBRARY
723 FIND_LIBRARY(QT_QTOPENGL_LIBRARY_RELEASE NAMES QtOpenGL QtOpenGL4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
724 FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG NAMES QtOpenGL_debug QtOpenGLd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
726 # Set QT_QTSQL_LIBRARY
727 FIND_LIBRARY(QT_QTSQL_LIBRARY_RELEASE NAMES QtSql QtSql4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
728 FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG NAMES QtSql_debug QtSqld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
730 # Set QT_QTXML_LIBRARY
731 FIND_LIBRARY(QT_QTXML_LIBRARY_RELEASE NAMES QtXml QtXml4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
732 FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG NAMES QtXml_debug QtXmld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
734 # Set QT_QTSVG_LIBRARY
735 FIND_LIBRARY(QT_QTSVG_LIBRARY_RELEASE NAMES QtSvg QtSvg4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
736 FIND_LIBRARY(QT_QTSVG_LIBRARY_DEBUG NAMES QtSvg_debug QtSvgd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
738 # Set QT_QTUITOOLS_LIBRARY
739 FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools QtUiTools4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
740 FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_DEBUG NAMES QtUiTools_debug QtUiToolsd QtUiToolsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
741 # QtUiTools not with other frameworks with binary installation (in /usr/lib)
742 IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE)
743 FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools PATHS ${QT_LIBRARY_DIR})
744 ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE)
746 # Set QT_QTTEST_LIBRARY
747 FIND_LIBRARY(QT_QTTEST_LIBRARY_RELEASE NAMES QtTest QtTest4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
748 FIND_LIBRARY(QT_QTTEST_LIBRARY_DEBUG NAMES QtTest_debug QtTest_debug4 QtTestd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
750 # Set QT_QTDBUS_LIBRARY
751 # This was introduced with Qt 4.2, where also the naming scheme for debug libs was changed
752 # So does any of the debug lib names listed here actually exist ?
753 FIND_LIBRARY(QT_QTDBUS_LIBRARY_RELEASE NAMES QtDBus QtDBus4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
754 FIND_LIBRARY(QT_QTDBUS_LIBRARY_DEBUG NAMES QtDBus_debug QtDBus_debug4 QtDBusd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
756 # Set QT_QTSCRIPT_LIBRARY
757 FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_RELEASE NAMES QtScript QtScript4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
758 FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_DEBUG NAMES QtScript_debug QtScriptd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
760 IF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE )
761 IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
762 MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.")
763 ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
764 ENDIF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE )
766 # Set QT_QTASSISTANT_LIBRARY
767 FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient QtAssistantClient4 QtAssistant QtAssistant4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
768 FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistantClientd QtAssistantClientd4 QtAssistantClient_debug QtAssistant_debug QtAssistantd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
770 # Set QT_QTDESIGNER_LIBRARY
771 FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_RELEASE NAMES QtDesigner QtDesigner4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
772 FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_DEBUG NAMES QtDesigner_debug QtDesignerd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
774 # Set QT_QTDESIGNERCOMPONENTS_LIBRARY
775 FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents QtDesignerComponents4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
776 FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NAMES QtDesignerComponents_debug QtDesignerComponentsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
778 # Set QT_QTMAIN_LIBRARY
780 FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain PATHS ${QT_LIBRARY_DIR}
782 FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmaind PATHS ${QT_LIBRARY_DIR}
786 # Set QT_QTASSISTANTCLIENT_LIBRARY
787 FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NAMES QtAssistantClient QtAssistantClient4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
788 FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NAMES QtAssistantClient_debug QtAssistantClientd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
790 # Set QT_QTHELP_LIBRARY
791 FIND_LIBRARY(QT_QTHELP_LIBRARY_RELEASE NAMES QtHelp QtHelp4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
792 FIND_LIBRARY(QT_QTHELP_LIBRARY_DEBUG NAMES QtHelp_debug QtHelpd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
793 FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene QtCLucene4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
794 FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_DEBUG NAMES QtCLucene_debug QtCLucened4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
796 # Set QT_QTWEBKIT_LIBRARY
797 FIND_LIBRARY(QT_QTWEBKIT_LIBRARY_RELEASE NAMES QtWebKit QtWebKit4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
798 FIND_LIBRARY(QT_QTWEBKIT_LIBRARY_DEBUG NAMES QtWebKit_debug QtWebKitd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
800 # Set QT_QTXMLPATTERNS_LIBRARY
801 FIND_LIBRARY(QT_QTXMLPATTERNS_LIBRARY_RELEASE NAMES QtXmlPatterns QtXmlPatterns4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
802 FIND_LIBRARY(QT_QTXMLPATTERNS_LIBRARY_DEBUG NAMES QtXmlPatterns_debug QtXmlPatternsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
804 # Set QT_PHONON_LIBRARY
805 FIND_LIBRARY(QT_PHONON_LIBRARY_RELEASE NAMES phonon phonon4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
806 FIND_LIBRARY(QT_PHONON_LIBRARY_DEBUG NAMES phonon_debug phonond4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
808 ############################################
810 # Check the existence of the libraries.
812 ############################################
814 MACRO (_QT4_ADJUST_LIB_VARS basename)
815 IF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG)
817 # if only the release version was found, set the debug variable also to the release version
818 IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
819 SET(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE})
820 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE})
821 SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_RELEASE})
822 ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
824 # if only the debug version was found, set the release variable also to the debug version
825 IF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE)
826 SET(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG})
827 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG})
828 SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_DEBUG})
829 ENDIF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE)
831 IF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
832 # if the generator supports configuration types then set
833 # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
834 IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
835 SET(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
836 ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
837 # if there are no configuration types and CMAKE_BUILD_TYPE has no value
838 # then just use the release libraries
839 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE} )
840 ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
841 SET(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
842 ENDIF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
844 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE FILEPATH "The Qt ${basename} library")
846 IF (QT_${basename}_LIBRARY)
847 SET(QT_${basename}_FOUND 1)
848 ENDIF (QT_${basename}_LIBRARY)
850 ENDIF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG)
852 IF (QT_${basename}_INCLUDE_DIR)
853 #add the include directory to QT_INCLUDES
854 SET(QT_INCLUDES "${QT_${basename}_INCLUDE_DIR}" ${QT_INCLUDES})
855 ENDIF (QT_${basename}_INCLUDE_DIR)
857 # Make variables changeble to the advanced user
858 MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR)
859 ENDMACRO (_QT4_ADJUST_LIB_VARS)
862 # Set QT_xyz_LIBRARY variable and add
863 # library include path to QT_INCLUDES
864 _QT4_ADJUST_LIB_VARS(QTCORE)
865 _QT4_ADJUST_LIB_VARS(QTGUI)
866 _QT4_ADJUST_LIB_VARS(QT3SUPPORT)
867 _QT4_ADJUST_LIB_VARS(QTASSISTANT)
868 _QT4_ADJUST_LIB_VARS(QTDESIGNER)
869 _QT4_ADJUST_LIB_VARS(QTDESIGNERCOMPONENTS)
870 _QT4_ADJUST_LIB_VARS(QTNETWORK)
871 _QT4_ADJUST_LIB_VARS(QTNSPLUGIN)
872 _QT4_ADJUST_LIB_VARS(QTOPENGL)
873 _QT4_ADJUST_LIB_VARS(QTSQL)
874 _QT4_ADJUST_LIB_VARS(QTXML)
875 _QT4_ADJUST_LIB_VARS(QTSVG)
876 _QT4_ADJUST_LIB_VARS(QTSCRIPT)
877 _QT4_ADJUST_LIB_VARS(QTUITOOLS)
878 _QT4_ADJUST_LIB_VARS(QTTEST)
879 _QT4_ADJUST_LIB_VARS(QTDBUS)
880 _QT4_ADJUST_LIB_VARS(QTASSISTANTCLIENT)
881 _QT4_ADJUST_LIB_VARS(QTHELP)
882 _QT4_ADJUST_LIB_VARS(QTWEBKIT)
883 _QT4_ADJUST_LIB_VARS(QTXMLPATTERNS)
884 _QT4_ADJUST_LIB_VARS(PHONON)
885 _QT4_ADJUST_LIB_VARS(QTCLUCENE)
887 # platform dependent libraries
889 _QT4_ADJUST_LIB_VARS(QTMOTIF)
892 _QT4_ADJUST_LIB_VARS(QTMAIN)
896 #######################################
898 # Check the executables of Qt
901 #######################################
904 # find moc and uic using qmake
905 QT_QUERY_QMAKE(QT_MOC_EXECUTABLE_INTERNAL "QMAKE_MOC")
906 QT_QUERY_QMAKE(QT_UIC_EXECUTABLE_INTERNAL "QMAKE_UIC")
908 # make sure we have / and not \ as qmake gives on windows
910 "${QT_MOC_EXECUTABLE_INTERNAL}" QT_MOC_EXECUTABLE_INTERNAL)
911 # make sure we have / and not \ as qmake gives on windows
913 "${QT_UIC_EXECUTABLE_INTERNAL}" QT_UIC_EXECUTABLE_INTERNAL)
915 SET(QT_MOC_EXECUTABLE
916 ${QT_MOC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The moc executable")
917 SET(QT_UIC_EXECUTABLE
918 ${QT_UIC_EXECUTABLE_INTERNAL} CACHE FILEPATH "The uic executable")
920 FIND_PROGRAM(QT_UIC3_EXECUTABLE
922 PATHS ${QT_BINARY_DIR}
926 FIND_PROGRAM(QT_RCC_EXECUTABLE
928 PATHS ${QT_BINARY_DIR}
932 FIND_PROGRAM(QT_DBUSCPP2XML_EXECUTABLE
934 PATHS ${QT_BINARY_DIR}
938 FIND_PROGRAM(QT_DBUSXML2CPP_EXECUTABLE
940 PATHS ${QT_BINARY_DIR}
944 FIND_PROGRAM(QT_LUPDATE_EXECUTABLE
946 PATHS ${QT_BINARY_DIR}
950 FIND_PROGRAM(QT_LRELEASE_EXECUTABLE
952 PATHS ${QT_BINARY_DIR}
956 IF (QT_MOC_EXECUTABLE)
957 SET(QT_WRAP_CPP "YES")
958 ENDIF (QT_MOC_EXECUTABLE)
960 IF (QT_UIC_EXECUTABLE)
961 SET(QT_WRAP_UI "YES")
962 ENDIF (QT_UIC_EXECUTABLE)
966 MARK_AS_ADVANCED( QT_UIC_EXECUTABLE QT_UIC3_EXECUTABLE QT_MOC_EXECUTABLE
967 QT_RCC_EXECUTABLE QT_DBUSXML2CPP_EXECUTABLE QT_DBUSCPP2XML_EXECUTABLE
968 QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE)
970 ######################################
972 # Macros for building Qt files
974 ######################################
976 MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
979 SET(_QT4_DOING_OPTIONS FALSE)
980 FOREACH(_currentArg ${ARGN})
981 IF ("${_currentArg}" STREQUAL "OPTIONS")
982 SET(_QT4_DOING_OPTIONS TRUE)
983 ELSE ("${_currentArg}" STREQUAL "OPTIONS")
984 IF(_QT4_DOING_OPTIONS)
985 LIST(APPEND ${_qt4_options} "${_currentArg}")
986 ELSE(_QT4_DOING_OPTIONS)
987 LIST(APPEND ${_qt4_files} "${_currentArg}")
988 ENDIF(_QT4_DOING_OPTIONS)
989 ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
990 ENDFOREACH(_currentArg)
991 ENDMACRO (QT4_EXTRACT_OPTIONS)
993 # macro used to create the names of output files preserving relative dirs
994 MACRO (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile )
995 STRING(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
996 STRING(LENGTH ${infile} _infileLength)
997 SET(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
998 IF(_infileLength GREATER _binlength)
999 STRING(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
1000 ENDIF(_infileLength GREATER _binlength)
1001 IF(CMAKE_CURRENT_BINARY_DIR MATCHES "${_checkinfile}")
1002 FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
1003 ELSE(CMAKE_CURRENT_BINARY_DIR MATCHES "${_checkinfile}")
1004 FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
1005 ENDIF(CMAKE_CURRENT_BINARY_DIR MATCHES "${_checkinfile}")
1006 SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
1007 GET_FILENAME_COMPONENT(outpath ${_outfile} PATH)
1008 GET_FILENAME_COMPONENT(_outfile ${_outfile} NAME_WE)
1009 FILE(MAKE_DIRECTORY ${outpath})
1010 SET(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
1011 ENDMACRO (QT4_MAKE_OUTPUT_FILE )
1013 MACRO (QT4_GET_MOC_INC_DIRS _moc_INC_DIRS)
1014 SET(${_moc_INC_DIRS})
1015 GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES)
1017 FOREACH(_current ${_inc_DIRS})
1018 SET(${_moc_INC_DIRS} ${${_moc_INC_DIRS}} "-I" ${_current})
1019 ENDFOREACH(_current ${_inc_DIRS})
1021 ENDMACRO(QT4_GET_MOC_INC_DIRS)
1023 # helper macro to set up a moc rule
1024 MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_includes moc_options)
1025 # For Windows, create a parameters file to work around command line length limit
1027 # Pass the parameters in a file. Set the working directory to
1028 # be that containing the parameters file and reference it by
1029 # just the file name. This is necessary because the moc tool on
1030 # MinGW builds does not seem to handle spaces in the path to the
1031 # file given with the @ syntax.
1032 GET_FILENAME_COMPONENT(_moc_outfile_name "${outfile}" NAME)
1033 GET_FILENAME_COMPONENT(_moc_outfile_dir "${outfile}" PATH)
1034 IF(_moc_outfile_dir)
1035 SET(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir})
1036 ENDIF(_moc_outfile_dir)
1037 SET (_moc_parameters_file ${outfile}_parameters)
1038 SET (_moc_parameters ${moc_includes} ${moc_options} -o "${outfile}" "${infile}")
1039 FILE (REMOVE ${_moc_parameters_file})
1040 FOREACH(arg ${_moc_parameters})
1041 FILE (APPEND ${_moc_parameters_file} "${arg}\n")
1043 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1044 COMMAND ${QT_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters
1049 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1050 COMMAND ${QT_MOC_EXECUTABLE}
1051 ARGS ${moc_includes} ${moc_options} -o ${outfile} ${infile}
1054 ENDMACRO (QT4_CREATE_MOC_COMMAND)
1057 MACRO (QT4_GENERATE_MOC infile outfile )
1058 QT4_GET_MOC_INC_DIRS(moc_includes)
1059 GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE)
1060 QT4_CREATE_MOC_COMMAND(${abs_infile} ${outfile} "${moc_includes}" "")
1061 SET_SOURCE_FILES_PROPERTIES(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file
1062 ENDMACRO (QT4_GENERATE_MOC)
1065 # QT4_WRAP_CPP(outfiles inputfile ... )
1067 MACRO (QT4_WRAP_CPP outfiles )
1069 QT4_GET_MOC_INC_DIRS(moc_includes)
1070 QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN})
1072 FOREACH (it ${moc_files})
1073 GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
1074 QT4_MAKE_OUTPUT_FILE(${it} moc_ cxx outfile)
1075 QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_includes}" "${moc_options}")
1076 SET(${outfiles} ${${outfiles}} ${outfile})
1079 ENDMACRO (QT4_WRAP_CPP)
1082 # QT4_WRAP_UI(outfiles inputfile ... )
1084 MACRO (QT4_WRAP_UI outfiles )
1085 QT4_EXTRACT_OPTIONS(ui_files ui_options ${ARGN})
1087 FOREACH (it ${ui_files})
1088 GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
1089 GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
1090 SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
1091 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1092 COMMAND ${QT_UIC_EXECUTABLE}
1093 ARGS ${ui_options} -o ${outfile} ${infile}
1094 MAIN_DEPENDENCY ${infile})
1095 SET(${outfiles} ${${outfiles}} ${outfile})
1098 ENDMACRO (QT4_WRAP_UI)
1101 # QT4_ADD_RESOURCES(outfiles inputfile ... )
1103 MACRO (QT4_ADD_RESOURCES outfiles )
1104 QT4_EXTRACT_OPTIONS(rcc_files rcc_options ${ARGN})
1106 FOREACH (it ${rcc_files})
1107 GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
1108 GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
1109 GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
1110 SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
1111 # parse file for dependencies
1112 # all files are absolute paths or relative to the location of the qrc file
1113 FILE(READ "${infile}" _RC_FILE_CONTENTS)
1114 STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
1116 FOREACH(_RC_FILE ${_RC_FILES})
1117 STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
1118 STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}")
1119 IF(NOT _ABS_PATH_INDICATOR)
1120 SET(_RC_FILE "${rc_path}/${_RC_FILE}")
1121 ENDIF(NOT _ABS_PATH_INDICATOR)
1122 SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
1123 ENDFOREACH(_RC_FILE)
1124 ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
1125 COMMAND ${QT_RCC_EXECUTABLE}
1126 ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
1127 MAIN_DEPENDENCY ${infile}
1128 DEPENDS ${_RC_DEPENDS})
1129 SET(${outfiles} ${${outfiles}} ${outfile})
1132 ENDMACRO (QT4_ADD_RESOURCES)
1134 MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename)
1135 GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE)
1136 SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
1137 SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
1138 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
1140 ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1141 COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -p ${_basename} ${_infile}
1144 SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
1146 QT4_GENERATE_MOC(${_header} ${_moc})
1148 SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
1149 MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
1151 ENDMACRO(QT4_ADD_DBUS_INTERFACE)
1154 MACRO(QT4_ADD_DBUS_INTERFACES _sources)
1155 FOREACH (_current_FILE ${ARGN})
1156 GET_FILENAME_COMPONENT(_infile ${_current_FILE} ABSOLUTE)
1157 # get the part before the ".xml" suffix
1158 STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2" _basename ${_current_FILE})
1159 STRING(TOLOWER ${_basename} _basename)
1160 QT4_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface)
1161 ENDFOREACH (_current_FILE)
1162 ENDMACRO(QT4_ADD_DBUS_INTERFACES)
1165 MACRO(QT4_GENERATE_DBUS_INTERFACE _header) # _customName )
1166 SET(_customName "${ARGV1}")
1167 GET_FILENAME_COMPONENT(_in_file ${_header} ABSOLUTE)
1168 GET_FILENAME_COMPONENT(_basename ${_header} NAME_WE)
1171 SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName})
1173 SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml)
1176 ADD_CUSTOM_COMMAND(OUTPUT ${_target}
1177 COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_in_file} > ${_target}
1180 ENDMACRO(QT4_GENERATE_DBUS_INTERFACE)
1183 MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename )
1184 GET_FILENAME_COMPONENT(_infile ${_xml_file} ABSOLUTE)
1186 SET(_optionalBasename "${ARGV4}")
1187 IF (_optionalBasename)
1188 SET(_basename ${_optionalBasename} )
1189 ELSE (_optionalBasename)
1190 STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile})
1191 STRING(TOLOWER ${_basename} _basename)
1192 ENDIF (_optionalBasename)
1194 SET(_optionalClassName "${ARGV5}")
1195 SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
1196 SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
1197 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
1199 IF(_optionalClassName)
1200 ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1201 COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
1204 ELSE(_optionalClassName)
1205 ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
1206 COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
1209 ENDIF(_optionalClassName)
1211 QT4_GENERATE_MOC(${_header} ${_moc})
1212 SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
1213 MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
1215 SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
1216 ENDMACRO(QT4_ADD_DBUS_ADAPTOR)
1219 QT4_GET_MOC_INC_DIRS(_moc_INCS)
1221 SET(_matching_FILES )
1222 FOREACH (_current_FILE ${ARGN})
1224 GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
1225 # if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
1226 # This is required to make uic work correctly:
1227 # we need to add generated .cpp files to the sources (to compile them),
1228 # but we cannot let automoc handle them, as the .cpp files don't exist yet when
1229 # cmake is run for the very first time on them -> however the .cpp files might
1230 # exist at a later run. at that time we need to skip them, so that we don't add two
1231 # different rules for the same moc file
1232 GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC)
1234 IF ( NOT _skip AND EXISTS ${_abs_FILE} )
1236 FILE(READ ${_abs_FILE} _contents)
1238 GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH)
1240 STRING(REGEX MATCHALL "#include +[^ ]+\\.moc[\">]" _match "${_contents}")
1242 FOREACH (_current_MOC_INC ${_match})
1243 STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
1244 GET_FILENAME_COMPONENT(_basename ${_current_MOC} NAME_WE)
1245 SET(_header ${_abs_PATH}/${_basename}.h)
1246 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
1247 QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${_moc_INCS}" "")
1248 MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
1249 ENDFOREACH (_current_MOC_INC)
1251 ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} )
1252 ENDFOREACH (_current_FILE)
1253 ENDMACRO(QT4_AUTOMOC)
1255 MACRO(QT4_CREATE_TRANSLATION _qm_files)
1258 FOREACH (_file ${ARGN})
1259 GET_FILENAME_COMPONENT(_ext ${_file} EXT)
1260 GET_FILENAME_COMPONENT(_abs_FILE ${_file} ABSOLUTE)
1261 IF(_ext MATCHES "ts")
1262 LIST(APPEND _my_tsfiles ${_abs_FILE})
1263 ELSE(_ext MATCHES "ts")
1264 LIST(APPEND _my_sources ${_abs_FILE})
1265 ENDIF(_ext MATCHES "ts")
1267 FOREACH(_ts_file ${_my_tsfiles})
1268 ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file}
1269 COMMAND ${QT_LUPDATE_EXECUTABLE}
1270 ARGS ${_my_sources} -ts ${_ts_file}
1271 DEPENDS ${_my_sources})
1272 ENDFOREACH(_ts_file)
1273 QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles})
1274 ENDMACRO(QT4_CREATE_TRANSLATION)
1276 MACRO(QT4_ADD_TRANSLATION _qm_files)
1277 FOREACH (_current_FILE ${ARGN})
1278 GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
1279 GET_FILENAME_COMPONENT(qm ${_abs_FILE} NAME_WE)
1280 SET(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm")
1282 ADD_CUSTOM_COMMAND(OUTPUT ${qm}
1283 COMMAND ${QT_LRELEASE_EXECUTABLE}
1284 ARGS ${_abs_FILE} -qm ${qm}
1285 DEPENDS ${_abs_FILE}
1287 SET(${_qm_files} ${${_qm_files}} ${qm})
1288 ENDFOREACH (_current_FILE)
1289 ENDMACRO(QT4_ADD_TRANSLATION)
1295 ######################################
1297 # decide if Qt got found
1299 ######################################
1301 # if the includes,libraries,moc,uic and rcc are found then we have it
1302 IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1303 SET( QT4_FOUND "YES" )
1304 INCLUDE(FindPackageMessage)
1305 FIND_PACKAGE_MESSAGE(Qt4 "Found Qt-Version ${QTVERSION}"
1306 "[${QT_LIBRARY_DIR}][${QT_INCLUDE_DIR}][${QT_MOC_EXECUTABLE}][${QT_UIC_EXECUTABLE}][${QT_RCC_EXECUTABLE}]")
1307 ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1308 SET( QT4_FOUND "NO")
1309 SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1310 IF( Qt4_FIND_REQUIRED)
1311 MESSAGE( FATAL_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!")
1312 ENDIF( Qt4_FIND_REQUIRED)
1313 ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
1314 SET(QT_FOUND ${QT4_FOUND})
1317 #######################################
1321 #######################################
1322 IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
1323 FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents)
1324 STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG ${_qconfig_FILE_contents})
1325 STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG ${_qconfig_FILE_contents})
1326 STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION ${_qconfig_FILE_contents})
1327 ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
1328 IF("${QT_EDITION}" MATCHES "DesktopLight")
1329 SET(QT_EDITION_DESKTOPLIGHT 1)
1330 ENDIF("${QT_EDITION}" MATCHES "DesktopLight")
1333 ###############################################
1335 # configuration/system dependent settings
1337 ###############################################
1339 SET(QT_QTGUI_LIB_DEPENDENCIES "")
1340 SET(QT_QTCORE_LIB_DEPENDENCIES "")
1341 SET(QT_QTNETWORK_LIB_DEPENDENCIES "")
1342 SET(QT_QTOPENGL_LIB_DEPENDENCIES "")
1343 SET(QT_QTDBUS_LIB_DEPENDENCIES "")
1344 SET(QT_QTHELP_LIB_DEPENDENCIES ${QT_QTCLUCENE_LIBRARY})
1346 # build using shared Qt needs -DQT_DLL
1347 IF(NOT QT_CONFIG MATCHES "static")
1348 # warning currently only qconfig.pri on Windows potentially contains "static"
1349 # so QT_DLL might not get defined properly on other platforms.
1350 SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_DLL)
1351 ENDIF(NOT QT_CONFIG MATCHES "static")
1353 # QtOpenGL dependencies
1354 QT_QUERY_QMAKE(QMAKE_LIBS_OPENGL "QMAKE_LIBS_OPENGL")
1355 SET (QT_QTOPENGL_LIB_DEPENDENCIES ${QT_QTOPENGL_LIB_DEPENDENCIES} ${QMAKE_LIBS_OPENGL})
1358 IF(QT_QCONFIG MATCHES "system-png")
1359 FIND_LIBRARY(QT_PNG_LIBRARY NAMES png)
1360 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY})
1361 MARK_AS_ADVANCED(QT_PNG_LIBRARY)
1362 ENDIF(QT_QCONFIG MATCHES "system-png")
1364 # for X11, get X11 library directory
1366 QT_QUERY_QMAKE(QMAKE_LIBDIR_X11 "QMAKE_LIBDIR_X11")
1370 IF(QT_QCONFIG MATCHES "x11sm")
1371 # ask qmake where the x11 libs are
1372 FIND_LIBRARY(QT_X11_SM_LIBRARY NAMES SM PATHS ${QMAKE_LIBDIR_X11})
1373 FIND_LIBRARY(QT_X11_ICE_LIBRARY NAMES ICE PATHS ${QMAKE_LIBDIR_X11})
1374 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_X11_SM_LIBRARY} ${QT_X11_ICE_LIBRARY})
1375 MARK_AS_ADVANCED(QT_X11_SM_LIBRARY)
1376 MARK_AS_ADVANCED(QT_X11_ICE_LIBRARY)
1377 ENDIF(QT_QCONFIG MATCHES "x11sm")
1380 IF(QT_QCONFIG MATCHES "tablet")
1381 FIND_LIBRARY(QT_XI_LIBRARY NAMES Xi PATHS ${QMAKE_LIBDIR_X11})
1382 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XI_LIBRARY})
1383 MARK_AS_ADVANCED(QT_XI_LIBRARY)
1384 ENDIF(QT_QCONFIG MATCHES "tablet")
1387 IF(QT_QCONFIG MATCHES "xrender")
1388 FIND_LIBRARY(QT_XRENDER_LIBRARY NAMES Xrender PATHS ${QMAKE_LIBDIR_X11})
1389 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRENDER_LIBRARY})
1390 MARK_AS_ADVANCED(QT_XRENDER_LIBRARY)
1391 ENDIF(QT_QCONFIG MATCHES "xrender")
1394 IF(QT_QCONFIG MATCHES "xrandr")
1395 FIND_LIBRARY(QT_XRANDR_LIBRARY NAMES Xrandr PATHS ${QMAKE_LIBDIR_X11})
1396 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRANDR_LIBRARY})
1397 MARK_AS_ADVANCED(QT_XRANDR_LIBRARY)
1398 ENDIF(QT_QCONFIG MATCHES "xrandr")
1401 IF(QT_QCONFIG MATCHES "xcursor")
1402 FIND_LIBRARY(QT_XCURSOR_LIBRARY NAMES Xcursor PATHS ${QMAKE_LIBDIR_X11})
1403 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XCURSOR_LIBRARY})
1404 MARK_AS_ADVANCED(QT_XCURSOR_LIBRARY)
1405 ENDIF(QT_QCONFIG MATCHES "xcursor")
1408 IF(QT_QCONFIG MATCHES "xinerama")
1409 FIND_LIBRARY(QT_XINERAMA_LIBRARY NAMES Xinerama PATHS ${QMAKE_LIBDIR_X11})
1410 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XINERAMA_LIBRARY})
1411 MARK_AS_ADVANCED(QT_XINERAMA_LIBRARY)
1412 ENDIF(QT_QCONFIG MATCHES "xinerama")
1415 IF(QT_QCONFIG MATCHES "xfixes")
1416 FIND_LIBRARY(QT_XFIXES_LIBRARY NAMES Xfixes PATHS ${QMAKE_LIBDIR_X11})
1417 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XFIXES_LIBRARY})
1418 MARK_AS_ADVANCED(QT_XFIXES_LIBRARY)
1419 ENDIF(QT_QCONFIG MATCHES "xfixes")
1422 IF(QT_QCONFIG MATCHES "system-freetype")
1423 FIND_LIBRARY(QT_FREETYPE_LIBRARY NAMES freetype)
1424 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY})
1425 MARK_AS_ADVANCED(QT_FREETYPE_LIBRARY)
1426 ENDIF(QT_QCONFIG MATCHES "system-freetype")
1429 IF(QT_QCONFIG MATCHES "fontconfig")
1430 FIND_LIBRARY(QT_FONTCONFIG_LIBRARY NAMES fontconfig)
1431 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY})
1432 MARK_AS_ADVANCED(QT_FONTCONFIG_LIBRARY)
1433 ENDIF(QT_QCONFIG MATCHES "fontconfig")
1436 IF(QT_QCONFIG MATCHES "system-zlib")
1437 FIND_LIBRARY(QT_ZLIB_LIBRARY NAMES z)
1438 SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY})
1439 MARK_AS_ADVANCED(QT_ZLIB_LIBRARY)
1440 ENDIF(QT_QCONFIG MATCHES "system-zlib")
1443 IF(QT_QCONFIG MATCHES "openssl" AND NOT Q_WS_WIN)
1444 FIND_PACKAGE(OpenSSL)
1445 SET(QT_QTNETWORK_LIB_DEPENDENCIES ${QT_QTNETWORK_LIB_DEPENDENCIES} ${OPENSSL_LIBRARIES})
1446 ENDIF(QT_QCONFIG MATCHES "openssl" AND NOT Q_WS_WIN)
1449 IF(QT_QCONFIG MATCHES "qdbus")
1451 # if the dbus library isn't found, we'll assume its not required to build
1452 # shared Qt on Linux doesn't require it
1453 IF(NOT QT_DBUS_LIBRARY)
1454 EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L dbus-1
1455 OUTPUT_VARIABLE _dbus_query_output
1456 RESULT_VARIABLE _dbus_result
1457 ERROR_VARIABLE _dbus_query_output )
1459 IF(_dbus_result MATCHES 0)
1460 STRING(REPLACE "-L" "" _dbus_query_output "${_dbus_query_output}")
1461 SEPARATE_ARGUMENTS(_dbus_query_output)
1462 ELSE(_dbus_result MATCHES 0)
1463 SET(_dbus_query_output)
1464 ENDIF(_dbus_result MATCHES 0)
1466 FIND_LIBRARY(QT_DBUS_LIBRARY NAMES dbus-1 PATHS ${_dbus_query_output} )
1469 SET(QT_QTDBUS_LIB_DEPENDENCIES ${QT_QTDBUS_LIB_DEPENDENCIES} ${QT_DBUS_LIBRARY})
1470 ENDIF(QT_DBUS_LIBRARY)
1472 MARK_AS_ADVANCED(QT_DBUS_LIBRARY)
1473 ENDIF(NOT QT_DBUS_LIBRARY)
1475 ENDIF(QT_QCONFIG MATCHES "qdbus")
1478 IF(QT_QCONFIG MATCHES "glib")
1480 # if the glib libraries aren't found, we'll assume its not required to build
1481 # shared Qt on Linux doesn't require it
1483 # Qt 4.2.0+ uses glib-2.0
1484 IF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY)
1485 EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L glib-2.0 gthread-2.0
1486 OUTPUT_VARIABLE _glib_query_output
1487 RESULT_VARIABLE _glib_result
1488 ERROR_VARIABLE _glib_query_output )
1490 IF(_glib_result MATCHES 0)
1491 STRING(REPLACE "-L" "" _glib_query_output "${_glib_query_output}")
1492 SEPARATE_ARGUMENTS(_glib_query_output)
1493 ELSE(_glib_result MATCHES 0)
1494 SET(_glib_query_output)
1495 ENDIF(_glib_result MATCHES 0)
1497 FIND_LIBRARY(QT_GLIB_LIBRARY NAMES glib-2.0 PATHS ${_glib_query_output} )
1498 FIND_LIBRARY(QT_GTHREAD_LIBRARY NAMES gthread-2.0 PATHS ${_glib_query_output} )
1500 IF(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY)
1501 SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES}
1502 ${QT_GTHREAD_LIBRARY} ${QT_GLIB_LIBRARY})
1503 ENDIF(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY)
1505 MARK_AS_ADVANCED(QT_GLIB_LIBRARY)
1506 MARK_AS_ADVANCED(QT_GTHREAD_LIBRARY)
1507 ENDIF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY)
1508 ENDIF(QT_QCONFIG MATCHES "glib")
1510 ## clock-monotonic, just see if we need to link with rt
1511 IF(QT_QCONFIG MATCHES "clock-monotonic")
1512 SET(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
1513 SET(CMAKE_REQUIRED_LIBRARIES rt)
1514 CHECK_SYMBOL_EXISTS(_POSIX_TIMERS "unistd.h;time.h" QT_POSIX_TIMERS)
1515 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
1517 FIND_LIBRARY(QT_RT_LIBRARY NAMES rt)
1518 SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_RT_LIBRARY})
1519 MARK_AS_ADVANCED(QT_RT_LIBRARY)
1520 ENDIF(QT_POSIX_TIMERS)
1521 ENDIF(QT_QCONFIG MATCHES "clock-monotonic")
1524 # X11 libraries Qt absolutely depends on
1525 QT_QUERY_QMAKE(QT_LIBS_X11 "QMAKE_LIBS_X11")
1526 SEPARATE_ARGUMENTS(QT_LIBS_X11)
1527 FOREACH(QT_X11_LIB ${QT_LIBS_X11})
1528 STRING(REGEX REPLACE "-l" "" QT_X11_LIB "${QT_X11_LIB}")
1529 SET(QT_TMP_STR "QT_X11_${QT_X11_LIB}_LIBRARY")
1530 FIND_LIBRARY(${QT_TMP_STR} NAMES "${QT_X11_LIB}" PATHS ${QMAKE_LIBDIR_X11})
1531 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${${QT_TMP_STR}})
1532 MARK_AS_ADVANCED(${QT_TMP_STR})
1533 ENDFOREACH(QT_X11_LIB)
1535 QT_QUERY_QMAKE(QT_LIBS_THREAD "QMAKE_LIBS_THREAD")
1536 SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_LIBS_THREAD})
1538 QT_QUERY_QMAKE(QMAKE_LIBS_DYNLOAD "QMAKE_LIBS_DYNLOAD")
1539 SET (QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QMAKE_LIBS_DYNLOAD})
1544 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} imm32 winmm)
1545 SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ws2_32)
1549 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework Carbon")
1551 # Qt 4.0, 4.1, 4.2 use QuickTime
1552 IF(QT_VERSION_MINOR LESS 3)
1553 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework QuickTime")
1554 ENDIF(QT_VERSION_MINOR LESS 3)
1556 # Qt 4.2+ use AppKit
1557 IF(QT_VERSION_MINOR GREATER 1)
1558 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework AppKit")
1559 ENDIF(QT_VERSION_MINOR GREATER 1)
1561 SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} "-framework ApplicationServices")
1564 #######################################
1566 # compatibility settings
1568 #######################################
1569 # Backwards compatibility for CMake1.4 and 1.2
1570 SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} )
1571 SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} )
1573 SET( QT_QT_LIBRARY "")
1575 ELSE(QT4_QMAKE_FOUND)
1577 SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1578 IF(Qt4_FIND_REQUIRED)
1579 IF(QT4_INSTALLED_VERSION_TOO_OLD)
1580 MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1581 ELSE(QT4_INSTALLED_VERSION_TOO_OLD)
1582 MESSAGE( FATAL_ERROR "Qt qmake not found!")
1583 ENDIF(QT4_INSTALLED_VERSION_TOO_OLD)
1584 ELSE(Qt4_FIND_REQUIRED)
1585 IF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1586 MESSAGE(STATUS "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1587 ENDIF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1588 ENDIF(Qt4_FIND_REQUIRED)
1590 ENDIF (QT4_QMAKE_FOUND)