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 # The variable QT_USE_FILE is set which is the path to a CMake file that can be included
7 # to compile Qt 4 applications and libraries. It sets up the compilation
8 # environment for include directories, preprocessor defines and populates a
9 # QT_LIBRARIES variable.
11 # Typical usage could be something like:
12 # find_package(Qt4 4.4.3 COMPONENTS QtCore QtGui QtXml REQUIRED )
13 # include(${QT_USE_FILE})
14 # add_executable(myexe main.cpp)
15 # target_link_libraries(myexe ${QT_LIBRARIES})
17 # When using the components argument, QT_USE_QT* variables are automatically set
18 # for the QT_USE_FILE to pick up. If one wishes to manually set them, the
19 # available ones to set include:
39 # QT_USE_QTASSISTANTCLIENT
42 # QT_USE_QTXMLPATTERNS
44 # QT_USE_QTSCRIPTTOOLS
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. Per-direcotry preprocessor definitions
52 # are also added. Options may be given to moc, such as those found
53 # when executing "moc -help".
55 # macro QT4_WRAP_UI(outfiles inputfile ... OPTIONS ...)
56 # create code from a list of Qt designer ui files.
57 # Options may be given to uic, such as those found
58 # when executing "uic -help"
60 # macro QT4_ADD_RESOURCES(outfiles inputfile ... OPTIONS ...)
61 # create code from a list of Qt resource files.
62 # Options may be given to rcc, such as those found
63 # when executing "rcc -help"
65 # macro QT4_GENERATE_MOC(inputfile outputfile )
66 # creates a rule to run moc on infile and create outfile.
67 # Use this if for some reason QT4_WRAP_CPP() isn't appropriate, e.g.
68 # because you need a custom filename for the moc file or something similar.
70 # macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... )
71 # This macro is still experimental.
72 # It can be used to have moc automatically handled.
73 # So if you have the files foo.h and foo.cpp, and in foo.h a
74 # a class uses the Q_OBJECT macro, moc has to run on it. If you don't
75 # want to use QT4_WRAP_CPP() (which is reliable and mature), you can insert
77 # in foo.cpp and then give foo.cpp as argument to QT4_AUTOMOC(). This will the
78 # scan all listed files at cmake-time for such included moc files and if it finds
79 # them cause a rule to be generated to run moc at build time on the
80 # accompanying header file foo.h.
81 # If a source file has the SKIP_AUTOMOC property set it will be ignored by this macro.
83 # macro QT4_ADD_DBUS_INTERFACE(outfiles interface basename)
84 # create a the interface header and implementation files with the
85 # given basename from the given interface xml file and add it to
88 # macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... )
89 # create the interface header and implementation files
90 # for all listed interface xml files
91 # the name will be automatically determined from the name of the xml file
93 # macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname [basename] )
94 # create a dbus adaptor (header and implementation file) from the xml file
95 # describing the interface, and add it to the list of sources. The adaptor
96 # forwards the calls to a parent class, defined in parentheader and named
97 # parentclassname. The name of the generated files will be
98 # <basename>adaptor.{cpp,h} where basename is the basename of the xml file.
100 # macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] )
101 # generate the xml interface file from the given header.
102 # If the optional argument interfacename is omitted, the name of the
103 # interface file is constructed from the basename of the header with
104 # the suffix .xml appended.
106 # macro QT4_CREATE_TRANSLATION( qm_files directories ... sources ...
107 # ts_files ... OPTIONS ...)
109 # in: directories sources ts_files
110 # options: flags to pass to lupdate, such as -extensions to specify
111 # extensions for a directory scan.
112 # generates commands to create .ts (vie lupdate) and .qm
113 # (via lrelease) - files from directories and/or sources. The ts files are
114 # created and/or updated in the source tree (unless given with full paths).
115 # The qm files are generated in the build tree.
116 # Updating the translations can be done by adding the qm_files
117 # to the source list of your library/executable, so they are
118 # always updated, or by adding a custom target to control when
119 # they get updated/generated.
121 # macro QT4_ADD_TRANSLATION( qm_files ts_files ... )
124 # generates commands to create .qm from .ts - files. The generated
125 # filenames can be found in qm_files. The ts_files
126 # must exists and are not updated in any way.
129 # Below is a detailed list of variables that FindQt4.cmake sets.
130 # QT_FOUND If false, don't try to use Qt.
131 # QT4_FOUND If false, don't try to use Qt 4.
133 # QT_VERSION_MAJOR The major version of Qt found.
134 # QT_VERSION_MINOR The minor version of Qt found.
135 # QT_VERSION_PATCH The patch version of Qt found.
137 # QT_EDITION Set to the edition of Qt (i.e. DesktopLight)
138 # QT_EDITION_DESKTOPLIGHT True if QT_EDITION == DesktopLight
139 # QT_QTCORE_FOUND True if QtCore was found.
140 # QT_QTGUI_FOUND True if QtGui was found.
141 # QT_QT3SUPPORT_FOUND True if Qt3Support was found.
142 # QT_QTASSISTANT_FOUND True if QtAssistant was found.
143 # QT_QAXCONTAINER_FOUND True if QAxContainer was found (Windows only).
144 # QT_QAXSERVER_FOUND True if QAxServer was found (Windows only).
145 # QT_QTDBUS_FOUND True if QtDBus was found.
146 # QT_QTDESIGNER_FOUND True if QtDesigner was found.
147 # QT_QTDESIGNERCOMPONENTS True if QtDesignerComponents was found.
148 # QT_QTMOTIF_FOUND True if QtMotif was found.
149 # QT_QTNETWORK_FOUND True if QtNetwork was found.
150 # QT_QTNSPLUGIN_FOUND True if QtNsPlugin was found.
151 # QT_QTOPENGL_FOUND True if QtOpenGL was found.
152 # QT_QTSQL_FOUND True if QtSql was found.
153 # QT_QTXML_FOUND True if QtXml was found.
154 # QT_QTSVG_FOUND True if QtSvg was found.
155 # QT_QTSCRIPT_FOUND True if QtScript was found.
156 # QT_QTTEST_FOUND True if QtTest was found.
157 # QT_QTUITOOLS_FOUND True if QtUiTools was found.
158 # QT_QTASSISTANTCLIENT_FOUND True if QtAssistantClient was found.
159 # QT_QTHELP_FOUND True if QtHelp was found.
160 # QT_QTWEBKIT_FOUND True if QtWebKit was found.
161 # QT_QTXMLPATTERNS_FOUND True if QtXmlPatterns was found.
162 # QT_PHONON_FOUND True if phonon was found.
163 # QT_QTSCRIPTTOOLS_FOUND True if QtScriptTools was found.
166 # QT_DEFINITIONS Definitions to use when compiling code that uses Qt.
167 # You do not need to use this if you include QT_USE_FILE.
168 # The QT_USE_FILE will also define QT_DEBUG and QT_NO_DEBUG
169 # to fit your current build type. Those are not contained
172 # QT_INCLUDES List of paths to all include directories of
173 # Qt4 QT_INCLUDE_DIR and QT_QTCORE_INCLUDE_DIR are
174 # always in this variable even if NOTFOUND,
175 # all other INCLUDE_DIRS are
176 # only added if they are found.
177 # You do not need to use this if you include QT_USE_FILE.
180 # Include directories for the Qt modules are listed here.
181 # You do not need to use these variables if you include QT_USE_FILE.
183 # QT_INCLUDE_DIR Path to "include" of Qt4
184 # QT_QT3SUPPORT_INCLUDE_DIR Path to "include/Qt3Support"
185 # QT_QTASSISTANT_INCLUDE_DIR Path to "include/QtAssistant"
186 # QT_QAXCONTAINER_INCLUDE_DIR Path to "include/ActiveQt" (Windows only)
187 # QT_QAXSERVER_INCLUDE_DIR Path to "include/ActiveQt" (Windows only)
188 # QT_QTCORE_INCLUDE_DIR Path to "include/QtCore"
189 # QT_QTDESIGNER_INCLUDE_DIR Path to "include/QtDesigner"
190 # QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR Path to "include/QtDesigner"
191 # QT_QTDBUS_INCLUDE_DIR Path to "include/QtDBus"
192 # QT_QTGUI_INCLUDE_DIR Path to "include/QtGui"
193 # QT_QTMOTIF_INCLUDE_DIR Path to "include/QtMotif"
194 # QT_QTNETWORK_INCLUDE_DIR Path to "include/QtNetwork"
195 # QT_QTNSPLUGIN_INCLUDE_DIR Path to "include/QtNsPlugin"
196 # QT_QTOPENGL_INCLUDE_DIR Path to "include/QtOpenGL"
197 # QT_QTSQL_INCLUDE_DIR Path to "include/QtSql"
198 # QT_QTXML_INCLUDE_DIR Path to "include/QtXml"
199 # QT_QTSVG_INCLUDE_DIR Path to "include/QtSvg"
200 # QT_QTSCRIPT_INCLUDE_DIR Path to "include/QtScript"
201 # QT_QTTEST_INCLUDE_DIR Path to "include/QtTest"
202 # QT_QTASSISTANTCLIENT_INCLUDE_DIR Path to "include/QtAssistant"
203 # QT_QTHELP_INCLUDE_DIR Path to "include/QtHelp"
204 # QT_QTWEBKIT_INCLUDE_DIR Path to "include/QtWebKit"
205 # QT_QTXMLPATTERNS_INCLUDE_DIR Path to "include/QtXmlPatterns"
206 # QT_PHONON_INCLUDE_DIR Path to "include/phonon"
207 # QT_QTSCRIPTTOOLS_INCLUDE_DIR Path to "include/QtScriptTools"
209 # QT_BINARY_DIR Path to "bin" of Qt4
210 # QT_LIBRARY_DIR Path to "lib" of Qt4
211 # QT_PLUGINS_DIR Path to "plugins" for Qt4
212 # QT_TRANSLATIONS_DIR Path to "translations" of Qt4
213 # QT_DOC_DIR Path to "doc" of Qt4
214 # QT_MKSPECS_DIR Path to "mkspecs" of Qt4
217 # The Qt toolkit may contain both debug and release libraries.
218 # In that case, the following library variables will contain both.
219 # You do not need to use these variables if you include QT_USE_FILE,
220 # and use QT_LIBRARIES.
222 # QT_QT3SUPPORT_LIBRARY The Qt3Support library
223 # QT_QTASSISTANT_LIBRARY The QtAssistant library
224 # QT_QAXCONTAINER_LIBRARY The QAxContainer library (Windows only)
225 # QT_QAXSERVER_LIBRARY The QAxServer library (Windows only)
226 # QT_QTCORE_LIBRARY The QtCore library
227 # QT_QTDBUS_LIBRARY The QtDBus library
228 # QT_QTDESIGNER_LIBRARY The QtDesigner library
229 # QT_QTDESIGNERCOMPONENTS_LIBRARY The QtDesignerComponents library
230 # QT_QTGUI_LIBRARY The QtGui library
231 # QT_QTMOTIF_LIBRARY The QtMotif library
232 # QT_QTNETWORK_LIBRARY The QtNetwork library
233 # QT_QTNSPLUGIN_LIBRARY The QtNsPLugin library
234 # QT_QTOPENGL_LIBRARY The QtOpenGL library
235 # QT_QTSQL_LIBRARY The QtSql library
236 # QT_QTXML_LIBRARY The QtXml library
237 # QT_QTSVG_LIBRARY The QtSvg library
238 # QT_QTSCRIPT_LIBRARY The QtScript library
239 # QT_QTTEST_LIBRARY The QtTest library
240 # QT_QTMAIN_LIBRARY The qtmain library for Windows
241 # QT_QTUITOOLS_LIBRARY The QtUiTools library
242 # QT_QTASSISTANTCLIENT_LIBRARY The QtAssistantClient library
243 # QT_QTHELP_LIBRARY The QtHelp library
244 # QT_QTWEBKIT_LIBRARY The QtWebKit library
245 # QT_QTXMLPATTERNS_LIBRARY The QtXmlPatterns library
246 # QT_PHONON_LIBRARY The phonon library
247 # QT_QTSCRIPTTOOLS_LIBRARY The QtScriptTools library
249 # also defined, but NOT for general use are
250 # QT_MOC_EXECUTABLE Where to find the moc tool.
251 # QT_UIC_EXECUTABLE Where to find the uic tool.
252 # QT_UIC3_EXECUTABLE Where to find the uic3 tool.
253 # QT_RCC_EXECUTABLE Where to find the rcc tool
254 # QT_DBUSCPP2XML_EXECUTABLE Where to find the qdbuscpp2xml tool.
255 # QT_DBUSXML2CPP_EXECUTABLE Where to find the qdbusxml2cpp tool.
256 # QT_LUPDATE_EXECUTABLE Where to find the lupdate tool.
257 # QT_LRELEASE_EXECUTABLE Where to find the lrelease tool.
258 # QT_QCOLLECTIONGENERATOR_EXECUTABLE Where to find the qcollectiongenerator tool.
261 # These are around for backwards compatibility
263 # QT_WRAP_CPP Set true if QT_MOC_EXECUTABLE is found
264 # QT_WRAP_UI Set true if QT_UIC_EXECUTABLE is found
266 # These variables do _NOT_ have any effect anymore (compared to FindQt.cmake)
267 # QT_MT_REQUIRED Qt4 is now always multithreaded
269 # These variables are set to "" Because Qt structure changed
270 # (They make no sense in Qt4)
271 # QT_QT_LIBRARY Qt-Library is now split
274 # Use FIND_PACKAGE( Qt4 COMPONENTS ... ) to enable modules
275 IF( Qt4_FIND_COMPONENTS )
276 FOREACH( component ${Qt4_FIND_COMPONENTS} )
277 STRING( TOUPPER ${component} _COMPONENT )
278 SET( QT_USE_${_COMPONENT} 1 )
279 ENDFOREACH( component )
281 # To make sure we don't use QtCore or QtGui when not in COMPONENTS
282 IF(NOT QT_USE_QTCORE)
283 SET( QT_DONT_USE_QTCORE 1 )
284 ENDIF(NOT QT_USE_QTCORE)
287 SET( QT_DONT_USE_QTGUI 1 )
288 ENDIF(NOT QT_USE_QTGUI)
290 ENDIF( Qt4_FIND_COMPONENTS )
292 # If Qt3 has already been found, fail.
294 IF(Qt4_FIND_REQUIRED)
295 MESSAGE( FATAL_ERROR "Qt3 and Qt4 cannot be used together in one project. If switching to Qt4, the CMakeCache.txt needs to be cleaned.")
296 ELSE(Qt4_FIND_REQUIRED)
297 IF(NOT Qt4_FIND_QUIETLY)
298 MESSAGE( STATUS "Qt3 and Qt4 cannot be used together in one project. If switching to Qt4, the CMakeCache.txt needs to be cleaned.")
299 ENDIF(NOT Qt4_FIND_QUIETLY)
301 ENDIF(Qt4_FIND_REQUIRED)
305 INCLUDE(CheckSymbolExists)
306 INCLUDE(MacroAddFileDependencies)
308 SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake)
310 SET( QT_DEFINITIONS "")
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 IF(QT_QMAKE_EXECUTABLE)
317 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake/tmp.pro
318 "message(CMAKE_MESSAGE<$$${invar}>)")
320 # Invoke qmake with the tmp.pro program to get the desired
321 # information. Use the same variable for both stdout and stderr
322 # to make sure we get the output on all platforms.
323 EXECUTE_PROCESS(COMMAND ${QT_QMAKE_EXECUTABLE}
325 ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake
326 OUTPUT_VARIABLE _qmake_query_output
327 RESULT_VARIABLE _qmake_result
328 ERROR_VARIABLE _qmake_query_output )
331 "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake")
334 MESSAGE(WARNING " querying qmake for ${invar}. qmake reported:\n${_qmake_query_output}")
336 STRING(REGEX REPLACE ".*CMAKE_MESSAGE<([^>]*).*" "\\1" ${outvar} "${_qmake_query_output}")
339 ENDIF(QT_QMAKE_EXECUTABLE)
340 ENDMACRO(QT_QUERY_QMAKE)
342 GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME)
344 FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 PATHS
345 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
346 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
347 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]/bin"
351 IF (QT_QMAKE_EXECUTABLE)
353 IF(QT_QMAKE_EXECUTABLE_LAST)
354 STRING(COMPARE NOTEQUAL "${QT_QMAKE_EXECUTABLE_LAST}" "${QT_QMAKE_EXECUTABLE}" QT_QMAKE_CHANGED)
355 ENDIF(QT_QMAKE_EXECUTABLE_LAST)
357 SET(QT_QMAKE_EXECUTABLE_LAST "${QT_QMAKE_EXECUTABLE}" CACHE INTERNAL "" FORCE)
359 SET(QT4_QMAKE_FOUND FALSE)
361 EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
363 # check for qt3 qmake and then try and find qmake4 or qmake-qt4 in the path
364 IF("${QTVERSION}" MATCHES "Unknown")
365 SET(QT_QMAKE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE)
366 FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 PATHS
367 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
368 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
371 IF(QT_QMAKE_EXECUTABLE)
372 EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE}
373 ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION)
374 ENDIF(QT_QMAKE_EXECUTABLE)
375 ENDIF("${QTVERSION}" MATCHES "Unknown")
377 # check that we found the Qt4 qmake, Qt3 qmake output won't match here
378 STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" qt_version_tmp "${QTVERSION}")
381 # we need at least version 4.0.0
382 IF (NOT QT_MIN_VERSION)
383 SET(QT_MIN_VERSION "4.0.0")
384 ENDIF (NOT QT_MIN_VERSION)
386 #now parse the parts of the user given version string into variables
387 STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" req_qt_major_vers "${QT_MIN_VERSION}")
388 IF (NOT req_qt_major_vers)
389 MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"4.0.1\"")
390 ENDIF (NOT req_qt_major_vers)
392 # now parse the parts of the user given version string into variables
393 STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}")
394 STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers "${QT_MIN_VERSION}")
395 STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}")
397 # Suppport finding at least a particular version, for instance FIND_PACKAGE( Qt4 4.4.3 )
398 # This implementation is a hack to avoid duplicating code and make sure we stay
399 # source-compatible with CMake 2.6.x
400 # For CMake 2.8, we should not set QT_MIN_VERSION but only use Qt4_FIND_VERSION_MAJOR,
401 # Qt4_FIND_VERSION_MINOR, etc
402 IF( Qt4_FIND_VERSION )
403 SET( QT_MIN_VERSION ${Qt4_FIND_VERSION} )
404 SET( req_qt_major_vers ${Qt4_FIND_VERSION_MAJOR} )
405 SET( req_qt_minor_vers ${Qt4_FIND_VERSION_MINOR} )
406 SET( req_qt_patch_vers ${Qt4_FIND_VERSION_PATCH} )
407 ENDIF( Qt4_FIND_VERSION )
409 IF (NOT req_qt_major_vers EQUAL 4)
410 MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", major version 4 is required, e.g. \"4.0.1\"")
411 ENDIF (NOT req_qt_major_vers EQUAL 4)
413 # and now the version string given by qmake
414 STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" QT_VERSION_MAJOR "${QTVERSION}")
415 STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" QT_VERSION_MINOR "${QTVERSION}")
416 STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" QT_VERSION_PATCH "${QTVERSION}")
418 # compute an overall version number which can be compared at once
419 MATH(EXPR req_vers "${req_qt_major_vers}*10000 + ${req_qt_minor_vers}*100 + ${req_qt_patch_vers}")
420 MATH(EXPR found_vers "${QT_VERSION_MAJOR}*10000 + ${QT_VERSION_MINOR}*100 + ${QT_VERSION_PATCH}")
422 # Support finding *exactly* a particular version, for instance FIND_PACKAGE( Qt4 4.4.3 EXACT )
423 # The 'else' branch should be removed for CMake 2.8
424 IF( Qt4_FIND_VERSION_EXACT )
425 IF(found_vers EQUAL req_vers)
426 SET( QT4_QMAKE_FOUND TRUE )
427 ELSE(found_vers EQUAL req_vers)
428 SET( QT4_QMAKE_FOUND FALSE )
429 IF (found_vers LESS req_vers)
430 SET(QT4_INSTALLED_VERSION_TOO_OLD TRUE)
431 ELSE (found_vers LESS req_vers)
432 SET(QT4_INSTALLED_VERSION_TOO_NEW TRUE)
433 ENDIF (found_vers LESS req_vers)
434 ENDIF(found_vers EQUAL req_vers)
435 ELSE( Qt4_FIND_VERSION_EXACT )
436 IF (found_vers LESS req_vers)
437 SET(QT4_QMAKE_FOUND FALSE)
438 SET(QT4_INSTALLED_VERSION_TOO_OLD TRUE)
439 ELSE (found_vers LESS req_vers)
440 SET(QT4_QMAKE_FOUND TRUE)
441 ENDIF (found_vers LESS req_vers)
442 ENDIF( Qt4_FIND_VERSION_EXACT )
443 ENDIF (qt_version_tmp)
445 ENDIF (QT_QMAKE_EXECUTABLE)
449 # ask qmake for the library dir
451 IF (NOT QT_LIBRARY_DIR OR QT_QMAKE_CHANGED)
452 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
453 ARGS "-query QT_INSTALL_LIBS"
454 OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP )
455 # make sure we have / and not \ as qmake gives on windows
456 FILE(TO_CMAKE_PATH "${QT_LIBRARY_DIR_TMP}" QT_LIBRARY_DIR_TMP)
457 IF(EXISTS "${QT_LIBRARY_DIR_TMP}")
458 SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir" FORCE)
459 ELSE(EXISTS "${QT_LIBRARY_DIR_TMP}")
460 MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}")
461 MESSAGE("Warning: ${QT_LIBRARY_DIR_TMP} does NOT exist, Qt must NOT be installed correctly.")
462 ENDIF(EXISTS "${QT_LIBRARY_DIR_TMP}")
463 ENDIF(NOT QT_LIBRARY_DIR OR QT_QMAKE_CHANGED)
466 IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
467 SET(QT_USE_FRAMEWORKS ON
468 CACHE BOOL "Set to ON if Qt build uses frameworks." FORCE)
469 ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
470 SET(QT_USE_FRAMEWORKS OFF
471 CACHE BOOL "Set to ON if Qt build uses frameworks." FORCE)
472 ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
474 MARK_AS_ADVANCED(QT_USE_FRAMEWORKS)
477 # ask qmake for the binary dir
478 IF ((QT_LIBRARY_DIR AND NOT QT_BINARY_DIR) OR QT_QMAKE_CHANGED)
479 EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE}
480 ARGS "-query QT_INSTALL_BINS"
481 OUTPUT_VARIABLE qt_bins )
482 # make sure we have / and not \ as qmake gives on windows
483 FILE(TO_CMAKE_PATH "${qt_bins}" qt_bins)
484 SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "" FORCE)
485 ENDIF ((QT_LIBRARY_DIR AND NOT QT_BINARY_DIR) OR QT_QMAKE_CHANGED)
487 # ask qmake for the include dir
488 IF ((QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR) OR QT_QMAKE_CHANGED)
489 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
490 ARGS "-query QT_INSTALL_HEADERS"
491 OUTPUT_VARIABLE qt_headers )
492 # make sure we have / and not \ as qmake gives on windows
493 FILE(TO_CMAKE_PATH "${qt_headers}" qt_headers)
494 SET(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "" FORCE)
495 ENDIF ((QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR) OR QT_QMAKE_CHANGED)
498 # ask qmake for the documentation directory
499 IF ((QT_LIBRARY_DIR AND NOT QT_DOC_DIR) OR QT_QMAKE_CHANGED)
500 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
501 ARGS "-query QT_INSTALL_DOCS"
502 OUTPUT_VARIABLE qt_doc_dir )
503 # make sure we have / and not \ as qmake gives on windows
504 FILE(TO_CMAKE_PATH "${qt_doc_dir}" qt_doc_dir)
505 SET(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs" FORCE)
506 ENDIF ((QT_LIBRARY_DIR AND NOT QT_DOC_DIR) OR QT_QMAKE_CHANGED)
508 # ask qmake for the mkspecs directory
509 IF ((QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR) OR QT_QMAKE_CHANGED)
510 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
511 ARGS "-query QMAKE_MKSPECS"
512 OUTPUT_VARIABLE qt_mkspecs_dirs )
513 # do not replace : on windows as it might be a drive letter
514 # and windows should already use ; as a separator
516 STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}")
518 SET(QT_MKSPECS_DIR NOTFOUND)
519 FIND_PATH(QT_MKSPECS_DIR qconfig.pri PATHS ${qt_mkspecs_dirs}
520 DOC "The location of the Qt mkspecs containing qconfig.pri"
522 ENDIF ((QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR) OR QT_QMAKE_CHANGED)
524 # ask qmake for the plugins directory
525 IF ((QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR) OR QT_QMAKE_CHANGED)
526 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
527 ARGS "-query QT_INSTALL_PLUGINS"
528 OUTPUT_VARIABLE qt_plugins_dir )
529 # make sure we have / and not \ as qmake gives on windows
530 FILE(TO_CMAKE_PATH "${qt_plugins_dir}" qt_plugins_dir)
531 SET(QT_PLUGINS_DIR ${qt_plugins_dir} CACHE PATH "The location of the Qt plugins" FORCE)
532 ENDIF ((QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR) OR QT_QMAKE_CHANGED)
534 # ask qmake for the translations directory
535 IF ((QT_LIBRARY_DIR AND NOT QT_TRANSLATIONS_DIR) OR QT_QMAKE_CHANGED)
536 EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
537 ARGS "-query QT_INSTALL_TRANSLATIONS"
538 OUTPUT_VARIABLE qt_translations_dir )
539 # make sure we have / and not \ as qmake gives on windows
540 FILE(TO_CMAKE_PATH "${qt_translations_dir}" qt_translations_dir)
541 SET(QT_TRANSLATIONS_DIR ${qt_translations_dir} CACHE PATH "The location of the Qt translations" FORCE)
542 ENDIF ((QT_LIBRARY_DIR AND NOT QT_TRANSLATIONS_DIR) OR QT_QMAKE_CHANGED)
544 ########################################
546 # Setting the INCLUDE-Variables
548 ########################################
550 SET(QT_MODULES QtCore QtGui Qt3Support QtSvg QtScript QtTest QtUiTools
551 QtHelp QtWebKit QtXmlPatterns phonon QtMotif QtNetwork
552 QtNsPlugin QtOpenGL QtSql QtXml QtDesigner QtDBus QtScriptTools)
555 FOREACH(QT_MODULE ${QT_MODULES})
556 STRING(TOUPPER ${QT_MODULE} _upper_qt_module)
557 SET(QT_${_upper_qt_module}_INCLUDE_DIR NOTFOUND)
558 SET(QT_${_upper_qt_module}_LIBRARY_RELEASE NOTFOUND)
559 SET(QT_${_upper_qt_module}_LIBRARY_DEBUG NOTFOUND)
560 ENDFOREACH(QT_MODULE)
561 SET(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR NOTFOUND)
562 SET(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NOTFOUND)
563 SET(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NOTFOUND)
564 SET(QT_QTASSISTANTCLIENT_INCLUDE_DIR NOTFOUND)
565 SET(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NOTFOUND)
566 SET(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NOTFOUND)
567 SET(QT_QTASSISTANT_INCLUDE_DIR NOTFOUND)
568 SET(QT_QTASSISTANT_LIBRARY_RELEASE NOTFOUND)
569 SET(QT_QTASSISTANT_LIBRARY_DEBUG NOTFOUND)
570 SET(QT_QTCLUCENE_LIBRARY_RELEASE NOTFOUND)
571 SET(QT_QTCLUCENE_LIBRARY_DEBUG NOTFOUND)
572 SET(QT_QAXCONTAINER_INCLUDE_DIR NOTFOUND)
573 SET(QT_QAXCONTAINER_LIBRARY_RELEASE NOTFOUND)
574 SET(QT_QAXCONTAINER_LIBRARY_DEBUG NOTFOUND)
575 SET(QT_QAXSERVER_INCLUDE_DIR NOTFOUND)
576 SET(QT_QAXSERVER_LIBRARY_RELEASE NOTFOUND)
577 SET(QT_QAXSERVER_LIBRARY_DEBUG NOTFOUND)
579 SET(QT_QTMAIN_LIBRARY_DEBUG NOTFOUND)
580 SET(QT_QTMAIN_LIBRARY_RELEASE NOTFOUND)
582 ENDIF(QT_QMAKE_CHANGED)
584 FOREACH(QT_MODULE ${QT_MODULES})
585 STRING(TOUPPER ${QT_MODULE} _upper_qt_module)
586 FIND_PATH(QT_${_upper_qt_module}_INCLUDE_DIR ${QT_MODULE}
588 ${QT_HEADERS_DIR}/${QT_MODULE}
589 ${QT_LIBRARY_DIR}/${QT_MODULE}.framework/Headers
592 ENDFOREACH(QT_MODULE)
595 SET(QT_MODULES ${QT_MODULES} QAxContainer QAxServer)
596 # Set QT_AXCONTAINER_INCLUDE_DIR and QT_AXSERVER_INCLUDE_DIR
597 FIND_PATH(QT_QAXCONTAINER_INCLUDE_DIR ActiveQt
599 ${QT_HEADERS_DIR}/ActiveQt
602 FIND_PATH(QT_QAXSERVER_INCLUDE_DIR ActiveQt
604 ${QT_HEADERS_DIR}/ActiveQt
609 # Set QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR
610 FIND_PATH(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR QDesignerComponents
612 ${QT_HEADERS_DIR}/QtDesigner
613 ${QT_LIBRARY_DIR}/QtDesigner.framework/Headers
617 # Set QT_QTASSISTANT_INCLUDE_DIR
618 FIND_PATH(QT_QTASSISTANT_INCLUDE_DIR QAssistantClient
620 ${QT_HEADERS_DIR}/QtAssistant
621 ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers
625 # Set QT_QTASSISTANTCLIENT_INCLUDE_DIR
626 FIND_PATH(QT_QTASSISTANTCLIENT_INCLUDE_DIR QAssistantClient
628 ${QT_HEADERS_DIR}/QtAssistant
629 ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers
633 # Set QT_INCLUDE_DIR by removine "/QtCore" in the string ${QT_QTCORE_INCLUDE_DIR}
634 IF( QT_QTCORE_INCLUDE_DIR )
635 IF (QT_USE_FRAMEWORKS)
636 SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR})
637 ELSE (QT_USE_FRAMEWORKS)
638 STRING( REGEX REPLACE "/QtCore$" "" qt4_include_dir ${QT_QTCORE_INCLUDE_DIR})
639 SET( QT_INCLUDE_DIR ${qt4_include_dir})
640 ENDIF (QT_USE_FRAMEWORKS)
641 ENDIF( QT_QTCORE_INCLUDE_DIR )
643 IF( NOT QT_INCLUDE_DIR)
644 IF(Qt4_FIND_REQUIRED)
645 MESSAGE( FATAL_ERROR "Could NOT find QtCore header")
646 ENDIF(Qt4_FIND_REQUIRED)
647 ENDIF( NOT QT_INCLUDE_DIR)
649 # Make variables changeble to the advanced user
650 MARK_AS_ADVANCED( QT_LIBRARY_DIR QT_INCLUDE_DIR QT_DOC_DIR QT_MKSPECS_DIR
651 QT_PLUGINS_DIR QT_TRANSLATIONS_DIR)
654 SET( QT_INCLUDES ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} )
657 #############################################
659 # Find out what window system we're using
661 #############################################
662 # Save required variable
663 SET(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
664 SET(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
665 # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES
666 SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}")
667 # On Mac OS X when Qt has framework support, also add the framework path
668 IF( QT_USE_FRAMEWORKS )
669 SET(CMAKE_REQUIRED_FLAGS "-F${QT_LIBRARY_DIR} ")
670 ENDIF( QT_USE_FRAMEWORKS )
671 # Check for Window system symbols (note: only one should end up being set)
672 CHECK_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11)
673 CHECK_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN)
674 CHECK_SYMBOL_EXISTS(Q_WS_QWS "QtCore/qglobal.h" Q_WS_QWS)
675 CHECK_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC)
678 UNSET(QT_MAC_USE_COCOA CACHE)
679 ENDIF(QT_QMAKE_CHANGED)
680 CHECK_SYMBOL_EXISTS(QT_MAC_USE_COCOA "QtCore/qconfig.h" QT_MAC_USE_COCOA)
683 IF (QT_QTCOPY_REQUIRED)
684 CHECK_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY)
685 IF (NOT QT_IS_QTCOPY)
686 MESSAGE(FATAL_ERROR "qt-copy is required, but hasn't been found")
687 ENDIF (NOT QT_IS_QTCOPY)
688 ENDIF (QT_QTCOPY_REQUIRED)
690 # Restore CMAKE_REQUIRED_INCLUDES and CMAKE_REQUIRED_FLAGS variables
691 SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
692 SET(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
694 #############################################
698 #######################################
702 #######################################
703 IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
704 FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents)
705 STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG "${_qconfig_FILE_contents}")
706 STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG "${_qconfig_FILE_contents}")
707 STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION "${_qconfig_FILE_contents}")
708 STRING(REGEX MATCH "QT_LIBINFIX[^\n]+" _qconfig_qt_libinfix "${_qconfig_FILE_contents}")
709 STRING(REGEX REPLACE "QT_LIBINFIX *= *([^\n]*)" "\\1" QT_LIBINFIX "${_qconfig_qt_libinfix}")
710 ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
711 IF("${QT_EDITION}" MATCHES "DesktopLight")
712 SET(QT_EDITION_DESKTOPLIGHT 1)
713 ENDIF("${QT_EDITION}" MATCHES "DesktopLight")
719 FOREACH(QT_MODULE ${QT_MODULES})
720 STRING(TOUPPER ${QT_MODULE} _upper_qt_module)
721 FIND_LIBRARY(QT_${_upper_qt_module}_LIBRARY_RELEASE
722 NAMES ${QT_MODULE}${QT_LIBINFIX} ${QT_MODULE}${QT_LIBINFIX}4
723 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH
725 FIND_LIBRARY(QT_${_upper_qt_module}_LIBRARY_DEBUG
726 NAMES ${QT_MODULE}${QT_LIBINFIX}_debug ${QT_MODULE}${QT_LIBINFIX}d ${QT_MODULE}${QT_LIBINFIX}d4
727 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH
729 ENDFOREACH(QT_MODULE)
731 # QtUiTools not with other frameworks with binary installation (in /usr/lib)
732 IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE)
733 FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR})
734 ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE)
736 IF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE )
738 # try dropping a hint if trying to use Visual Studio with Qt built by mingw
739 IF(QT_LIBRARY_DIR AND MSVC)
740 IF(EXISTS ${QT_LIBRARY_DIR}/libqtmain.a)
741 MESSAGE( FATAL_ERROR "It appears you're trying to use Visual Studio with Qt built by mingw")
742 ENDIF(EXISTS ${QT_LIBRARY_DIR}/libqtmain.a)
743 ENDIF(QT_LIBRARY_DIR AND MSVC)
745 IF(Qt4_FIND_REQUIRED)
746 MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.")
747 ENDIF(Qt4_FIND_REQUIRED)
748 ENDIF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE )
750 # Set QT_QTDESIGNERCOMPONENTS_LIBRARY
751 FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents${QT_LIBINFIX} QtDesignerComponents${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
752 FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NAMES QtDesignerComponents${QT_LIBINFIX}_debug QtDesignerComponents${QT_LIBINFIX}d QtDesignerComponents${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
754 # Set QT_QTMAIN_LIBRARY
756 FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR}
758 FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmain${QT_LIBINFIX}d PATHS ${QT_LIBRARY_DIR}
762 # Set QT_QTASSISTANTCLIENT_LIBRARY
763 FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
764 FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
766 # Set QT_QTASSISTANT_LIBRARY
767 FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 QtAssistant${QT_LIBINFIX} QtAssistant${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
768 FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 QtAssistant${QT_LIBINFIX}_debug QtAssistant${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
770 # Set QT_QTHELP_LIBRARY
771 FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} QtCLucene${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
772 FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_DEBUG NAMES QtCLucene${QT_LIBINFIX}_debug QtCLucene${QT_LIBINFIX}d QtCLucene${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH)
773 # QtCLucene not with other frameworks with binary installation (in /usr/lib)
774 IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE)
775 FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR})
776 ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE)
778 ############################################
780 # Check the existence of the libraries.
782 ############################################
784 MACRO (_QT4_ADJUST_LIB_VARS basename)
785 IF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG)
787 # if only the release version was found, set the debug variable also to the release version
788 IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
789 SET(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE})
790 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE})
791 SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_RELEASE})
792 ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
794 # if only the debug version was found, set the release variable also to the debug version
795 IF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE)
796 SET(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG})
797 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG})
798 SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_DEBUG})
799 ENDIF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE)
801 IF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
802 # if the generator supports configuration types then set
803 # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
804 IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
805 SET(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
806 ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
807 # if there are no configuration types and CMAKE_BUILD_TYPE has no value
808 # then just use the release libraries
809 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE} )
810 ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
811 SET(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
812 ENDIF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
814 SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE STRING "The Qt ${basename} library" FORCE)
816 IF (QT_${basename}_LIBRARY)
817 SET(QT_${basename}_FOUND 1)
818 ENDIF (QT_${basename}_LIBRARY)
820 ENDIF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG)
822 IF (QT_${basename}_INCLUDE_DIR)
823 #add the include directory to QT_INCLUDES
824 SET(QT_INCLUDES "${QT_${basename}_INCLUDE_DIR}" ${QT_INCLUDES})
825 ENDIF (QT_${basename}_INCLUDE_DIR)
827 # Make variables changeble to the advanced user
828 MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR)
829 ENDMACRO (_QT4_ADJUST_LIB_VARS)
832 # Set QT_xyz_LIBRARY variable and add
833 # library include path to QT_INCLUDES
834 _QT4_ADJUST_LIB_VARS(QTCORE)
835 _QT4_ADJUST_LIB_VARS(QTGUI)
836 _QT4_ADJUST_LIB_VARS(QT3SUPPORT)
837 _QT4_ADJUST_LIB_VARS(QTASSISTANT)
838 _QT4_ADJUST_LIB_VARS(QTDESIGNER)
839 _QT4_ADJUST_LIB_VARS(QTDESIGNERCOMPONENTS)
840 _QT4_ADJUST_LIB_VARS(QTNETWORK)
841 _QT4_ADJUST_LIB_VARS(QTNSPLUGIN)
842 _QT4_ADJUST_LIB_VARS(QTOPENGL)
843 _QT4_ADJUST_LIB_VARS(QTSQL)
844 _QT4_ADJUST_LIB_VARS(QTXML)
845 _QT4_ADJUST_LIB_VARS(QTSVG)
846 _QT4_ADJUST_LIB_VARS(QTSCRIPT)
847 _QT4_ADJUST_LIB_VARS(QTUITOOLS)
848 _QT4_ADJUST_LIB_VARS(QTTEST)
849 _QT4_ADJUST_LIB_VARS(QTDBUS)
850 _QT4_ADJUST_LIB_VARS(QTASSISTANTCLIENT)
851 _QT4_ADJUST_LIB_VARS(QTHELP)
852 _QT4_ADJUST_LIB_VARS(QTWEBKIT)
853 _QT4_ADJUST_LIB_VARS(QTXMLPATTERNS)
854 _QT4_ADJUST_LIB_VARS(PHONON)
855 _QT4_ADJUST_LIB_VARS(QTCLUCENE)
856 _QT4_ADJUST_LIB_VARS(QTMOTIF)
857 _QT4_ADJUST_LIB_VARS(QTSCRIPTTOOLS)
859 # platform dependent libraries
861 _QT4_ADJUST_LIB_VARS(QTMAIN)
862 _QT4_ADJUST_LIB_VARS(QAXSERVER)
863 _QT4_ADJUST_LIB_VARS(QAXCONTAINER)
867 #######################################
869 # Check the executables of Qt
872 #######################################
876 SET(QT_UIC_EXECUTABLE NOTFOUND)
877 SET(QT_MOC_EXECUTABLE NOTFOUND)
878 SET(QT_UIC3_EXECUTABLE NOTFOUND)
879 SET(QT_RCC_EXECUTABLE NOTFOUND)
880 SET(QT_DBUSCPP2XML_EXECUTABLE NOTFOUND)
881 SET(QT_DBUSXML2CPP_EXECUTABLE NOTFOUND)
882 SET(QT_LUPDATE_EXECUTABLE NOTFOUND)
883 SET(QT_LRELEASE_EXECUTABLE NOTFOUND)
884 SET(QT_QCOLLECTIONGENERATOR_EXECUTABLE NOTFOUND)
885 ENDIF(QT_QMAKE_CHANGED)
887 FIND_PROGRAM(QT_MOC_EXECUTABLE
889 PATHS ${QT_BINARY_DIR}
893 FIND_PROGRAM(QT_UIC_EXECUTABLE
895 PATHS ${QT_BINARY_DIR}
899 FIND_PROGRAM(QT_UIC3_EXECUTABLE
901 PATHS ${QT_BINARY_DIR}
905 FIND_PROGRAM(QT_RCC_EXECUTABLE
907 PATHS ${QT_BINARY_DIR}
911 FIND_PROGRAM(QT_DBUSCPP2XML_EXECUTABLE
913 PATHS ${QT_BINARY_DIR}
917 FIND_PROGRAM(QT_DBUSXML2CPP_EXECUTABLE
919 PATHS ${QT_BINARY_DIR}
923 FIND_PROGRAM(QT_LUPDATE_EXECUTABLE
924 NAMES lupdate-qt4 lupdate
925 PATHS ${QT_BINARY_DIR}
929 FIND_PROGRAM(QT_LRELEASE_EXECUTABLE
930 NAMES lrelease-qt4 lrelease
931 PATHS ${QT_BINARY_DIR}
935 FIND_PROGRAM(QT_QCOLLECTIONGENERATOR_EXECUTABLE
936 NAMES qcollectiongenerator-qt4 qcollectiongenerator
937 PATHS ${QT_BINARY_DIR}
941 IF (QT_MOC_EXECUTABLE)
942 SET(QT_WRAP_CPP "YES")
943 ENDIF (QT_MOC_EXECUTABLE)
945 IF (QT_UIC_EXECUTABLE)
946 SET(QT_WRAP_UI "YES")
947 ENDIF (QT_UIC_EXECUTABLE)
951 MARK_AS_ADVANCED( QT_UIC_EXECUTABLE QT_UIC3_EXECUTABLE QT_MOC_EXECUTABLE
952 QT_RCC_EXECUTABLE QT_DBUSXML2CPP_EXECUTABLE QT_DBUSCPP2XML_EXECUTABLE
953 QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE QT_QCOLLECTIONGENERATOR_EXECUTABLE)
955 ######################################
957 # Macros for building Qt files
959 ######################################
961 MACRO (QT4_EXTRACT_OPTIONS _qt4_files _qt4_options)
964 SET(_QT4_DOING_OPTIONS FALSE)
965 FOREACH(_currentArg ${ARGN})
966 IF ("${_currentArg}" STREQUAL "OPTIONS")
967 SET(_QT4_DOING_OPTIONS TRUE)
968 ELSE ("${_currentArg}" STREQUAL "OPTIONS")
969 IF(_QT4_DOING_OPTIONS)
970 LIST(APPEND ${_qt4_options} "${_currentArg}")
971 ELSE(_QT4_DOING_OPTIONS)
972 LIST(APPEND ${_qt4_files} "${_currentArg}")
973 ENDIF(_QT4_DOING_OPTIONS)
974 ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
975 ENDFOREACH(_currentArg)
976 ENDMACRO (QT4_EXTRACT_OPTIONS)
978 # macro used to create the names of output files preserving relative dirs
979 MACRO (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile )
980 STRING(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
981 STRING(LENGTH ${infile} _infileLength)
982 SET(_checkinfile ${CMAKE_CURRENT_SOURCE_DIR})
983 IF(_infileLength GREATER _binlength)
984 STRING(SUBSTRING "${infile}" 0 ${_binlength} _checkinfile)
985 IF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
986 FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_BINARY_DIR} ${infile})
987 ELSE(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
988 FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
989 ENDIF(_checkinfile STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
990 ELSE(_infileLength GREATER _binlength)
991 FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
992 ENDIF(_infileLength GREATER _binlength)
993 IF(WIN32 AND rel MATCHES "^[a-zA-Z]:") # absolute path
994 STRING(REGEX REPLACE "^([a-zA-Z]):(.*)$" "\\1_\\2" rel "${rel}")
995 ENDIF(WIN32 AND rel MATCHES "^[a-zA-Z]:")
996 SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
997 STRING(REPLACE ".." "__" _outfile ${_outfile})
998 GET_FILENAME_COMPONENT(outpath ${_outfile} PATH)
999 GET_FILENAME_COMPONENT(_outfile ${_outfile} NAME_WE)
1000 FILE(MAKE_DIRECTORY ${outpath})
1001 SET(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
1002 ENDMACRO (QT4_MAKE_OUTPUT_FILE )
1004 MACRO (QT4_GET_MOC_FLAGS _moc_flags)
1006 GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES)
1008 FOREACH(_current ${_inc_DIRS})
1009 SET(${_moc_flags} ${${_moc_flags}} "-I${_current}")
1010 ENDFOREACH(_current ${_inc_DIRS})
1012 GET_DIRECTORY_PROPERTY(_defines COMPILE_DEFINITIONS)
1013 FOREACH(_current ${_defines})
1014 SET(${_moc_flags} ${${_moc_flags}} "-D${_current}")
1015 ENDFOREACH(_current ${_defines})
1018 SET(${_moc_flags} ${${_moc_flags}} -DWIN32)
1021 ENDMACRO(QT4_GET_MOC_FLAGS)
1023 # helper macro to set up a moc rule
1024 MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_flags 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_flags} ${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_flags} ${moc_options} -o ${outfile} ${infile}
1054 ENDMACRO (QT4_CREATE_MOC_COMMAND)
1057 MACRO (QT4_GENERATE_MOC infile outfile )
1058 QT4_GET_MOC_FLAGS(moc_flags)
1059 GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE)
1060 QT4_CREATE_MOC_COMMAND(${abs_infile} ${outfile} "${moc_flags}" "")
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_FLAGS(moc_flags)
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_flags}" "${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} -o ${_target} ${_in_file}
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_FLAGS(_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 IF(EXISTS ${_abs_PATH}/${_basename}.hpp)
1246 SET(_header ${_abs_PATH}/${_basename}.hpp)
1247 ELSE(EXISTS ${_abs_PATH}/${_basename}.hpp)
1248 SET(_header ${_abs_PATH}/${_basename}.h)
1249 ENDIF(EXISTS ${_abs_PATH}/${_basename}.hpp)
1250 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
1251 QT4_CREATE_MOC_COMMAND(${_header} ${_moc} "${_moc_INCS}" "")
1252 MACRO_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
1253 ENDFOREACH (_current_MOC_INC)
1255 ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} )
1256 ENDFOREACH (_current_FILE)
1257 ENDMACRO(QT4_AUTOMOC)
1259 MACRO(QT4_CREATE_TRANSLATION _qm_files)
1260 QT4_EXTRACT_OPTIONS(_lupdate_files _lupdate_options ${ARGN})
1265 FOREACH (_file ${_lupdate_files})
1266 GET_FILENAME_COMPONENT(_ext ${_file} EXT)
1267 GET_FILENAME_COMPONENT(_abs_FILE ${_file} ABSOLUTE)
1268 IF(_ext MATCHES "ts")
1269 LIST(APPEND _my_tsfiles ${_abs_FILE})
1270 ELSE(_ext MATCHES "ts")
1272 LIST(APPEND _my_dirs ${_abs_FILE})
1274 LIST(APPEND _my_sources ${_abs_FILE})
1276 ENDIF(_ext MATCHES "ts")
1278 FOREACH(_ts_file ${_my_tsfiles})
1280 # make a .pro file to call lupdate on, so we don't make our commands too
1281 # long for some systems
1282 GET_FILENAME_COMPONENT(_ts_name ${_ts_file} NAME_WE)
1283 SET(_ts_pro ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lupdate.pro)
1285 FOREACH(_pro_src ${_my_sources})
1286 SET(_pro_srcs "${_pro_srcs} \"${_pro_src}\"")
1287 ENDFOREACH(_pro_src ${_my_sources})
1288 FILE(WRITE ${_ts_pro} "SOURCES = ${_pro_srcs}")
1290 ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file}
1291 COMMAND ${QT_LUPDATE_EXECUTABLE}
1292 ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file}
1293 DEPENDS ${_my_sources} ${_ts_pro})
1294 ENDFOREACH(_ts_file)
1295 QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles})
1296 ENDMACRO(QT4_CREATE_TRANSLATION)
1298 MACRO(QT4_ADD_TRANSLATION _qm_files)
1299 FOREACH (_current_FILE ${ARGN})
1300 GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
1301 GET_FILENAME_COMPONENT(qm ${_abs_FILE} NAME_WE)
1302 GET_SOURCE_FILE_PROPERTY(output_location ${_abs_FILE} OUTPUT_LOCATION)
1304 FILE(MAKE_DIRECTORY "${output_location}")
1305 SET(qm "${output_location}/${qm}.qm")
1306 ELSE(output_location)
1307 SET(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm")
1308 ENDIF(output_location)
1310 ADD_CUSTOM_COMMAND(OUTPUT ${qm}
1311 COMMAND ${QT_LRELEASE_EXECUTABLE}
1312 ARGS ${_abs_FILE} -qm ${qm}
1313 DEPENDS ${_abs_FILE}
1315 SET(${_qm_files} ${${_qm_files}} ${qm})
1316 ENDFOREACH (_current_FILE)
1317 ENDMACRO(QT4_ADD_TRANSLATION)
1323 ######################################
1325 # decide if Qt got found
1327 ######################################
1329 # if the includes,libraries,moc,uic and rcc are found then we have it
1330 IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND
1331 QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE AND QT_QTCORE_LIBRARY)
1332 SET( QT4_FOUND "YES" )
1333 INCLUDE(FindPackageMessage)
1334 FIND_PACKAGE_MESSAGE(Qt4 "Found Qt-Version ${QTVERSION}"
1335 "[${QT_LIBRARY_DIR}][${QT_INCLUDE_DIR}][${QT_MOC_EXECUTABLE}][${QT_UIC_EXECUTABLE}][${QT_RCC_EXECUTABLE}]")
1336 ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND
1337 QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE AND QT_QTCORE_LIBRARY)
1338 SET( QT4_FOUND "NO")
1339 SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1340 IF( Qt4_FIND_REQUIRED)
1341 MESSAGE( FATAL_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!")
1342 ENDIF( Qt4_FIND_REQUIRED)
1343 ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND
1344 QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE AND QT_QTCORE_LIBRARY)
1346 SET(QT_FOUND ${QT4_FOUND})
1349 ###############################################
1351 # configuration/system dependent settings
1353 ###############################################
1355 # find dependencies for some Qt modules
1356 # when doing builds against a static Qt, they are required
1357 # when doing builds against a shared Qt, they are sometimes not required
1358 # even some Linux distros do not require these dependencies
1359 # if a user needs the dependencies, and they couldn't be found, they can set
1360 # the variables themselves.
1362 SET(QT_QTGUI_LIB_DEPENDENCIES "")
1363 SET(QT_QTCORE_LIB_DEPENDENCIES "")
1364 SET(QT_QTNETWORK_LIB_DEPENDENCIES "")
1365 SET(QT_QTOPENGL_LIB_DEPENDENCIES "")
1366 SET(QT_QTDBUS_LIB_DEPENDENCIES "")
1367 SET(QT_QTHELP_LIB_DEPENDENCIES ${QT_QTCLUCENE_LIBRARY})
1369 # build using shared Qt needs -DQT_DLL
1370 IF(NOT QT_CONFIG MATCHES "static")
1371 # warning currently only qconfig.pri on Windows potentially contains "static"
1372 # so QT_DLL might not get defined properly on other platforms.
1373 SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_DLL)
1374 ENDIF(NOT QT_CONFIG MATCHES "static")
1376 # QtOpenGL dependencies
1377 QT_QUERY_QMAKE(QMAKE_LIBS_OPENGL "QMAKE_LIBS_OPENGL")
1378 SET (QT_QTOPENGL_LIB_DEPENDENCIES ${QT_QTOPENGL_LIB_DEPENDENCIES} ${QMAKE_LIBS_OPENGL})
1381 IF(QT_QCONFIG MATCHES "system-png")
1382 FIND_LIBRARY(QT_PNG_LIBRARY NAMES png)
1383 MARK_AS_ADVANCED(QT_PNG_LIBRARY)
1385 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY})
1386 ENDIF(QT_PNG_LIBRARY)
1387 ENDIF(QT_QCONFIG MATCHES "system-png")
1389 # for X11, get X11 library directory
1391 QT_QUERY_QMAKE(QMAKE_LIBDIR_X11 "QMAKE_LIBDIR_X11")
1395 IF(QT_QCONFIG MATCHES "x11sm")
1396 # ask qmake where the x11 libs are
1397 FIND_LIBRARY(QT_X11_SM_LIBRARY NAMES SM PATHS ${QMAKE_LIBDIR_X11})
1398 FIND_LIBRARY(QT_X11_ICE_LIBRARY NAMES ICE PATHS ${QMAKE_LIBDIR_X11})
1399 MARK_AS_ADVANCED(QT_X11_SM_LIBRARY)
1400 MARK_AS_ADVANCED(QT_X11_ICE_LIBRARY)
1401 IF(QT_X11_SM_LIBRARY AND QT_X11_ICE_LIBRARY)
1402 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_X11_SM_LIBRARY} ${QT_X11_ICE_LIBRARY})
1403 ENDIF(QT_X11_SM_LIBRARY AND QT_X11_ICE_LIBRARY)
1404 ENDIF(QT_QCONFIG MATCHES "x11sm")
1407 IF(QT_QCONFIG MATCHES "tablet")
1408 FIND_LIBRARY(QT_XI_LIBRARY NAMES Xi PATHS ${QMAKE_LIBDIR_X11})
1409 MARK_AS_ADVANCED(QT_XI_LIBRARY)
1411 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XI_LIBRARY})
1412 ENDIF(QT_XI_LIBRARY)
1413 ENDIF(QT_QCONFIG MATCHES "tablet")
1416 IF(QT_QCONFIG MATCHES "xrender")
1417 FIND_LIBRARY(QT_XRENDER_LIBRARY NAMES Xrender PATHS ${QMAKE_LIBDIR_X11})
1418 MARK_AS_ADVANCED(QT_XRENDER_LIBRARY)
1419 IF(QT_XRENDER_LIBRARY)
1420 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRENDER_LIBRARY})
1421 ENDIF(QT_XRENDER_LIBRARY)
1422 ENDIF(QT_QCONFIG MATCHES "xrender")
1425 IF(QT_QCONFIG MATCHES "xrandr")
1426 FIND_LIBRARY(QT_XRANDR_LIBRARY NAMES Xrandr PATHS ${QMAKE_LIBDIR_X11})
1427 MARK_AS_ADVANCED(QT_XRANDR_LIBRARY)
1428 IF(QT_XRANDR_LIBRARY)
1429 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRANDR_LIBRARY})
1430 ENDIF(QT_XRANDR_LIBRARY)
1431 ENDIF(QT_QCONFIG MATCHES "xrandr")
1434 IF(QT_QCONFIG MATCHES "xcursor")
1435 FIND_LIBRARY(QT_XCURSOR_LIBRARY NAMES Xcursor PATHS ${QMAKE_LIBDIR_X11})
1436 MARK_AS_ADVANCED(QT_XCURSOR_LIBRARY)
1437 IF(QT_XCURSOR_LIBRARY)
1438 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XCURSOR_LIBRARY})
1439 ENDIF(QT_XCURSOR_LIBRARY)
1440 ENDIF(QT_QCONFIG MATCHES "xcursor")
1443 IF(QT_QCONFIG MATCHES "xinerama")
1444 FIND_LIBRARY(QT_XINERAMA_LIBRARY NAMES Xinerama PATHS ${QMAKE_LIBDIR_X11})
1445 MARK_AS_ADVANCED(QT_XINERAMA_LIBRARY)
1446 IF(QT_XINERAMA_LIBRARY)
1447 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XINERAMA_LIBRARY})
1448 ENDIF(QT_XINERAMA_LIBRARY)
1449 ENDIF(QT_QCONFIG MATCHES "xinerama")
1452 IF(QT_QCONFIG MATCHES "xfixes")
1453 FIND_LIBRARY(QT_XFIXES_LIBRARY NAMES Xfixes PATHS ${QMAKE_LIBDIR_X11})
1454 MARK_AS_ADVANCED(QT_XFIXES_LIBRARY)
1455 IF(QT_XFIXES_LIBRARY)
1456 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XFIXES_LIBRARY})
1457 ENDIF(QT_XFIXES_LIBRARY)
1458 ENDIF(QT_QCONFIG MATCHES "xfixes")
1461 IF(QT_QCONFIG MATCHES "system-freetype")
1462 FIND_LIBRARY(QT_FREETYPE_LIBRARY NAMES freetype)
1463 MARK_AS_ADVANCED(QT_FREETYPE_LIBRARY)
1464 IF(QT_FREETYPE_LIBRARY)
1465 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY})
1466 ENDIF(QT_FREETYPE_LIBRARY)
1467 ENDIF(QT_QCONFIG MATCHES "system-freetype")
1470 IF(QT_QCONFIG MATCHES "fontconfig")
1471 FIND_LIBRARY(QT_FONTCONFIG_LIBRARY NAMES fontconfig)
1472 MARK_AS_ADVANCED(QT_FONTCONFIG_LIBRARY)
1473 IF(QT_FONTCONFIG_LIBRARY)
1474 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY})
1475 ENDIF(QT_FONTCONFIG_LIBRARY)
1476 ENDIF(QT_QCONFIG MATCHES "fontconfig")
1479 IF(QT_QCONFIG MATCHES "system-zlib")
1480 FIND_LIBRARY(QT_ZLIB_LIBRARY NAMES z)
1481 MARK_AS_ADVANCED(QT_ZLIB_LIBRARY)
1483 SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY})
1484 ENDIF(QT_ZLIB_LIBRARY)
1485 ENDIF(QT_QCONFIG MATCHES "system-zlib")
1488 IF(QT_QCONFIG MATCHES "openssl" AND NOT Q_WS_WIN)
1489 FIND_PACKAGE(OpenSSL)
1490 IF(OPENSSL_LIBRARIES)
1491 SET(QT_QTNETWORK_LIB_DEPENDENCIES ${QT_QTNETWORK_LIB_DEPENDENCIES} ${OPENSSL_LIBRARIES})
1492 ENDIF(OPENSSL_LIBRARIES)
1493 ENDIF(QT_QCONFIG MATCHES "openssl" AND NOT Q_WS_WIN)
1496 IF(QT_QCONFIG MATCHES "dbus")
1498 # if the dbus library isn't found, we'll assume its not required to build
1499 # shared Qt on Linux doesn't require it
1500 IF(NOT QT_DBUS_LIBRARY)
1501 EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L dbus-1
1502 OUTPUT_VARIABLE _dbus_query_output
1503 RESULT_VARIABLE _dbus_result
1504 ERROR_VARIABLE _dbus_query_output )
1506 IF(_dbus_result MATCHES 0)
1507 STRING(REPLACE "-L" "" _dbus_query_output "${_dbus_query_output}")
1508 SEPARATE_ARGUMENTS(_dbus_query_output)
1509 ELSE(_dbus_result MATCHES 0)
1510 SET(_dbus_query_output)
1511 ENDIF(_dbus_result MATCHES 0)
1513 FIND_LIBRARY(QT_DBUS_LIBRARY NAMES dbus-1 PATHS ${_dbus_query_output} )
1516 SET(QT_QTDBUS_LIB_DEPENDENCIES ${QT_QTDBUS_LIB_DEPENDENCIES} ${QT_DBUS_LIBRARY})
1517 ENDIF(QT_DBUS_LIBRARY)
1519 MARK_AS_ADVANCED(QT_DBUS_LIBRARY)
1520 ENDIF(NOT QT_DBUS_LIBRARY)
1522 ENDIF(QT_QCONFIG MATCHES "dbus")
1525 IF(QT_QCONFIG MATCHES "glib")
1527 # if the glib libraries aren't found, we'll assume its not required to build
1528 # shared Qt on Linux doesn't require it
1530 # Qt 4.2.0+ uses glib-2.0
1531 IF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY)
1532 EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L glib-2.0 gthread-2.0
1533 OUTPUT_VARIABLE _glib_query_output
1534 RESULT_VARIABLE _glib_result
1535 ERROR_VARIABLE _glib_query_output )
1537 IF(_glib_result MATCHES 0)
1538 STRING(REPLACE "-L" "" _glib_query_output "${_glib_query_output}")
1539 SEPARATE_ARGUMENTS(_glib_query_output)
1540 ELSE(_glib_result MATCHES 0)
1541 SET(_glib_query_output)
1542 ENDIF(_glib_result MATCHES 0)
1544 FIND_LIBRARY(QT_GLIB_LIBRARY NAMES glib-2.0 PATHS ${_glib_query_output} )
1545 FIND_LIBRARY(QT_GTHREAD_LIBRARY NAMES gthread-2.0 PATHS ${_glib_query_output} )
1547 MARK_AS_ADVANCED(QT_GLIB_LIBRARY)
1548 MARK_AS_ADVANCED(QT_GTHREAD_LIBRARY)
1549 ENDIF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY)
1551 IF(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY)
1552 SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES}
1553 ${QT_GTHREAD_LIBRARY} ${QT_GLIB_LIBRARY})
1554 ENDIF(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY)
1557 # Qt 4.5+ also links to gobject-2.0
1558 IF(QT_VERSION_MINOR GREATER 4)
1559 IF(NOT QT_GOBJECT_LIBRARY)
1560 EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L gobject-2.0
1561 OUTPUT_VARIABLE _glib_query_output
1562 RESULT_VARIABLE _glib_result
1563 ERROR_VARIABLE _glib_query_output )
1565 IF(_glib_result MATCHES 0)
1566 STRING(REPLACE "-L" "" _glib_query_output "${_glib_query_output}")
1567 SEPARATE_ARGUMENTS(_glib_query_output)
1568 ELSE(_glib_result MATCHES 0)
1569 SET(_glib_query_output)
1570 ENDIF(_glib_result MATCHES 0)
1572 FIND_LIBRARY(QT_GOBJECT_LIBRARY NAMES gobject-2.0 PATHS ${_glib_query_output} )
1574 MARK_AS_ADVANCED(QT_GOBJECT_LIBRARY)
1575 ENDIF(NOT QT_GOBJECT_LIBRARY)
1577 IF(QT_GOBJECT_LIBRARY)
1578 SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES}
1579 ${QT_GOBJECT_LIBRARY})
1580 ENDIF(QT_GOBJECT_LIBRARY)
1581 ENDIF(QT_VERSION_MINOR GREATER 4)
1583 ENDIF(QT_QCONFIG MATCHES "glib")
1585 ## clock-monotonic, just see if we need to link with rt
1586 IF(QT_QCONFIG MATCHES "clock-monotonic")
1587 SET(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
1588 SET(CMAKE_REQUIRED_LIBRARIES rt)
1589 CHECK_SYMBOL_EXISTS(_POSIX_TIMERS "unistd.h;time.h" QT_POSIX_TIMERS)
1590 SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
1592 FIND_LIBRARY(QT_RT_LIBRARY NAMES rt)
1593 MARK_AS_ADVANCED(QT_RT_LIBRARY)
1595 SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_RT_LIBRARY})
1596 ENDIF(QT_RT_LIBRARY)
1597 ENDIF(QT_POSIX_TIMERS)
1598 ENDIF(QT_QCONFIG MATCHES "clock-monotonic")
1601 # X11 libraries Qt absolutely depends on
1602 QT_QUERY_QMAKE(QT_LIBS_X11 "QMAKE_LIBS_X11")
1603 SEPARATE_ARGUMENTS(QT_LIBS_X11)
1604 FOREACH(QT_X11_LIB ${QT_LIBS_X11})
1605 STRING(REGEX REPLACE "-l" "" QT_X11_LIB "${QT_X11_LIB}")
1606 SET(QT_TMP_STR "QT_X11_${QT_X11_LIB}_LIBRARY")
1607 FIND_LIBRARY(${QT_TMP_STR} NAMES "${QT_X11_LIB}" PATHS ${QMAKE_LIBDIR_X11})
1608 MARK_AS_ADVANCED(${QT_TMP_STR})
1610 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${${QT_TMP_STR}})
1611 ENDIF(${QT_TMP_STR})
1612 ENDFOREACH(QT_X11_LIB)
1614 QT_QUERY_QMAKE(QT_LIBS_THREAD "QMAKE_LIBS_THREAD")
1615 SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_LIBS_THREAD})
1617 QT_QUERY_QMAKE(QMAKE_LIBS_DYNLOAD "QMAKE_LIBS_DYNLOAD")
1618 SET (QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QMAKE_LIBS_DYNLOAD})
1623 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} imm32 winmm)
1624 SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ws2_32)
1628 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework Carbon")
1630 # Qt 4.0, 4.1, 4.2 use QuickTime
1631 IF(QT_VERSION_MINOR LESS 3)
1632 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework QuickTime")
1633 ENDIF(QT_VERSION_MINOR LESS 3)
1635 # Qt 4.2+ use AppKit
1636 IF(QT_VERSION_MINOR GREATER 1)
1637 SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework AppKit")
1638 ENDIF(QT_VERSION_MINOR GREATER 1)
1640 SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} "-framework ApplicationServices")
1643 #######################################
1645 # compatibility settings
1647 #######################################
1648 # Backwards compatibility for CMake1.4 and 1.2
1649 SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} )
1650 SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} )
1652 SET( QT_QT_LIBRARY "")
1654 ELSE(QT4_QMAKE_FOUND)
1656 SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE)
1658 # The code below is overly complex to make sure we do not break compatibility with CMake 2.6.x
1659 # For CMake 2.8, it should be simplified by getting rid of QT4_INSTALLED_VERSION_TOO_OLD and
1660 # QT4_INSTALLED_VERSION_TOO_NEW
1661 IF(Qt4_FIND_REQUIRED)
1662 IF(QT4_INSTALLED_VERSION_TOO_OLD)
1663 IF( Qt4_FIND_VERSION_EXACT )
1664 MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, version ${QT_MIN_VERSION} is required")
1665 ELSE( Qt4_FIND_VERSION_EXACT )
1666 MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1667 ENDIF( Qt4_FIND_VERSION_EXACT )
1668 ELSE(QT4_INSTALLED_VERSION_TOO_OLD)
1669 IF( Qt4_FIND_VERSION_EXACT AND QT4_INSTALLED_VERSION_TOO_NEW )
1670 MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too new, version ${QT_MIN_VERSION} is required")
1671 ELSE( Qt4_FIND_VERSION_EXACT AND QT4_INSTALLED_VERSION_TOO_NEW )
1672 MESSAGE( FATAL_ERROR "Qt qmake not found!")
1673 ENDIF( Qt4_FIND_VERSION_EXACT AND QT4_INSTALLED_VERSION_TOO_NEW )
1674 ENDIF(QT4_INSTALLED_VERSION_TOO_OLD)
1675 ELSE(Qt4_FIND_REQUIRED)
1676 IF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1677 MESSAGE(STATUS "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required")
1678 ENDIF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY)
1679 ENDIF(Qt4_FIND_REQUIRED)
1681 ENDIF (QT4_QMAKE_FOUND)