1# Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2# file Copyright.txt or https://cmake.org/licensing for details. 3 4#[=======================================================================[.rst: 5FindQt4 6------- 7 8Finding and Using Qt4 9^^^^^^^^^^^^^^^^^^^^^ 10 11This module can be used to find Qt4. The most important issue is that 12the Qt4 qmake is available via the system path. This qmake is then 13used to detect basically everything else. This module defines a 14number of :prop_tgt:`IMPORTED` targets, macros and variables. 15 16Typical usage could be something like: 17 18.. code-block:: cmake 19 20 set(CMAKE_AUTOMOC ON) 21 set(CMAKE_INCLUDE_CURRENT_DIR ON) 22 find_package(Qt4 4.4.3 REQUIRED QtGui QtXml) 23 add_executable(myexe main.cpp) 24 target_link_libraries(myexe Qt4::QtGui Qt4::QtXml) 25 26.. note:: 27 28 When using :prop_tgt:`IMPORTED` targets, the qtmain.lib static library is 29 automatically linked on Windows for :prop_tgt:`WIN32 <WIN32_EXECUTABLE>` 30 executables. To disable that globally, set the 31 ``QT4_NO_LINK_QTMAIN`` variable before finding Qt4. To disable that 32 for a particular executable, set the ``QT4_NO_LINK_QTMAIN`` target 33 property to ``TRUE`` on the executable. 34 35Qt Build Tools 36^^^^^^^^^^^^^^ 37 38Qt relies on some bundled tools for code generation, such as ``moc`` for 39meta-object code generation,``uic`` for widget layout and population, 40and ``rcc`` for virtual filesystem content generation. These tools may be 41automatically invoked by :manual:`cmake(1)` if the appropriate conditions 42are met. See :manual:`cmake-qt(7)` for more. 43 44Qt Macros 45^^^^^^^^^ 46 47In some cases it can be necessary or useful to invoke the Qt build tools in a 48more-manual way. Several macros are available to add targets for such uses. 49 50:: 51 52 macro QT4_WRAP_CPP(outfiles inputfile ... [TARGET tgt] OPTIONS ...) 53 create moc code from a list of files containing Qt class with 54 the Q_OBJECT declaration. Per-directory preprocessor definitions 55 are also added. If the <tgt> is specified, the 56 INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS from 57 the <tgt> are passed to moc. Options may be given to moc, such as 58 those found when executing "moc -help". 59 60 61:: 62 63 macro QT4_WRAP_UI(outfiles inputfile ... OPTIONS ...) 64 create code from a list of Qt designer ui files. 65 Options may be given to uic, such as those found 66 when executing "uic -help" 67 68 69:: 70 71 macro QT4_ADD_RESOURCES(outfiles inputfile ... OPTIONS ...) 72 create code from a list of Qt resource files. 73 Options may be given to rcc, such as those found 74 when executing "rcc -help" 75 76 77:: 78 79 macro QT4_GENERATE_MOC(inputfile outputfile [TARGET tgt]) 80 creates a rule to run moc on infile and create outfile. 81 Use this if for some reason QT4_WRAP_CPP() isn't appropriate, e.g. 82 because you need a custom filename for the moc file or something 83 similar. If the <tgt> is specified, the 84 INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS from 85 the <tgt> are passed to moc. 86 87 88:: 89 90 macro QT4_ADD_DBUS_INTERFACE(outfiles interface basename) 91 Create the interface header and implementation files with the 92 given basename from the given interface xml file and add it to 93 the list of sources. 94 95 You can pass additional parameters to the qdbusxml2cpp call by setting 96 properties on the input file: 97 98 INCLUDE the given file will be included in the generate interface header 99 100 CLASSNAME the generated class is named accordingly 101 102 NO_NAMESPACE the generated class is not wrapped in a namespace 103 104 105:: 106 107 macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... ) 108 Create the interface header and implementation files 109 for all listed interface xml files. 110 The basename will be automatically determined from the name 111 of the xml file. 112 113 The source file properties described for 114 QT4_ADD_DBUS_INTERFACE also apply here. 115 116 117:: 118 119 macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname 120 [basename] [classname]) 121 create a dbus adaptor (header and implementation file) from the xml file 122 describing the interface, and add it to the list of sources. The adaptor 123 forwards the calls to a parent class, defined in parentheader and named 124 parentclassname. The name of the generated files will be 125 <basename>adaptor.{cpp,h} where basename defaults to the basename of the 126 xml file. 127 If <classname> is provided, then it will be used as the classname of the 128 adaptor itself. 129 130 131:: 132 133 macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] OPTIONS ...) 134 generate the xml interface file from the given header. 135 If the optional argument interfacename is omitted, the name of the 136 interface file is constructed from the basename of the header with 137 the suffix .xml appended. 138 Options may be given to qdbuscpp2xml, such as those found when 139 executing "qdbuscpp2xml --help" 140 141 142:: 143 144 macro QT4_CREATE_TRANSLATION( qm_files directories ... sources ... 145 ts_files ... OPTIONS ...) 146 out: qm_files 147 in: directories sources ts_files 148 options: flags to pass to lupdate, such as -extensions to specify 149 extensions for a directory scan. 150 generates commands to create .ts (via lupdate) and .qm 151 (via lrelease) - files from directories and/or sources. The ts files are 152 created and/or updated in the source tree (unless given with full paths). 153 The qm files are generated in the build tree. 154 Updating the translations can be done by adding the qm_files 155 to the source list of your library/executable, so they are 156 always updated, or by adding a custom target to control when 157 they get updated/generated. 158 159 160:: 161 162 macro QT4_ADD_TRANSLATION( qm_files ts_files ... ) 163 out: qm_files 164 in: ts_files 165 generates commands to create .qm from .ts - files. The generated 166 filenames can be found in qm_files. The ts_files 167 must exist and are not updated in any way. 168 169 170:: 171 172 macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... [TARGET tgt]) 173 The qt4_automoc macro is obsolete. Use the CMAKE_AUTOMOC feature instead. 174 This macro is still experimental. 175 It can be used to have moc automatically handled. 176 So if you have the files foo.h and foo.cpp, and in foo.h a 177 a class uses the Q_OBJECT macro, moc has to run on it. If you don't 178 want to use QT4_WRAP_CPP() (which is reliable and mature), you can insert 179 #include "foo.moc" 180 in foo.cpp and then give foo.cpp as argument to QT4_AUTOMOC(). This will 181 scan all listed files at cmake-time for such included moc files and if it 182 finds them cause a rule to be generated to run moc at build time on the 183 accompanying header file foo.h. 184 If a source file has the SKIP_AUTOMOC property set it will be ignored by 185 this macro. 186 If the <tgt> is specified, the INTERFACE_INCLUDE_DIRECTORIES and 187 INTERFACE_COMPILE_DEFINITIONS from the <tgt> are passed to moc. 188 189 190:: 191 192 function QT4_USE_MODULES( target [link_type] modules...) 193 This function is obsolete. Use target_link_libraries with IMPORTED targets 194 instead. 195 Make <target> use the <modules> from Qt. Using a Qt module means 196 to link to the library, add the relevant include directories for the 197 module, and add the relevant compiler defines for using the module. 198 Modules are roughly equivalent to components of Qt4, so usage would be 199 something like: 200 qt4_use_modules(myexe Core Gui Declarative) 201 to use QtCore, QtGui and QtDeclarative. The optional <link_type> argument 202 can be specified as either LINK_PUBLIC or LINK_PRIVATE to specify the 203 same argument to the target_link_libraries call. 204 205 206IMPORTED Targets 207^^^^^^^^^^^^^^^^ 208 209A particular Qt library may be used by using the corresponding 210:prop_tgt:`IMPORTED` target with the :command:`target_link_libraries` 211command: 212 213.. code-block:: cmake 214 215 target_link_libraries(myexe Qt4::QtGui Qt4::QtXml) 216 217Using a target in this way causes :cmake(1)` to use the appropriate include 218directories and compile definitions for the target when compiling ``myexe``. 219 220Targets are aware of their dependencies, so for example it is not necessary 221to list ``Qt4::QtCore`` if another Qt library is listed, and it is not 222necessary to list ``Qt4::QtGui`` if ``Qt4::QtDeclarative`` is listed. 223Targets may be tested for existence in the usual way with the 224:command:`if(TARGET)` command. 225 226The Qt toolkit may contain both debug and release libraries. 227:manual:`cmake(1)` will choose the appropriate version based on the build 228configuration. 229 230``Qt4::QtCore`` 231 The QtCore target 232``Qt4::QtGui`` 233 The QtGui target 234``Qt4::Qt3Support`` 235 The Qt3Support target 236``Qt4::QtAssistant`` 237 The QtAssistant target 238``Qt4::QtAssistantClient`` 239 The QtAssistantClient target 240``Qt4::QAxContainer`` 241 The QAxContainer target (Windows only) 242``Qt4::QAxServer`` 243 The QAxServer target (Windows only) 244``Qt4::QtDBus`` 245 The QtDBus target 246``Qt4::QtDeclarative`` 247 The QtDeclarative target 248``Qt4::QtDesigner`` 249 The QtDesigner target 250``Qt4::QtDesignerComponents`` 251 The QtDesignerComponents target 252``Qt4::QtHelp`` 253 The QtHelp target 254``Qt4::QtMotif`` 255 The QtMotif target 256``Qt4::QtMultimedia`` 257 The QtMultimedia target 258``Qt4::QtNetwork`` 259 The QtNetwork target 260``Qt4::QtNsPLugin`` 261 The QtNsPLugin target 262``Qt4::QtOpenGL`` 263 The QtOpenGL target 264``Qt4::QtScript`` 265 The QtScript target 266``Qt4::QtScriptTools`` 267 The QtScriptTools target 268``Qt4::QtSql`` 269 The QtSql target 270``Qt4::QtSvg`` 271 The QtSvg target 272``Qt4::QtTest`` 273 The QtTest target 274``Qt4::QtUiTools`` 275 The QtUiTools target 276``Qt4::QtWebKit`` 277 The QtWebKit target 278``Qt4::QtXml`` 279 The QtXml target 280``Qt4::QtXmlPatterns`` 281 The QtXmlPatterns target 282``Qt4::phonon`` 283 The phonon target 284 285Result Variables 286^^^^^^^^^^^^^^^^ 287 288 Below is a detailed list of variables that FindQt4.cmake sets. 289 290``Qt4_FOUND`` 291 If false, don't try to use Qt 4. 292``QT_FOUND`` 293 If false, don't try to use Qt. This variable is for compatibility only. 294``QT4_FOUND`` 295 If false, don't try to use Qt 4. This variable is for compatibility only. 296``QT_VERSION_MAJOR`` 297 The major version of Qt found. 298``QT_VERSION_MINOR`` 299 The minor version of Qt found. 300``QT_VERSION_PATCH`` 301 The patch version of Qt found. 302#]=======================================================================] 303 304# Use find_package( Qt4 COMPONENTS ... ) to enable modules 305if( Qt4_FIND_COMPONENTS ) 306 foreach( component ${Qt4_FIND_COMPONENTS} ) 307 string( TOUPPER ${component} _COMPONENT ) 308 set( QT_USE_${_COMPONENT} 1 ) 309 endforeach() 310 311 # To make sure we don't use QtCore or QtGui when not in COMPONENTS 312 if(NOT QT_USE_QTCORE) 313 set( QT_DONT_USE_QTCORE 1 ) 314 endif() 315 316 if(NOT QT_USE_QTGUI) 317 set( QT_DONT_USE_QTGUI 1 ) 318 endif() 319 320endif() 321 322# If Qt3 has already been found, fail. 323if(QT_QT_LIBRARY) 324 if(Qt4_FIND_REQUIRED) 325 message( FATAL_ERROR "Qt3 and Qt4 cannot be used together in one project. If switching to Qt4, the CMakeCache.txt needs to be cleaned.") 326 else() 327 if(NOT Qt4_FIND_QUIETLY) 328 message( STATUS "Qt3 and Qt4 cannot be used together in one project. If switching to Qt4, the CMakeCache.txt needs to be cleaned.") 329 endif() 330 return() 331 endif() 332endif() 333 334 335include(${CMAKE_CURRENT_LIST_DIR}/CheckCXXSymbolExists.cmake) 336include(${CMAKE_CURRENT_LIST_DIR}/MacroAddFileDependencies.cmake) 337include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) 338include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) 339 340set(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake) 341 342set( QT_DEFINITIONS "") 343 344# convenience macro for dealing with debug/release library names 345macro (_QT4_ADJUST_LIB_VARS _camelCaseBasename) 346 347 string(TOUPPER "${_camelCaseBasename}" basename) 348 349 # The name of the imported targets, i.e. the prefix "Qt4::" must not change, 350 # since it is stored in EXPORT-files as name of a required library. If the name would change 351 # here, this would lead to the imported Qt4-library targets not being resolved by cmake anymore. 352 if (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) 353 354 if(NOT TARGET Qt4::${_camelCaseBasename}) 355 add_library(Qt4::${_camelCaseBasename} UNKNOWN IMPORTED ) 356 357 if (QT_${basename}_LIBRARY_RELEASE) 358 set_property(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 359 set(_location "${QT_${basename}_LIBRARY_RELEASE}") 360 if(QT_USE_FRAMEWORKS AND EXISTS ${_location}/${_camelCaseBasename}) 361 set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_RELEASE "${_location}/${_camelCaseBasename}" ) 362 else() 363 set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_RELEASE "${_location}" ) 364 endif() 365 endif () 366 367 if (QT_${basename}_LIBRARY_DEBUG) 368 set_property(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) 369 set(_location "${QT_${basename}_LIBRARY_DEBUG}") 370 if(QT_USE_FRAMEWORKS AND EXISTS ${_location}/${_camelCaseBasename}) 371 set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_DEBUG "${_location}/${_camelCaseBasename}" ) 372 else() 373 set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_DEBUG "${_location}" ) 374 endif() 375 endif () 376 set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY 377 INTERFACE_INCLUDE_DIRECTORIES 378 "${QT_${basename}_INCLUDE_DIR}" 379 ) 380 string(REGEX REPLACE "^QT" "" _stemname ${basename}) 381 set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY 382 INTERFACE_COMPILE_DEFINITIONS 383 "QT_${_stemname}_LIB" 384 ) 385 endif() 386 387 # If QT_USE_IMPORTED_TARGETS is enabled, the QT_QTFOO_LIBRARY variables are set to point at these 388 # imported targets. This works better in general, and is also in almost all cases fully 389 # backward compatible. The only issue is when a project A which had this enabled then exports its 390 # libraries via export or export_library_dependencies(). In this case the libraries from project 391 # A will depend on the imported Qt targets, and the names of these imported targets will be stored 392 # in the dependency files on disk. This means when a project B then uses project A, these imported 393 # targets must be created again, otherwise e.g. "Qt4__QtCore" will be interpreted as name of a 394 # library file on disk, and not as a target, and linking will fail: 395 if(QT_USE_IMPORTED_TARGETS) 396 set(QT_${basename}_LIBRARY Qt4::${_camelCaseBasename} ) 397 set(QT_${basename}_LIBRARIES Qt4::${_camelCaseBasename} ) 398 else() 399 400 # if the release- as well as the debug-version of the library have been found: 401 if (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) 402 # if the generator is multi-config or if CMAKE_BUILD_TYPE is set for 403 # single-config generators, set optimized and debug libraries 404 get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 405 if(_isMultiConfig OR CMAKE_BUILD_TYPE) 406 set(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) 407 else() 408 # For single-config generators where CMAKE_BUILD_TYPE has no value, 409 # just use the release libraries 410 set(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE} ) 411 endif() 412 set(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) 413 endif () 414 415 # if only the release version was found, set the debug variable also to the release version 416 if (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) 417 set(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE}) 418 set(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE}) 419 set(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_RELEASE}) 420 endif () 421 422 # if only the debug version was found, set the release variable also to the debug version 423 if (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) 424 set(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG}) 425 set(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG}) 426 set(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_DEBUG}) 427 endif () 428 429 # put the value in the cache: 430 set(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE STRING "The Qt ${basename} library" FORCE) 431 432 endif() 433 434 set(QT_${basename}_FOUND 1) 435 436 else () 437 438 set(QT_${basename}_LIBRARY "" CACHE STRING "The Qt ${basename} library" FORCE) 439 440 endif () 441 442 if (QT_${basename}_INCLUDE_DIR) 443 #add the include directory to QT_INCLUDES 444 set(QT_INCLUDES "${QT_${basename}_INCLUDE_DIR}" ${QT_INCLUDES}) 445 endif () 446 447 # Make variables changeable to the advanced user 448 mark_as_advanced(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR) 449endmacro () 450 451function(_QT4_QUERY_QMAKE VAR RESULT) 452 execute_process(COMMAND "${QT_QMAKE_EXECUTABLE}" -query ${VAR} 453 RESULT_VARIABLE return_code 454 OUTPUT_VARIABLE output 455 OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE) 456 if(NOT return_code) 457 file(TO_CMAKE_PATH "${output}" output) 458 set(${RESULT} ${output} PARENT_SCOPE) 459 endif() 460endfunction() 461 462function(_QT4_GET_VERSION_COMPONENTS VERSION RESULT_MAJOR RESULT_MINOR RESULT_PATCH) 463 string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" QT_VERSION_MAJOR "${QTVERSION}") 464 string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" QT_VERSION_MINOR "${QTVERSION}") 465 string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" QT_VERSION_PATCH "${QTVERSION}") 466 467 set(${RESULT_MAJOR} ${QT_VERSION_MAJOR} PARENT_SCOPE) 468 set(${RESULT_MINOR} ${QT_VERSION_MINOR} PARENT_SCOPE) 469 set(${RESULT_PATCH} ${QT_VERSION_PATCH} PARENT_SCOPE) 470endfunction() 471 472function(_QT4_FIND_QMAKE QMAKE_NAMES QMAKE_RESULT VERSION_RESULT) 473 list(LENGTH QMAKE_NAMES QMAKE_NAMES_LEN) 474 if(${QMAKE_NAMES_LEN} EQUAL 0) 475 return() 476 endif() 477 list(GET QMAKE_NAMES 0 QMAKE_NAME) 478 479 get_filename_component(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME) 480 481 find_program(QT_QMAKE_EXECUTABLE NAMES ${QMAKE_NAME} 482 PATHS 483 ENV QTDIR 484 "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]" 485 PATH_SUFFIXES bin 486 DOC "The qmake executable for the Qt installation to use" 487 ) 488 489 set(major 0) 490 if (QT_QMAKE_EXECUTABLE) 491 _qt4_query_qmake(QT_VERSION QTVERSION) 492 _qt4_get_version_components("${QTVERSION}" major minor patch) 493 endif() 494 495 if (NOT QT_QMAKE_EXECUTABLE OR NOT "${major}" EQUAL 4) 496 set(curr_qmake "${QT_QMAKE_EXECUTABLE}") 497 set(curr_qt_version "${QTVERSION}") 498 499 set(QT_QMAKE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE) 500 list(REMOVE_AT QMAKE_NAMES 0) 501 _qt4_find_qmake("${QMAKE_NAMES}" QMAKE QTVERSION) 502 503 _qt4_get_version_components("${QTVERSION}" major minor patch) 504 if (NOT ${major} EQUAL 4) 505 # Restore possibly found qmake and it's version; these are used later 506 # in error message if incorrect version is found 507 set(QT_QMAKE_EXECUTABLE "${curr_qmake}" CACHE FILEPATH "" FORCE) 508 set(QTVERSION "${curr_qt_version}") 509 endif() 510 511 endif() 512 513 514 set(${QMAKE_RESULT} "${QT_QMAKE_EXECUTABLE}" PARENT_SCOPE) 515 set(${VERSION_RESULT} "${QTVERSION}" PARENT_SCOPE) 516endfunction() 517 518 519set(QT4_INSTALLED_VERSION_TOO_OLD FALSE) 520 521set(_QT4_QMAKE_NAMES qmake qmake4 qmake-qt4 qmake-mac) 522_qt4_find_qmake("${_QT4_QMAKE_NAMES}" QT_QMAKE_EXECUTABLE QTVERSION) 523 524if (QT_QMAKE_EXECUTABLE AND 525 QTVERSION VERSION_GREATER 3 AND QTVERSION VERSION_LESS 5) 526 527 if (Qt5Core_FOUND) 528 # Qt5CoreConfig sets QT_MOC_EXECUTABLE as a non-cache variable to the Qt 5 529 # path to moc. Unset that variable when Qt 4 and 5 are used together, so 530 # that when find_program looks for moc, it is not set to the Qt 5 version. 531 # If FindQt4 has already put the Qt 4 path in the cache, the unset() 532 # command 'unhides' the (correct) cache variable. 533 unset(QT_MOC_EXECUTABLE) 534 endif() 535 if (QT_QMAKE_EXECUTABLE_LAST) 536 string(COMPARE NOTEQUAL "${QT_QMAKE_EXECUTABLE_LAST}" "${QT_QMAKE_EXECUTABLE}" QT_QMAKE_CHANGED) 537 endif() 538 set(QT_QMAKE_EXECUTABLE_LAST "${QT_QMAKE_EXECUTABLE}" CACHE INTERNAL "" FORCE) 539 540 _qt4_get_version_components("${QTVERSION}" QT_VERSION_MAJOR QT_VERSION_MINOR QT_VERSION_PATCH) 541 542 # ask qmake for the mkspecs directory 543 # we do this first because QT_LIBINFIX might be set 544 if (NOT QT_MKSPECS_DIR OR QT_QMAKE_CHANGED) 545 _qt4_query_qmake(QMAKE_MKSPECS qt_mkspecs_dirs) 546 # do not replace : on windows as it might be a drive letter 547 # and windows should already use ; as a separator 548 if(NOT WIN32) 549 string(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}") 550 endif() 551 552 find_path(QT_MKSPECS_DIR NAMES qconfig.pri 553 HINTS ${qt_mkspecs_dirs} 554 PATH_SUFFIXES mkspecs share/qt4/mkspecs 555 DOC "The location of the Qt mkspecs containing qconfig.pri") 556 endif() 557 558 if(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") 559 file(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents) 560 string(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG "${_qconfig_FILE_contents}") 561 string(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG "${_qconfig_FILE_contents}") 562 string(REGEX MATCH "EDITION[^\n]+" QT_EDITION "${_qconfig_FILE_contents}") 563 string(REGEX MATCH "QT_LIBINFIX[^\n]+" _qconfig_qt_libinfix "${_qconfig_FILE_contents}") 564 string(REGEX REPLACE "QT_LIBINFIX *= *([^\n]*)" "\\1" QT_LIBINFIX "${_qconfig_qt_libinfix}") 565 endif() 566 if("${QT_EDITION}" MATCHES "DesktopLight") 567 set(QT_EDITION_DESKTOPLIGHT 1) 568 endif() 569 570 # ask qmake for the library dir as a hint, then search for QtCore library and use that as a reference for finding the 571 # others and for setting QT_LIBRARY_DIR 572 if (NOT (QT_QTCORE_LIBRARY_RELEASE OR QT_QTCORE_LIBRARY_DEBUG) OR QT_QMAKE_CHANGED) 573 _qt4_query_qmake(QT_INSTALL_LIBS QT_LIBRARY_DIR_TMP) 574 set(QT_QTCORE_LIBRARY_RELEASE NOTFOUND) 575 set(QT_QTCORE_LIBRARY_DEBUG NOTFOUND) 576 find_library(QT_QTCORE_LIBRARY_RELEASE 577 NAMES QtCore${QT_LIBINFIX} QtCore${QT_LIBINFIX}4 578 HINTS ${QT_LIBRARY_DIR_TMP} 579 NO_DEFAULT_PATH 580 ) 581 find_library(QT_QTCORE_LIBRARY_DEBUG 582 NAMES QtCore${QT_LIBINFIX}_debug QtCore${QT_LIBINFIX}d QtCore${QT_LIBINFIX}d4 583 HINTS ${QT_LIBRARY_DIR_TMP} 584 NO_DEFAULT_PATH 585 ) 586 587 if(NOT QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCORE_LIBRARY_DEBUG) 588 find_library(QT_QTCORE_LIBRARY_RELEASE 589 NAMES QtCore${QT_LIBINFIX} QtCore${QT_LIBINFIX}4 590 HINTS ${QT_LIBRARY_DIR_TMP} 591 ) 592 find_library(QT_QTCORE_LIBRARY_DEBUG 593 NAMES QtCore${QT_LIBINFIX}_debug QtCore${QT_LIBINFIX}d QtCore${QT_LIBINFIX}d4 594 HINTS ${QT_LIBRARY_DIR_TMP} 595 ) 596 endif() 597 598 # try dropping a hint if trying to use Visual Studio with Qt built by MinGW 599 if(NOT QT_QTCORE_LIBRARY_RELEASE AND MSVC) 600 if(EXISTS ${QT_LIBRARY_DIR_TMP}/libqtmain.a) 601 message( FATAL_ERROR "It appears you're trying to use Visual Studio with Qt built by MinGW. Those compilers do not produce code compatible with each other.") 602 endif() 603 endif() 604 605 endif () 606 607 # set QT_LIBRARY_DIR based on location of QtCore found. 608 if(QT_QTCORE_LIBRARY_RELEASE) 609 get_filename_component(QT_LIBRARY_DIR_TMP "${QT_QTCORE_LIBRARY_RELEASE}" PATH) 610 set(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE) 611 set(QT_QTCORE_FOUND 1) 612 elseif(QT_QTCORE_LIBRARY_DEBUG) 613 get_filename_component(QT_LIBRARY_DIR_TMP "${QT_QTCORE_LIBRARY_DEBUG}" PATH) 614 set(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE) 615 set(QT_QTCORE_FOUND 1) 616 else() 617 if(NOT Qt4_FIND_QUIETLY) 618 message(WARNING 619 "${QT_QMAKE_EXECUTABLE} reported QT_INSTALL_LIBS as " 620 "\"${QT_LIBRARY_DIR_TMP}\" " 621 "but QtCore could not be found there. " 622 "Qt is NOT installed correctly for the target build environment.") 623 endif() 624 set(Qt4_FOUND FALSE) 625 if(Qt4_FIND_REQUIRED) 626 message( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.") 627 else() 628 return() 629 endif() 630 endif() 631 632 # ask qmake for the binary dir 633 if (NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED) 634 _qt4_query_qmake(QT_INSTALL_BINS qt_bins) 635 set(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "" FORCE) 636 endif () 637 638 if (APPLE) 639 set(CMAKE_FIND_FRAMEWORK_OLD ${CMAKE_FIND_FRAMEWORK}) 640 if (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) 641 set(QT_USE_FRAMEWORKS ON CACHE INTERNAL "" FORCE) 642 set(CMAKE_FIND_FRAMEWORK FIRST) 643 else () 644 set(QT_USE_FRAMEWORKS OFF CACHE INTERNAL "" FORCE) 645 set(CMAKE_FIND_FRAMEWORK LAST) 646 endif () 647 endif () 648 649 # ask qmake for the include dir 650 if (QT_LIBRARY_DIR AND (NOT QT_QTCORE_INCLUDE_DIR OR NOT QT_HEADERS_DIR OR QT_QMAKE_CHANGED)) 651 _qt4_query_qmake(QT_INSTALL_HEADERS qt_headers) 652 set(QT_QTCORE_INCLUDE_DIR NOTFOUND) 653 find_path(QT_QTCORE_INCLUDE_DIR QtCore 654 HINTS ${qt_headers} ${QT_LIBRARY_DIR} 655 PATH_SUFFIXES QtCore qt4/QtCore 656 NO_DEFAULT_PATH 657 ) 658 if(NOT QT_QTCORE_INCLUDE_DIR) 659 find_path(QT_QTCORE_INCLUDE_DIR QtCore 660 HINTS ${qt_headers} ${QT_LIBRARY_DIR} 661 PATH_SUFFIXES QtCore qt4/QtCore 662 ) 663 endif() 664 665 # Set QT_HEADERS_DIR based on finding QtCore header 666 if(QT_QTCORE_INCLUDE_DIR) 667 if(QT_USE_FRAMEWORKS) 668 set(QT_HEADERS_DIR "${qt_headers}" CACHE INTERNAL "" FORCE) 669 else() 670 get_filename_component(qt_headers "${QT_QTCORE_INCLUDE_DIR}/../" ABSOLUTE) 671 set(QT_HEADERS_DIR "${qt_headers}" CACHE INTERNAL "" FORCE) 672 endif() 673 else() 674 message("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_HEADERS as ${qt_headers}") 675 message("Warning: But QtCore couldn't be found. Qt must NOT be installed correctly.") 676 endif() 677 endif() 678 679 if(APPLE) 680 set(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_OLD}) 681 endif() 682 683 # Set QT_INCLUDE_DIR based on QT_HEADERS_DIR 684 if(QT_HEADERS_DIR) 685 if(QT_USE_FRAMEWORKS) 686 # Qt/Mac frameworks has two include dirs. 687 # One is the framework include for which CMake will add a -F flag 688 # and the other is an include dir for non-framework Qt modules 689 set(QT_INCLUDE_DIR ${QT_HEADERS_DIR} ${QT_QTCORE_LIBRARY_RELEASE} ) 690 else() 691 set(QT_INCLUDE_DIR ${QT_HEADERS_DIR}) 692 endif() 693 endif() 694 695 # Set QT_INCLUDES 696 set( QT_INCLUDES ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR}) 697 698 699 # ask qmake for the documentation directory 700 if (QT_LIBRARY_DIR AND NOT QT_DOC_DIR OR QT_QMAKE_CHANGED) 701 _qt4_query_qmake(QT_INSTALL_DOCS qt_doc_dir) 702 set(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs" FORCE) 703 endif () 704 705 706 # ask qmake for the plugins directory 707 if (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR OR QT_QMAKE_CHANGED) 708 _qt4_query_qmake(QT_INSTALL_PLUGINS qt_plugins_dir) 709 if(CMAKE_CROSSCOMPILING OR NOT qt_plugins_dir) 710 find_path(QT_PLUGINS_DIR 711 NAMES accessible bearer codecs designer graphicssystems iconengines imageformats inputmethods qmltooling script sqldrivers 712 HINTS ${qt_plugins_dir} 713 PATH_SUFFIXES plugins lib/qt4/plugins 714 DOC "The location of the Qt plugins") 715 else() 716 set(QT_PLUGINS_DIR ${qt_plugins_dir} CACHE PATH "The location of the Qt plugins") 717 endif() 718 endif () 719 720 # ask qmake for the translations directory 721 if (QT_LIBRARY_DIR AND NOT QT_TRANSLATIONS_DIR OR QT_QMAKE_CHANGED) 722 _qt4_query_qmake(QT_INSTALL_TRANSLATIONS qt_translations_dir) 723 set(QT_TRANSLATIONS_DIR ${qt_translations_dir} CACHE PATH "The location of the Qt translations" FORCE) 724 endif () 725 726 # ask qmake for the imports directory 727 if (QT_LIBRARY_DIR AND NOT QT_IMPORTS_DIR OR QT_QMAKE_CHANGED) 728 _qt4_query_qmake(QT_INSTALL_IMPORTS qt_imports_dir) 729 if(CMAKE_CROSSCOMPILING OR NOT qt_imports_dir) 730 find_path(QT_IMPORTS_DIR NAMES Qt 731 HINTS ${qt_imports_dir} 732 PATH_SUFFIXES imports lib/qt4/imports 733 DOC "The location of the Qt imports") 734 else() 735 set(QT_IMPORTS_DIR ${qt_imports_dir} CACHE PATH "The location of the Qt imports") 736 endif() 737 endif () 738 739 # Make variables changeable to the advanced user 740 mark_as_advanced( QT_LIBRARY_DIR QT_DOC_DIR QT_MKSPECS_DIR 741 QT_PLUGINS_DIR QT_TRANSLATIONS_DIR) 742 743 744 745 746 ############################################# 747 # 748 # Find out what window system we're using 749 # 750 ############################################# 751 cmake_push_check_state() 752 # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES 753 list(APPEND CMAKE_REQUIRED_INCLUDES "${QT_INCLUDE_DIR}") 754 set(CMAKE_REQUIRED_QUIET ${Qt4_FIND_QUIETLY}) 755 # Check for Window system symbols (note: only one should end up being set) 756 CHECK_CXX_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11) 757 CHECK_CXX_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN) 758 CHECK_CXX_SYMBOL_EXISTS(Q_WS_QWS "QtCore/qglobal.h" Q_WS_QWS) 759 CHECK_CXX_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC) 760 if(Q_WS_MAC) 761 if(QT_QMAKE_CHANGED) 762 unset(QT_MAC_USE_COCOA CACHE) 763 endif() 764 CHECK_CXX_SYMBOL_EXISTS(QT_MAC_USE_COCOA "QtCore/qconfig.h" QT_MAC_USE_COCOA) 765 endif() 766 767 if (QT_QTCOPY_REQUIRED) 768 CHECK_CXX_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY) 769 if (NOT QT_IS_QTCOPY) 770 message(FATAL_ERROR "qt-copy is required, but hasn't been found") 771 endif () 772 endif () 773 774 cmake_pop_check_state() 775 # 776 ############################################# 777 778 779 780 ######################################## 781 # 782 # Setting the INCLUDE-Variables 783 # 784 ######################################## 785 786 set(QT_MODULES QtGui Qt3Support QtSvg QtScript QtTest QtUiTools 787 QtHelp QtWebKit QtXmlPatterns phonon QtNetwork QtMultimedia 788 QtNsPlugin QtOpenGL QtSql QtXml QtDesigner QtDBus QtScriptTools 789 QtDeclarative) 790 791 if(Q_WS_X11) 792 set(QT_MODULES ${QT_MODULES} QtMotif) 793 endif() 794 795 if(QT_QMAKE_CHANGED) 796 foreach(QT_MODULE ${QT_MODULES}) 797 string(TOUPPER ${QT_MODULE} _upper_qt_module) 798 set(QT_${_upper_qt_module}_INCLUDE_DIR NOTFOUND) 799 set(QT_${_upper_qt_module}_LIBRARY_RELEASE NOTFOUND) 800 set(QT_${_upper_qt_module}_LIBRARY_DEBUG NOTFOUND) 801 endforeach() 802 set(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR NOTFOUND) 803 set(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NOTFOUND) 804 set(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NOTFOUND) 805 set(QT_QTASSISTANTCLIENT_INCLUDE_DIR NOTFOUND) 806 set(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NOTFOUND) 807 set(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NOTFOUND) 808 set(QT_QTASSISTANT_INCLUDE_DIR NOTFOUND) 809 set(QT_QTASSISTANT_LIBRARY_RELEASE NOTFOUND) 810 set(QT_QTASSISTANT_LIBRARY_DEBUG NOTFOUND) 811 set(QT_QTCLUCENE_LIBRARY_RELEASE NOTFOUND) 812 set(QT_QTCLUCENE_LIBRARY_DEBUG NOTFOUND) 813 set(QT_QAXCONTAINER_INCLUDE_DIR NOTFOUND) 814 set(QT_QAXCONTAINER_LIBRARY_RELEASE NOTFOUND) 815 set(QT_QAXCONTAINER_LIBRARY_DEBUG NOTFOUND) 816 set(QT_QAXSERVER_INCLUDE_DIR NOTFOUND) 817 set(QT_QAXSERVER_LIBRARY_RELEASE NOTFOUND) 818 set(QT_QAXSERVER_LIBRARY_DEBUG NOTFOUND) 819 if(Q_WS_WIN) 820 set(QT_QTMAIN_LIBRARY_DEBUG NOTFOUND) 821 set(QT_QTMAIN_LIBRARY_RELEASE NOTFOUND) 822 endif() 823 endif() 824 825 foreach(QT_MODULE ${QT_MODULES}) 826 string(TOUPPER ${QT_MODULE} _upper_qt_module) 827 find_path(QT_${_upper_qt_module}_INCLUDE_DIR ${QT_MODULE} 828 PATHS 829 ${QT_HEADERS_DIR}/${QT_MODULE} 830 ${QT_LIBRARY_DIR}/${QT_MODULE}.framework/Headers 831 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH 832 ) 833 # phonon doesn't seem consistent, let's try phonondefs.h for some 834 # installations 835 if(${QT_MODULE} STREQUAL "phonon") 836 find_path(QT_${_upper_qt_module}_INCLUDE_DIR phonondefs.h 837 PATHS 838 ${QT_HEADERS_DIR}/${QT_MODULE} 839 ${QT_LIBRARY_DIR}/${QT_MODULE}.framework/Headers 840 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH 841 ) 842 endif() 843 endforeach() 844 845 if(Q_WS_WIN) 846 set(QT_MODULES ${QT_MODULES} QAxContainer QAxServer) 847 # Set QT_AXCONTAINER_INCLUDE_DIR and QT_AXSERVER_INCLUDE_DIR 848 find_path(QT_QAXCONTAINER_INCLUDE_DIR ActiveQt 849 PATHS ${QT_HEADERS_DIR}/ActiveQt 850 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH 851 ) 852 find_path(QT_QAXSERVER_INCLUDE_DIR ActiveQt 853 PATHS ${QT_HEADERS_DIR}/ActiveQt 854 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH 855 ) 856 endif() 857 858 # Set QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR 859 find_path(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR QDesignerComponents 860 PATHS 861 ${QT_HEADERS_DIR}/QtDesigner 862 ${QT_LIBRARY_DIR}/QtDesigner.framework/Headers 863 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH 864 ) 865 866 # Set QT_QTASSISTANT_INCLUDE_DIR 867 find_path(QT_QTASSISTANT_INCLUDE_DIR QtAssistant 868 PATHS 869 ${QT_HEADERS_DIR}/QtAssistant 870 ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers 871 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH 872 ) 873 874 # Set QT_QTASSISTANTCLIENT_INCLUDE_DIR 875 find_path(QT_QTASSISTANTCLIENT_INCLUDE_DIR QAssistantClient 876 PATHS 877 ${QT_HEADERS_DIR}/QtAssistant 878 ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers 879 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH 880 ) 881 882 ######################################## 883 # 884 # Setting the LIBRARY-Variables 885 # 886 ######################################## 887 888 # find the libraries 889 foreach(QT_MODULE ${QT_MODULES}) 890 string(TOUPPER ${QT_MODULE} _upper_qt_module) 891 find_library(QT_${_upper_qt_module}_LIBRARY_RELEASE 892 NAMES ${QT_MODULE}${QT_LIBINFIX} ${QT_MODULE}${QT_LIBINFIX}4 893 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH 894 ) 895 find_library(QT_${_upper_qt_module}_LIBRARY_DEBUG 896 NAMES ${QT_MODULE}${QT_LIBINFIX}_debug ${QT_MODULE}${QT_LIBINFIX}d ${QT_MODULE}${QT_LIBINFIX}d4 897 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH 898 ) 899 if(QT_${_upper_qt_module}_LIBRARY_RELEASE MATCHES "/${QT_MODULE}\\.framework$") 900 if(NOT EXISTS "${QT_${_upper_qt_module}_LIBRARY_RELEASE}/${QT_MODULE}") 901 # Release framework library file does not exist... Force to NOTFOUND: 902 set(QT_${_upper_qt_module}_LIBRARY_RELEASE "QT_${_upper_qt_module}_LIBRARY_RELEASE-NOTFOUND" CACHE FILEPATH "Path to a library." FORCE) 903 endif() 904 endif() 905 if(QT_${_upper_qt_module}_LIBRARY_DEBUG MATCHES "/${QT_MODULE}\\.framework$") 906 if(NOT EXISTS "${QT_${_upper_qt_module}_LIBRARY_DEBUG}/${QT_MODULE}") 907 # Debug framework library file does not exist... Force to NOTFOUND: 908 set(QT_${_upper_qt_module}_LIBRARY_DEBUG "QT_${_upper_qt_module}_LIBRARY_DEBUG-NOTFOUND" CACHE FILEPATH "Path to a library." FORCE) 909 endif() 910 endif() 911 endforeach() 912 913 # QtUiTools is sometimes not in the same directory as the other found libraries 914 # e.g. on Mac, its never a framework like the others are 915 if(QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE) 916 find_library(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR}) 917 endif() 918 919 # Set QT_QTDESIGNERCOMPONENTS_LIBRARY 920 find_library(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents${QT_LIBINFIX} QtDesignerComponents${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) 921 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 NO_CMAKE_FIND_ROOT_PATH) 922 923 # Set QT_QTMAIN_LIBRARY 924 if(Q_WS_WIN) 925 find_library(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) 926 find_library(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmain${QT_LIBINFIX}d PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) 927 endif() 928 929 # Set QT_QTASSISTANTCLIENT_LIBRARY 930 find_library(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) 931 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 NO_CMAKE_FIND_ROOT_PATH) 932 933 # Set QT_QTASSISTANT_LIBRARY 934 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 NO_CMAKE_FIND_ROOT_PATH) 935 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 NO_CMAKE_FIND_ROOT_PATH) 936 937 # Set QT_QTHELP_LIBRARY 938 find_library(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} QtCLucene${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) 939 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 NO_CMAKE_FIND_ROOT_PATH) 940 if(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE) 941 find_library(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR}) 942 endif() 943 944 945 ############################################ 946 # 947 # Check the existence of the libraries. 948 # 949 ############################################ 950 951 952 macro(_qt4_add_target_depends_internal _QT_MODULE _PROPERTY) 953 if (TARGET Qt4::${_QT_MODULE}) 954 foreach(_DEPEND ${ARGN}) 955 set(_VALID_DEPENDS) 956 if (TARGET Qt4::Qt${_DEPEND}) 957 list(APPEND _VALID_DEPENDS Qt4::Qt${_DEPEND}) 958 endif() 959 if (_VALID_DEPENDS) 960 set_property(TARGET Qt4::${_QT_MODULE} APPEND PROPERTY 961 ${_PROPERTY} 962 "${_VALID_DEPENDS}" 963 ) 964 endif() 965 set(_VALID_DEPENDS) 966 endforeach() 967 endif() 968 endmacro() 969 970 macro(_qt4_add_target_depends _QT_MODULE) 971 if (TARGET Qt4::${_QT_MODULE}) 972 get_target_property(_configs Qt4::${_QT_MODULE} IMPORTED_CONFIGURATIONS) 973 _qt4_add_target_depends_internal(${_QT_MODULE} INTERFACE_LINK_LIBRARIES ${ARGN}) 974 foreach(_config ${_configs}) 975 _qt4_add_target_depends_internal(${_QT_MODULE} IMPORTED_LINK_INTERFACE_LIBRARIES_${_config} ${ARGN}) 976 endforeach() 977 set(_configs) 978 endif() 979 endmacro() 980 981 macro(_qt4_add_target_private_depends _QT_MODULE) 982 if (TARGET Qt4::${_QT_MODULE}) 983 get_target_property(_configs Qt4::${_QT_MODULE} IMPORTED_CONFIGURATIONS) 984 foreach(_config ${_configs}) 985 _qt4_add_target_depends_internal(${_QT_MODULE} IMPORTED_LINK_DEPENDENT_LIBRARIES_${_config} ${ARGN}) 986 endforeach() 987 set(_configs) 988 endif() 989 endmacro() 990 991 992 # Set QT_xyz_LIBRARY variable and add 993 # library include path to QT_INCLUDES 994 _QT4_ADJUST_LIB_VARS(QtCore) 995 set_property(TARGET Qt4::QtCore APPEND PROPERTY 996 INTERFACE_INCLUDE_DIRECTORIES 997 "${QT_MKSPECS_DIR}/default" 998 ${QT_INCLUDE_DIR} 999 ) 1000 set_property(TARGET Qt4::QtCore APPEND PROPERTY 1001 INTERFACE_COMPILE_DEFINITIONS 1002 $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG> 1003 ) 1004 set_property(TARGET Qt4::QtCore PROPERTY 1005 INTERFACE_QT_MAJOR_VERSION 4 1006 ) 1007 set_property(TARGET Qt4::QtCore APPEND PROPERTY 1008 COMPATIBLE_INTERFACE_STRING QT_MAJOR_VERSION 1009 ) 1010 1011 foreach(QT_MODULE ${QT_MODULES}) 1012 _QT4_ADJUST_LIB_VARS(${QT_MODULE}) 1013 _qt4_add_target_depends(${QT_MODULE} Core) 1014 endforeach() 1015 1016 _QT4_ADJUST_LIB_VARS(QtAssistant) 1017 _QT4_ADJUST_LIB_VARS(QtAssistantClient) 1018 _QT4_ADJUST_LIB_VARS(QtCLucene) 1019 _QT4_ADJUST_LIB_VARS(QtDesignerComponents) 1020 1021 # platform dependent libraries 1022 if(Q_WS_WIN) 1023 _QT4_ADJUST_LIB_VARS(qtmain) 1024 1025 _QT4_ADJUST_LIB_VARS(QAxServer) 1026 if(QT_QAXSERVER_FOUND) 1027 set_property(TARGET Qt4::QAxServer PROPERTY 1028 INTERFACE_QT4_NO_LINK_QTMAIN ON 1029 ) 1030 set_property(TARGET Qt4::QAxServer APPEND PROPERTY 1031 COMPATIBLE_INTERFACE_BOOL QT4_NO_LINK_QTMAIN) 1032 endif() 1033 1034 _QT4_ADJUST_LIB_VARS(QAxContainer) 1035 endif() 1036 1037 # Only public dependencies are listed here. 1038 # Eg, QtDBus links to QtXml, but users of QtDBus do not need to 1039 # link to QtXml because QtDBus only uses it internally, not in public 1040 # headers. 1041 # Everything depends on QtCore, but that is covered above already 1042 _qt4_add_target_depends(Qt3Support Sql Gui Network) 1043 if (TARGET Qt4::Qt3Support) 1044 # An additional define is required for QT3_SUPPORT 1045 set_property(TARGET Qt4::Qt3Support APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS QT3_SUPPORT) 1046 endif() 1047 _qt4_add_target_depends(QtDeclarative Script Gui) 1048 _qt4_add_target_depends(QtDesigner Gui) 1049 _qt4_add_target_depends(QtHelp Gui) 1050 _qt4_add_target_depends(QtMultimedia Gui) 1051 _qt4_add_target_depends(QtOpenGL Gui) 1052 _qt4_add_target_depends(QtSvg Gui) 1053 _qt4_add_target_depends(QtWebKit Gui Network) 1054 1055 _qt4_add_target_private_depends(Qt3Support Xml) 1056 if(QT_VERSION VERSION_GREATER 4.6) 1057 _qt4_add_target_private_depends(QtSvg Xml) 1058 endif() 1059 _qt4_add_target_private_depends(QtDBus Xml) 1060 _qt4_add_target_private_depends(QtUiTools Xml Gui) 1061 _qt4_add_target_private_depends(QtHelp Sql Xml Network) 1062 _qt4_add_target_private_depends(QtXmlPatterns Network) 1063 _qt4_add_target_private_depends(QtScriptTools Gui) 1064 _qt4_add_target_private_depends(QtWebKit XmlPatterns) 1065 _qt4_add_target_private_depends(QtDeclarative XmlPatterns Svg Sql Gui) 1066 _qt4_add_target_private_depends(QtMultimedia Gui) 1067 _qt4_add_target_private_depends(QtOpenGL Gui) 1068 if(QT_QAXSERVER_FOUND) 1069 _qt4_add_target_private_depends(QAxServer Gui) 1070 endif() 1071 if(QT_QAXCONTAINER_FOUND) 1072 _qt4_add_target_private_depends(QAxContainer Gui) 1073 endif() 1074 _qt4_add_target_private_depends(phonon Gui) 1075 if(QT_QTDBUS_FOUND) 1076 _qt4_add_target_private_depends(phonon DBus) 1077 endif() 1078 1079 if (WIN32 AND NOT QT4_NO_LINK_QTMAIN) 1080 set(_isExe $<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>) 1081 set(_isWin32 $<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>) 1082 set(_isNotExcluded $<NOT:$<BOOL:$<TARGET_PROPERTY:QT4_NO_LINK_QTMAIN>>>) 1083 set(_isPolicyNEW $<TARGET_POLICY:CMP0020>) 1084 get_target_property(_configs Qt4::QtCore IMPORTED_CONFIGURATIONS) 1085 set_property(TARGET Qt4::QtCore APPEND PROPERTY 1086 INTERFACE_LINK_LIBRARIES 1087 $<$<AND:${_isExe},${_isWin32},${_isNotExcluded},${_isPolicyNEW}>:Qt4::qtmain> 1088 ) 1089 foreach(_config ${_configs}) 1090 set_property(TARGET Qt4::QtCore APPEND PROPERTY 1091 IMPORTED_LINK_INTERFACE_LIBRARIES_${_config} 1092 $<$<AND:${_isExe},${_isWin32},${_isNotExcluded},${_isPolicyNEW}>:Qt4::qtmain> 1093 ) 1094 endforeach() 1095 unset(_configs) 1096 unset(_isExe) 1097 unset(_isWin32) 1098 unset(_isNotExcluded) 1099 unset(_isPolicyNEW) 1100 endif() 1101 1102 ####################################### 1103 # 1104 # Check the executables of Qt 1105 # ( moc, uic, rcc ) 1106 # 1107 ####################################### 1108 1109 1110 if(QT_QMAKE_CHANGED) 1111 set(QT_UIC_EXECUTABLE NOTFOUND) 1112 set(QT_MOC_EXECUTABLE NOTFOUND) 1113 set(QT_UIC3_EXECUTABLE NOTFOUND) 1114 set(QT_RCC_EXECUTABLE NOTFOUND) 1115 set(QT_DBUSCPP2XML_EXECUTABLE NOTFOUND) 1116 set(QT_DBUSXML2CPP_EXECUTABLE NOTFOUND) 1117 set(QT_LUPDATE_EXECUTABLE NOTFOUND) 1118 set(QT_LRELEASE_EXECUTABLE NOTFOUND) 1119 set(QT_QCOLLECTIONGENERATOR_EXECUTABLE NOTFOUND) 1120 set(QT_DESIGNER_EXECUTABLE NOTFOUND) 1121 set(QT_LINGUIST_EXECUTABLE NOTFOUND) 1122 endif() 1123 1124 macro(_find_qt4_program VAR NAME) 1125 find_program(${VAR} 1126 NAMES ${ARGN} 1127 PATHS ${QT_BINARY_DIR} 1128 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH 1129 ) 1130 if (${VAR} AND NOT TARGET ${NAME}) 1131 add_executable(${NAME} IMPORTED) 1132 set_property(TARGET ${NAME} PROPERTY IMPORTED_LOCATION ${${VAR}}) 1133 endif() 1134 endmacro() 1135 1136 _find_qt4_program(QT_MOC_EXECUTABLE Qt4::moc moc-qt4 moc4 moc) 1137 _find_qt4_program(QT_UIC_EXECUTABLE Qt4::uic uic-qt4 uic4 uic) 1138 _find_qt4_program(QT_UIC3_EXECUTABLE Qt4::uic3 uic3) 1139 _find_qt4_program(QT_RCC_EXECUTABLE Qt4::rcc rcc) 1140 _find_qt4_program(QT_DBUSCPP2XML_EXECUTABLE Qt4::qdbuscpp2xml qdbuscpp2xml) 1141 _find_qt4_program(QT_DBUSXML2CPP_EXECUTABLE Qt4::qdbusxml2cpp qdbusxml2cpp) 1142 _find_qt4_program(QT_LUPDATE_EXECUTABLE Qt4::lupdate lupdate-qt4 lupdate4 lupdate) 1143 _find_qt4_program(QT_LRELEASE_EXECUTABLE Qt4::lrelease lrelease-qt4 lrelease4 lrelease) 1144 _find_qt4_program(QT_QCOLLECTIONGENERATOR_EXECUTABLE Qt4::qcollectiongenerator qcollectiongenerator-qt4 qcollectiongenerator) 1145 _find_qt4_program(QT_DESIGNER_EXECUTABLE Qt4::designer designer-qt4 designer4 designer) 1146 _find_qt4_program(QT_LINGUIST_EXECUTABLE Qt4::linguist linguist-qt4 linguist4 linguist) 1147 1148 if (NOT TARGET Qt4::qmake) 1149 add_executable(Qt4::qmake IMPORTED) 1150 set_property(TARGET Qt4::qmake PROPERTY IMPORTED_LOCATION ${QT_QMAKE_EXECUTABLE}) 1151 endif() 1152 1153 if (QT_MOC_EXECUTABLE) 1154 set(QT_WRAP_CPP "YES") 1155 endif () 1156 1157 if (QT_UIC_EXECUTABLE) 1158 set(QT_WRAP_UI "YES") 1159 endif () 1160 1161 1162 1163 mark_as_advanced( QT_UIC_EXECUTABLE QT_UIC3_EXECUTABLE QT_MOC_EXECUTABLE 1164 QT_RCC_EXECUTABLE QT_DBUSXML2CPP_EXECUTABLE QT_DBUSCPP2XML_EXECUTABLE 1165 QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE QT_QCOLLECTIONGENERATOR_EXECUTABLE 1166 QT_DESIGNER_EXECUTABLE QT_LINGUIST_EXECUTABLE) 1167 1168 1169 # get the directory of the current file, used later on in the file 1170 get_filename_component( _qt4_current_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) 1171 1172 1173 ############################################### 1174 # 1175 # configuration/system dependent settings 1176 # 1177 ############################################### 1178 1179 include("${_qt4_current_dir}/Qt4ConfigDependentSettings.cmake") 1180 1181 1182 ####################################### 1183 # 1184 # Check the plugins of Qt 1185 # 1186 ####################################### 1187 1188 set( QT_PLUGIN_TYPES accessible bearer codecs decorations designer gfxdrivers graphicssystems iconengines imageformats inputmethods mousedrivers phonon_backend script sqldrivers ) 1189 1190 set( QT_ACCESSIBLE_PLUGINS qtaccessiblecompatwidgets qtaccessiblewidgets ) 1191 set( QT_BEARER_PLUGINS qcorewlanbearer qgenericbearer qnativewifibearer ) 1192 set( QT_CODECS_PLUGINS qcncodecs qjpcodecs qkrcodecs qtwcodecs ) 1193 set( QT_DECORATIONS_PLUGINS qdecorationdefault qdecorationwindows ) 1194 set( QT_DESIGNER_PLUGINS arthurplugin containerextension customwidgetplugin phononwidgets qdeclarativeview qt3supportwidgets qwebview taskmenuextension worldtimeclockplugin ) 1195 set( QT_GRAPHICSDRIVERS_PLUGINS qgfxtransformed qgfxvnc qscreenvfb ) 1196 set( QT_GRAPHICSSYSTEMS_PLUGINS qglgraphicssystem qtracegraphicssystem ) 1197 set( QT_ICONENGINES_PLUGINS qsvgicon ) 1198 set( QT_IMAGEFORMATS_PLUGINS qgif qjpeg qmng qico qsvg qtiff qtga ) 1199 set( QT_INPUTMETHODS_PLUGINS qimsw_multi ) 1200 set( QT_MOUSEDRIVERS_PLUGINS qwstslibmousehandler ) 1201 if(APPLE) 1202 set( QT_PHONON_BACKEND_PLUGINS phonon_qt7 ) 1203 elseif(WIN32) 1204 set( QT_PHONON_BACKEND_PLUGINS phonon_ds9 ) 1205 endif() 1206 set( QT_SCRIPT_PLUGINS qtscriptdbus ) 1207 set( QT_SQLDRIVERS_PLUGINS qsqldb2 qsqlibase qsqlite qsqlite2 qsqlmysql qsqloci qsqlodbc qsqlpsql qsqltds ) 1208 1209 set( QT_PHONON_PLUGINS ${QT_PHONON_BACKEND_PLUGINS} ) 1210 set( QT_QT3SUPPORT_PLUGINS qtaccessiblecompatwidgets ) 1211 set( QT_QTCORE_PLUGINS ${QT_BEARER_PLUGINS} ${QT_CODECS_PLUGINS} ) 1212 set( QT_QTGUI_PLUGINS qtaccessiblewidgets ${QT_IMAGEFORMATS_PLUGINS} ${QT_DECORATIONS_PLUGINS} ${QT_GRAPHICSDRIVERS_PLUGINS} ${QT_GRAPHICSSYSTEMS_PLUGINS} ${QT_INPUTMETHODS_PLUGINS} ${QT_MOUSEDRIVERS_PLUGINS} ) 1213 set( QT_QTSCRIPT_PLUGINS ${QT_SCRIPT_PLUGINS} ) 1214 set( QT_QTSQL_PLUGINS ${QT_SQLDRIVERS_PLUGINS} ) 1215 set( QT_QTSVG_PLUGINS qsvg qsvgicon ) 1216 1217 if(QT_QMAKE_CHANGED) 1218 foreach(QT_PLUGIN_TYPE ${QT_PLUGIN_TYPES}) 1219 string(TOUPPER ${QT_PLUGIN_TYPE} _upper_qt_plugin_type) 1220 set(QT_${_upper_qt_plugin_type}_PLUGINS_DIR ${QT_PLUGINS_DIR}/${QT_PLUGIN_TYPE}) 1221 foreach(QT_PLUGIN ${QT_${_upper_qt_plugin_type}_PLUGINS}) 1222 string(TOUPPER ${QT_PLUGIN} _upper_qt_plugin) 1223 unset(QT_${_upper_qt_plugin}_LIBRARY_RELEASE CACHE) 1224 unset(QT_${_upper_qt_plugin}_LIBRARY_DEBUG CACHE) 1225 unset(QT_${_upper_qt_plugin}_LIBRARY CACHE) 1226 unset(QT_${_upper_qt_plugin}_PLUGIN_RELEASE CACHE) 1227 unset(QT_${_upper_qt_plugin}_PLUGIN_DEBUG CACHE) 1228 unset(QT_${_upper_qt_plugin}_PLUGIN CACHE) 1229 endforeach() 1230 endforeach() 1231 endif() 1232 1233 # find_library works better than find_file but we need to set prefixes to only match plugins 1234 foreach(QT_PLUGIN_TYPE ${QT_PLUGIN_TYPES}) 1235 string(TOUPPER ${QT_PLUGIN_TYPE} _upper_qt_plugin_type) 1236 set(QT_${_upper_qt_plugin_type}_PLUGINS_DIR ${QT_PLUGINS_DIR}/${QT_PLUGIN_TYPE}) 1237 foreach(QT_PLUGIN ${QT_${_upper_qt_plugin_type}_PLUGINS}) 1238 string(TOUPPER ${QT_PLUGIN} _upper_qt_plugin) 1239 if(QT_IS_STATIC) 1240 find_library(QT_${_upper_qt_plugin}_LIBRARY_RELEASE 1241 NAMES ${QT_PLUGIN}${QT_LIBINFIX} ${QT_PLUGIN}${QT_LIBINFIX}4 1242 PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH 1243 ) 1244 find_library(QT_${_upper_qt_plugin}_LIBRARY_DEBUG 1245 NAMES ${QT_PLUGIN}${QT_LIBINFIX}_debug ${QT_PLUGIN}${QT_LIBINFIX}d ${QT_PLUGIN}${QT_LIBINFIX}d4 1246 PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH 1247 ) 1248 _QT4_ADJUST_LIB_VARS(${QT_PLUGIN}) 1249 else() 1250 # find_library works easier/better than find_file but we need to set suffixes to only match plugins 1251 set(CMAKE_FIND_LIBRARY_SUFFIXES_DEFAULT ${CMAKE_FIND_LIBRARY_SUFFIXES}) 1252 set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_MODULE_SUFFIX} ${CMAKE_SHARED_LIBRARY_SUFFIX}) 1253 find_library(QT_${_upper_qt_plugin}_PLUGIN_RELEASE 1254 NAMES ${QT_PLUGIN}${QT_LIBINFIX} ${QT_PLUGIN}${QT_LIBINFIX}4 1255 PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH 1256 ) 1257 find_library(QT_${_upper_qt_plugin}_PLUGIN_DEBUG 1258 NAMES ${QT_PLUGIN}${QT_LIBINFIX}_debug ${QT_PLUGIN}${QT_LIBINFIX}d ${QT_PLUGIN}${QT_LIBINFIX}d4 1259 PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH 1260 ) 1261 mark_as_advanced(QT_${_upper_qt_plugin}_PLUGIN_RELEASE QT_${_upper_qt_plugin}_PLUGIN_DEBUG) 1262 set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_DEFAULT}) 1263 endif() 1264 endforeach() 1265 endforeach() 1266 1267 1268 ###################################### 1269 # 1270 # Macros for building Qt files 1271 # 1272 ###################################### 1273 1274 include("${_qt4_current_dir}/Qt4Macros.cmake") 1275 1276endif() 1277 1278#support old QT_MIN_VERSION if set, but not if version is supplied by find_package() 1279if(NOT Qt4_FIND_VERSION AND QT_MIN_VERSION) 1280 set(Qt4_FIND_VERSION ${QT_MIN_VERSION}) 1281endif() 1282 1283if( Qt4_FIND_COMPONENTS ) 1284 1285 # if components specified in find_package(), make sure each of those pieces were found 1286 set(_QT4_FOUND_REQUIRED_VARS QT_QMAKE_EXECUTABLE QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE QT_INCLUDE_DIR QT_LIBRARY_DIR) 1287 foreach( component ${Qt4_FIND_COMPONENTS} ) 1288 string( TOUPPER ${component} _COMPONENT ) 1289 if(${_COMPONENT} STREQUAL "QTMAIN") 1290 if(Q_WS_WIN) 1291 set(_QT4_FOUND_REQUIRED_VARS ${_QT4_FOUND_REQUIRED_VARS} QT_${_COMPONENT}_LIBRARY) 1292 endif() 1293 else() 1294 set(_QT4_FOUND_REQUIRED_VARS ${_QT4_FOUND_REQUIRED_VARS} QT_${_COMPONENT}_INCLUDE_DIR QT_${_COMPONENT}_LIBRARY) 1295 endif() 1296 endforeach() 1297 1298 if(Qt4_FIND_COMPONENTS MATCHES QtGui) 1299 set(_QT4_FOUND_REQUIRED_VARS ${_QT4_FOUND_REQUIRED_VARS} QT_UIC_EXECUTABLE) 1300 endif() 1301 1302else() 1303 1304 # if no components specified, we'll make a default set of required variables to say Qt is found 1305 set(_QT4_FOUND_REQUIRED_VARS QT_QMAKE_EXECUTABLE QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE QT_UIC_EXECUTABLE QT_INCLUDE_DIR 1306 QT_LIBRARY_DIR QT_QTCORE_LIBRARY) 1307 1308endif() 1309 1310if (NOT QT_VERSION_MAJOR EQUAL 4) 1311 set(VERSION_MSG "Found unsuitable Qt version \"${QTVERSION}\" from ${QT_QMAKE_EXECUTABLE}") 1312 set(Qt4_FOUND FALSE) 1313 if(Qt4_FIND_REQUIRED) 1314 message( FATAL_ERROR "${VERSION_MSG}, this code requires Qt 4.x") 1315 else() 1316 if(NOT Qt4_FIND_QUIETLY) 1317 message( STATUS "${VERSION_MSG}") 1318 endif() 1319 endif() 1320else() 1321 if (CMAKE_FIND_PACKAGE_NAME STREQUAL "Qt") 1322 # FindQt include()'s this module. It's an old pattern, but rather than 1323 # trying to suppress this from outside the module (which is then sensitive 1324 # to the contents, detect the case in this module and suppress it 1325 # explicitly. 1326 set(FPHSA_NAME_MISMATCHED 1) 1327 endif () 1328 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Qt4 FOUND_VAR Qt4_FOUND 1329 REQUIRED_VARS ${_QT4_FOUND_REQUIRED_VARS} 1330 VERSION_VAR QTVERSION 1331 ) 1332 unset(FPHSA_NAME_MISMATCHED) 1333endif() 1334 1335####################################### 1336# 1337# compatibility settings 1338# 1339####################################### 1340# Backwards compatibility for CMake1.4 and 1.2 1341set (QT_MOC_EXE ${QT_MOC_EXECUTABLE} ) 1342set (QT_UIC_EXE ${QT_UIC_EXECUTABLE} ) 1343set( QT_QT_LIBRARY "") 1344set(QT4_FOUND ${Qt4_FOUND}) 1345set(QT_FOUND ${Qt4_FOUND}) 1346 1347