FindQt4.cmake 53.1 KB
Newer Older
1 2
#.rst:
# FindQt4
3
# -------
4
#
5
# Finding and Using Qt4
6
# ^^^^^^^^^^^^^^^^^^^^^
7 8 9 10
#
# This module can be used to find Qt4.  The most important issue is that
# the Qt4 qmake is available via the system path.  This qmake is then
# used to detect basically everything else.  This module defines a
11
# number of :prop_tgt:`IMPORTED` targets, macros and variables.
12 13
#
# Typical usage could be something like:
14
#
15
# .. code-block:: cmake
16
#
17 18 19
#    set(CMAKE_AUTOMOC ON)
#    set(CMAKE_INCLUDE_CURRENT_DIR ON)
#    find_package(Qt4 4.4.3 REQUIRED QtGui QtXml)
20
#    add_executable(myexe main.cpp)
21
#    target_link_libraries(myexe Qt4::QtGui Qt4::QtXml)
22
#
23
# .. note::
24
#
25
#  When using :prop_tgt:`IMPORTED` targets, the qtmain.lib static library is
26
#  automatically linked on Windows for :prop_tgt:`WIN32 <WIN32_EXECUTABLE>`
27
#  executables. To disable that globally, set the
28 29 30
#  ``QT4_NO_LINK_QTMAIN`` variable before finding Qt4. To disable that
#  for a particular executable, set the ``QT4_NO_LINK_QTMAIN`` target
#  property to ``TRUE`` on the executable.
31
#
32
# Qt Build Tools
33
# ^^^^^^^^^^^^^^
34
#
35 36 37 38
# Qt relies on some bundled tools for code generation, such as ``moc`` for
# meta-object code generation,``uic`` for widget layout and population,
# and ``rcc`` for virtual filesystem content generation.  These tools may be
# automatically invoked by :manual:`cmake(1)` if the appropriate conditions
39
# are met.  See :manual:`cmake-qt(7)` for more.
40
#
41
# Qt Macros
42
# ^^^^^^^^^
43
#
44 45
# In some cases it can be necessary or useful to invoke the Qt build tools in a
# more-manual way. Several macros are available to add targets for such uses.
46 47 48
#
# ::
#
49
#   macro QT4_WRAP_CPP(outfiles inputfile ... [TARGET tgt] OPTIONS ...)
50 51
#         create moc code from a list of files containing Qt class with
#         the Q_OBJECT declaration.  Per-directory preprocessor definitions
52 53 54 55
#         are also added.  If the <tgt> is specified, the
#         INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS from
#         the <tgt> are passed to moc.  Options may be given to moc, such as
#         those found when executing "moc -help".
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
#
#
# ::
#
#   macro QT4_WRAP_UI(outfiles inputfile ... OPTIONS ...)
#         create code from a list of Qt designer ui files.
#         Options may be given to uic, such as those found
#         when executing "uic -help"
#
#
# ::
#
#   macro QT4_ADD_RESOURCES(outfiles inputfile ... OPTIONS ...)
#         create code from a list of Qt resource files.
#         Options may be given to rcc, such as those found
#         when executing "rcc -help"
#
#
# ::
#
76
#   macro QT4_GENERATE_MOC(inputfile outputfile [TARGET tgt])
77 78
#         creates a rule to run moc on infile and create outfile.
#         Use this if for some reason QT4_WRAP_CPP() isn't appropriate, e.g.
79 80 81 82
#         because you need a custom filename for the moc file or something
#         similar.  If the <tgt> is specified, the
#         INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS from
#         the <tgt> are passed to moc.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
#
#
# ::
#
#   macro QT4_ADD_DBUS_INTERFACE(outfiles interface basename)
#         Create the interface header and implementation files with the
#         given basename from the given interface xml file and add it to
#         the list of sources.
#
#         You can pass additional parameters to the qdbusxml2cpp call by setting
#         properties on the input file:
#
#         INCLUDE the given file will be included in the generate interface header
#
#         CLASSNAME the generated class is named accordingly
#
#         NO_NAMESPACE the generated class is not wrapped in a namespace
#
#
# ::
#
#   macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... )
#         Create the interface header and implementation files
#         for all listed interface xml files.
107 108
#         The basename will be automatically determined from the name
#         of the xml file.
109
#
110 111
#         The source file properties described for
#         QT4_ADD_DBUS_INTERFACE also apply here.
112 113 114 115
#
#
# ::
#
116 117
#   macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname
#                              [basename] [classname])
118 119 120 121
#         create a dbus adaptor (header and implementation file) from the xml file
#         describing the interface, and add it to the list of sources. The adaptor
#         forwards the calls to a parent class, defined in parentheader and named
#         parentclassname. The name of the generated files will be
122 123
#         <basename>adaptor.{cpp,h} where basename defaults to the basename of the
#         xml file.
124 125 126 127 128 129 130 131 132 133 134
#         If <classname> is provided, then it will be used as the classname of the
#         adaptor itself.
#
#
# ::
#
#   macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] OPTIONS ...)
#         generate the xml interface file from the given header.
#         If the optional argument interfacename is omitted, the name of the
#         interface file is constructed from the basename of the header with
#         the suffix .xml appended.
135 136
#         Options may be given to qdbuscpp2xml, such as those found when
#         executing "qdbuscpp2xml --help"
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
#
#
# ::
#
#   macro QT4_CREATE_TRANSLATION( qm_files directories ... sources ...
#                                 ts_files ... OPTIONS ...)
#         out: qm_files
#         in:  directories sources ts_files
#         options: flags to pass to lupdate, such as -extensions to specify
#         extensions for a directory scan.
#         generates commands to create .ts (vie lupdate) and .qm
#         (via lrelease) - files from directories and/or sources. The ts files are
#         created and/or updated in the source tree (unless given with full paths).
#         The qm files are generated in the build tree.
#         Updating the translations can be done by adding the qm_files
#         to the source list of your library/executable, so they are
#         always updated, or by adding a custom target to control when
#         they get updated/generated.
#
#
# ::
#
#   macro QT4_ADD_TRANSLATION( qm_files ts_files ... )
#         out: qm_files
#         in:  ts_files
#         generates commands to create .qm from .ts - files. The generated
#         filenames can be found in qm_files. The ts_files
#         must exist and are not updated in any way.
#
#
167 168 169 170 171 172 173 174 175 176
# ::
#
#   macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... [TARGET tgt])
#         The qt4_automoc macro is obsolete.  Use the CMAKE_AUTOMOC feature instead.
#         This macro is still experimental.
#         It can be used to have moc automatically handled.
#         So if you have the files foo.h and foo.cpp, and in foo.h a
#         a class uses the Q_OBJECT macro, moc has to run on it. If you don't
#         want to use QT4_WRAP_CPP() (which is reliable and mature), you can insert
#         #include "foo.moc"
177
#         in foo.cpp and then give foo.cpp as argument to QT4_AUTOMOC(). This will
178 179
#         scan all listed files at cmake-time for such included moc files and if it
#         finds them cause a rule to be generated to run moc at build time on the
180
#         accompanying header file foo.h.
181 182
#         If a source file has the SKIP_AUTOMOC property set it will be ignored by
#         this macro.
183 184
#         If the <tgt> is specified, the INTERFACE_INCLUDE_DIRECTORIES and
#         INTERFACE_COMPILE_DEFINITIONS from the <tgt> are passed to moc.
185
#
186 187 188
#
# ::
#
189
#  function QT4_USE_MODULES( target [link_type] modules...)
190 191
#         This function is obsolete. Use target_link_libraries with IMPORTED targets
#         instead.
192
#         Make <target> use the <modules> from Qt. Using a Qt module means
193 194
#         to link to the library, add the relevant include directories for the
#         module, and add the relevant compiler defines for using the module.
195 196 197
#         Modules are roughly equivalent to components of Qt4, so usage would be
#         something like:
#          qt4_use_modules(myexe Core Gui Declarative)
198 199 200
#         to use QtCore, QtGui and QtDeclarative. The optional <link_type> argument
#         can be specified as either LINK_PUBLIC or LINK_PRIVATE to specify the
#         same argument to the target_link_libraries call.
201 202
#
#
203
# IMPORTED Targets
204
# ^^^^^^^^^^^^^^^^
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
#
# A particular Qt library may be used by using the corresponding
# :prop_tgt:`IMPORTED` target with the :command:`target_link_libraries`
# command:
#
# .. code-block:: cmake
#
#   target_link_libraries(myexe Qt4::QtGui Qt4::QtXml)
#
# Using a target in this way causes :cmake(1)` to use the appropriate include
# directories and compile definitions for the target when compiling ``myexe``.
#
# Targets are aware of their dependencies, so for example it is not necessary
# to list ``Qt4::QtCore`` if another Qt library is listed, and it is not
# necessary to list ``Qt4::QtGui`` if ``Qt4::QtDeclarative`` is listed.
# Targets may be tested for existence in the usual way with the
# :command:`if(TARGET)` command.
#
# The Qt toolkit may contain both debug and release libraries.
# :manual:`cmake(1)` will choose the appropriate version based on the build
# configuration.
#
# ``Qt4::QtCore``
#  The QtCore target
# ``Qt4::QtGui``
#  The QtGui target
# ``Qt4::Qt3Support``
#  The Qt3Support target
# ``Qt4::QtAssistant``
#  The QtAssistant target
# ``Qt4::QtAssistantClient``
#  The QtAssistantClient target
# ``Qt4::QAxContainer``
#  The QAxContainer target (Windows only)
# ``Qt4::QAxServer``
#  The QAxServer target (Windows only)
# ``Qt4::QtDBus``
#  The QtDBus target
# ``Qt4::QtDesigner``
#  The QtDesigner target
# ``Qt4::QtDesignerComponents``
#  The QtDesignerComponents target
# ``Qt4::QtHelp``
#  The QtHelp target
# ``Qt4::QtMotif``
#  The QtMotif target
# ``Qt4::QtMultimedia``
#  The QtMultimedia target
# ``Qt4::QtNetwork``
#  The QtNetwork target
# ``Qt4::QtNsPLugin``
#  The QtNsPLugin target
# ``Qt4::QtOpenGL``
#  The QtOpenGL target
# ``Qt4::QtScript``
#  The QtScript target
# ``Qt4::QtScriptTools``
#  The QtScriptTools target
# ``Qt4::QtSql``
#  The QtSql target
# ``Qt4::QtSvg``
#  The QtSvg target
# ``Qt4::QtTest``
#  The QtTest target
# ``Qt4::QtUiTools``
#  The QtUiTools target
# ``Qt4::QtWebKit``
#  The QtWebKit target
# ``Qt4::QtXml``
#  The QtXml target
# ``Qt4::QtXmlPatterns``
#  The QtXmlPatterns target
# ``Qt4::phonon``
#  The phonon target
#
# Result Variables
281
# ^^^^^^^^^^^^^^^^
282 283 284
#
#   Below is a detailed list of variables that FindQt4.cmake sets.
#
285 286 287 288 289 290 291 292 293 294 295 296
# ``Qt4_FOUND``
#  If false, don't try to use Qt 4.
# ``QT_FOUND``
#  If false, don't try to use Qt. This variable is for compatibility only.
# ``QT4_FOUND``
#  If false, don't try to use Qt 4. This variable is for compatibility only.
# ``QT_VERSION_MAJOR``
#  The major version of Qt found.
# ``QT_VERSION_MINOR``
#  The minor version of Qt found.
# ``QT_VERSION_PATCH``
#  The patch version of Qt found.
297

298 299 300 301 302 303 304 305 306 307
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
308
# (To distribute this file outside of CMake, substitute the full
309
#  License text for the above reference.)
310

311 312 313 314 315
# Use find_package( Qt4 COMPONENTS ... ) to enable modules
if( Qt4_FIND_COMPONENTS )
  foreach( component ${Qt4_FIND_COMPONENTS} )
    string( TOUPPER ${component} _COMPONENT )
    set( QT_USE_${_COMPONENT} 1 )
316
  endforeach()
317

318
  # To make sure we don't use QtCore or QtGui when not in COMPONENTS
319 320
  if(NOT QT_USE_QTCORE)
    set( QT_DONT_USE_QTCORE 1 )
321
  endif()
322

323 324
  if(NOT QT_USE_QTGUI)
    set( QT_DONT_USE_QTGUI 1 )
325
  endif()
326

327
endif()
328

329
# If Qt3 has already been found, fail.
330 331 332
if(QT_QT_LIBRARY)
  if(Qt4_FIND_REQUIRED)
    message( FATAL_ERROR "Qt3 and Qt4 cannot be used together in one project.  If switching to Qt4, the CMakeCache.txt needs to be cleaned.")
333
  else()
334 335
    if(NOT Qt4_FIND_QUIETLY)
      message( STATUS    "Qt3 and Qt4 cannot be used together in one project.  If switching to Qt4, the CMakeCache.txt needs to be cleaned.")
336
    endif()
337
    return()
338 339
  endif()
endif()
340 341


342 343
include(${CMAKE_CURRENT_LIST_DIR}/CheckCXXSymbolExists.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/MacroAddFileDependencies.cmake)
344
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
345
include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
346

347
set(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake)
348

349
set( QT_DEFINITIONS "")
350

351
# convenience macro for dealing with debug/release library names
352
macro (_QT4_ADJUST_LIB_VARS _camelCaseBasename)
353

354
  string(TOUPPER "${_camelCaseBasename}" basename)
355 356 357 358

  # The name of the imported targets, i.e. the prefix "Qt4::" must not change,
  # since it is stored in EXPORT-files as name of a required library. If the name would change
  # here, this would lead to the imported Qt4-library targets not being resolved by cmake anymore.
359
  if (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG)
360

361 362
    if(NOT TARGET Qt4::${_camelCaseBasename})
      add_library(Qt4::${_camelCaseBasename} UNKNOWN IMPORTED )
363

364 365
      if (QT_${basename}_LIBRARY_RELEASE)
        set_property(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
366
        if(QT_USE_FRAMEWORKS)
367
          set_property(TARGET Qt4::${_camelCaseBasename}        PROPERTY IMPORTED_LOCATION_RELEASE "${QT_${basename}_LIBRARY_RELEASE}/${_camelCaseBasename}" )
368
        else()
369
          set_property(TARGET Qt4::${_camelCaseBasename}        PROPERTY IMPORTED_LOCATION_RELEASE "${QT_${basename}_LIBRARY_RELEASE}" )
370
        endif()
371
      endif ()
372

373 374
      if (QT_${basename}_LIBRARY_DEBUG)
        set_property(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
375
        if(QT_USE_FRAMEWORKS)
376
          set_property(TARGET Qt4::${_camelCaseBasename}        PROPERTY IMPORTED_LOCATION_DEBUG "${QT_${basename}_LIBRARY_DEBUG}/${_camelCaseBasename}" )
377
        else()
378
          set_property(TARGET Qt4::${_camelCaseBasename}        PROPERTY IMPORTED_LOCATION_DEBUG "${QT_${basename}_LIBRARY_DEBUG}" )
379
        endif()
380
      endif ()
381 382 383 384 385 386 387 388 389
      set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY
        INTERFACE_INCLUDE_DIRECTORIES
          "${QT_${basename}_INCLUDE_DIR}"
      )
      string(REGEX REPLACE "^QT" "" _stemname ${basename})
      set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY
        INTERFACE_COMPILE_DEFINITIONS
          "QT_${_stemname}_LIB"
      )
390
    endif()
391 392 393 394

    # If QT_USE_IMPORTED_TARGETS is enabled, the QT_QTFOO_LIBRARY variables are set to point at these
    # imported targets. This works better in general, and is also in almost all cases fully
    # backward compatible. The only issue is when a project A which had this enabled then exports its
395
    # libraries via export or export_library_dependencies(). In this case the libraries from project
396 397 398 399
    # A will depend on the imported Qt targets, and the names of these imported targets will be stored
    # in the dependency files on disk. This means when a project B then uses project A, these imported
    # targets must be created again, otherwise e.g. "Qt4__QtCore" will be interpreted as name of a
    # library file on disk, and not as a target, and linking will fail:
400 401 402
    if(QT_USE_IMPORTED_TARGETS)
        set(QT_${basename}_LIBRARY       Qt4::${_camelCaseBasename} )
        set(QT_${basename}_LIBRARIES     Qt4::${_camelCaseBasename} )
403
    else()
404 405

      # if the release- as well as the debug-version of the library have been found:
406
      if (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
407 408
        # if the generator supports configuration types then set
        # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
409 410
        if (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
          set(QT_${basename}_LIBRARY       optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
411
        else()
412 413
          # if there are no configuration types and CMAKE_BUILD_TYPE has no value
          # then just use the release libraries
414
          set(QT_${basename}_LIBRARY       ${QT_${basename}_LIBRARY_RELEASE} )
415
        endif()
416
        set(QT_${basename}_LIBRARIES       optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
417
      endif ()
418 419

      # if only the release version was found, set the debug variable also to the release version
420 421 422 423
      if (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG)
        set(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE})
        set(QT_${basename}_LIBRARY       ${QT_${basename}_LIBRARY_RELEASE})
        set(QT_${basename}_LIBRARIES     ${QT_${basename}_LIBRARY_RELEASE})
424
      endif ()
425 426

      # if only the debug version was found, set the release variable also to the debug version
427 428 429 430
      if (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE)
        set(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG})
        set(QT_${basename}_LIBRARY         ${QT_${basename}_LIBRARY_DEBUG})
        set(QT_${basename}_LIBRARIES       ${QT_${basename}_LIBRARY_DEBUG})
431
      endif ()
432 433

      # put the value in the cache:
434
      set(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE STRING "The Qt ${basename} library" FORCE)
435

436
    endif()
437

438
    set(QT_${basename}_FOUND 1)
439

440
  else ()
441

442
    set(QT_${basename}_LIBRARY "" CACHE STRING "The Qt ${basename} library" FORCE)
443

444
  endif ()
445

446
  if (QT_${basename}_INCLUDE_DIR)
447
    #add the include directory to QT_INCLUDES
448
    set(QT_INCLUDES "${QT_${basename}_INCLUDE_DIR}" ${QT_INCLUDES})
449
  endif ()
450

451
  # Make variables changeable to the advanced user
452
  mark_as_advanced(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR)
453
endmacro ()
454

455
function(_QT4_QUERY_QMAKE VAR RESULT)
456 457
  execute_process(COMMAND "${QT_QMAKE_EXECUTABLE}" -query ${VAR}
    RESULT_VARIABLE return_code
458
    OUTPUT_VARIABLE output
459
    OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE)
460 461 462
  if(NOT return_code)
    file(TO_CMAKE_PATH "${output}" output)
    set(${RESULT} ${output} PARENT_SCOPE)
463 464
  endif()
endfunction()
465

466 467 468 469
function(_QT4_GET_VERSION_COMPONENTS VERSION RESULT_MAJOR RESULT_MINOR RESULT_PATCH)
  string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" QT_VERSION_MAJOR "${QTVERSION}")
  string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" QT_VERSION_MINOR "${QTVERSION}")
  string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" QT_VERSION_PATCH "${QTVERSION}")
470

471 472 473 474
  set(${RESULT_MAJOR} ${QT_VERSION_MAJOR} PARENT_SCOPE)
  set(${RESULT_MINOR} ${QT_VERSION_MINOR} PARENT_SCOPE)
  set(${RESULT_PATCH} ${QT_VERSION_PATCH} PARENT_SCOPE)
endfunction()
475

476 477 478 479
function(_QT4_FIND_QMAKE QMAKE_NAMES QMAKE_RESULT VERSION_RESULT)
  list(LENGTH QMAKE_NAMES QMAKE_NAMES_LEN)
  if(${QMAKE_NAMES_LEN} EQUAL 0)
    return()
480
  endif()
481
  list(GET QMAKE_NAMES 0 QMAKE_NAME)
482

483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
  get_filename_component(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME)

  find_program(QT_QMAKE_EXECUTABLE NAMES ${QMAKE_NAME}
    PATHS
      ENV QTDIR
      "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]"
    PATH_SUFFIXES bin
    DOC "The qmake executable for the Qt installation to use"
  )

  set(major 0)
  if (QT_QMAKE_EXECUTABLE)
    _qt4_query_qmake(QT_VERSION QTVERSION)
    _qt4_get_version_components("${QTVERSION}" major minor patch)
  endif()
498

499 500 501
  if (NOT QT_QMAKE_EXECUTABLE OR NOT "${major}" EQUAL 4)
    set(curr_qmake "${QT_QMAKE_EXECUTABLE}")
    set(curr_qt_version "${QTVERSION}")
502

503
    set(QT_QMAKE_EXECUTABLE NOTFOUND CACHE FILEPATH "" FORCE)
504 505 506 507 508 509 510 511 512
    list(REMOVE_AT QMAKE_NAMES 0)
    _qt4_find_qmake("${QMAKE_NAMES}" QMAKE QTVERSION)

    _qt4_get_version_components("${QTVERSION}" major minor patch)
    if (NOT ${major} EQUAL 4)
      # Restore possibly found qmake and it's version; these are used later
      # in error message if incorrect version is found
      set(QT_QMAKE_EXECUTABLE "${curr_qmake}" CACHE FILEPATH "" FORCE)
      set(QTVERSION "${curr_qt_version}")
513
    endif()
514

515
  endif()
516

517

518
  set(${QMAKE_RESULT} "${QT_QMAKE_EXECUTABLE}" PARENT_SCOPE)
519 520 521 522 523 524 525 526
  set(${VERSION_RESULT} "${QTVERSION}" PARENT_SCOPE)
endfunction()


set(QT4_INSTALLED_VERSION_TOO_OLD FALSE)

set(_QT4_QMAKE_NAMES qmake qmake4 qmake-qt4 qmake-mac)
_qt4_find_qmake("${_QT4_QMAKE_NAMES}" QT_QMAKE_EXECUTABLE QTVERSION)
527

528 529
if (QT_QMAKE_EXECUTABLE AND
  QTVERSION VERSION_GREATER 3 AND QTVERSION VERSION_LESS 5)
530

531 532 533 534 535 536 537 538
  if (Qt5Core_FOUND)
    # Qt5CoreConfig sets QT_MOC_EXECUTABLE as a non-cache variable to the Qt 5
    # path to moc.  Unset that variable when Qt 4 and 5 are used together, so
    # that when find_program looks for moc, it is not set to the Qt 5 version.
    # If FindQt4 has already put the Qt 4 path in the cache, the unset()
    # command 'unhides' the (correct) cache variable.
    unset(QT_MOC_EXECUTABLE)
  endif()
539 540 541 542 543
  if (QT_QMAKE_EXECUTABLE_LAST)
    string(COMPARE NOTEQUAL "${QT_QMAKE_EXECUTABLE_LAST}" "${QT_QMAKE_EXECUTABLE}" QT_QMAKE_CHANGED)
  endif()
  set(QT_QMAKE_EXECUTABLE_LAST "${QT_QMAKE_EXECUTABLE}" CACHE INTERNAL "" FORCE)

544
  _qt4_get_version_components("${QTVERSION}" QT_VERSION_MAJOR QT_VERSION_MINOR QT_VERSION_PATCH)
545

546 547
  # ask qmake for the mkspecs directory
  # we do this first because QT_LIBINFIX might be set
548
  if (NOT QT_MKSPECS_DIR  OR  QT_QMAKE_CHANGED)
549
    _qt4_query_qmake(QMAKE_MKSPECS qt_mkspecs_dirs)
550 551
    # do not replace : on windows as it might be a drive letter
    # and windows should already use ; as a separator
552 553
    if(NOT WIN32)
      string(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}")
554
    endif()
555 556 557
    set(qt_cross_paths)
    foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH})
      set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/mkspecs")
558
    endforeach()
559 560
    set(QT_MKSPECS_DIR NOTFOUND)
    find_path(QT_MKSPECS_DIR NAMES qconfig.pri
561
      HINTS ${qt_cross_paths} ${qt_mkspecs_dirs}
562 563
      DOC "The location of the Qt mkspecs containing qconfig.pri"
      NO_CMAKE_FIND_ROOT_PATH)
564 565 566 567 568 569 570 571 572
  endif()

  if(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
    file(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents)
    string(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG "${_qconfig_FILE_contents}")
    string(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG "${_qconfig_FILE_contents}")
    string(REGEX MATCH "EDITION[^\n]+" QT_EDITION "${_qconfig_FILE_contents}")
    string(REGEX MATCH "QT_LIBINFIX[^\n]+" _qconfig_qt_libinfix "${_qconfig_FILE_contents}")
    string(REGEX REPLACE "QT_LIBINFIX *= *([^\n]*)" "\\1" QT_LIBINFIX "${_qconfig_qt_libinfix}")
573
  endif()
574 575
  if("${QT_EDITION}" MATCHES "DesktopLight")
    set(QT_EDITION_DESKTOPLIGHT 1)
576
  endif()
577 578 579

  # ask qmake for the library dir as a hint, then search for QtCore library and use that as a reference for finding the
  # others and for setting QT_LIBRARY_DIR
580
  if (NOT (QT_QTCORE_LIBRARY_RELEASE OR QT_QTCORE_LIBRARY_DEBUG)  OR QT_QMAKE_CHANGED)
581
    _qt4_query_qmake(QT_INSTALL_LIBS QT_LIBRARY_DIR_TMP)
582 583 584
    set(QT_QTCORE_LIBRARY_RELEASE NOTFOUND)
    set(QT_QTCORE_LIBRARY_DEBUG NOTFOUND)
    find_library(QT_QTCORE_LIBRARY_RELEASE
585 586
                 NAMES QtCore${QT_LIBINFIX} QtCore${QT_LIBINFIX}4
                 HINTS ${QT_LIBRARY_DIR_TMP}
587
                 NO_DEFAULT_PATH
588
        )
589
    find_library(QT_QTCORE_LIBRARY_DEBUG
590 591
                 NAMES QtCore${QT_LIBINFIX}_debug QtCore${QT_LIBINFIX}d QtCore${QT_LIBINFIX}d4
                 HINTS ${QT_LIBRARY_DIR_TMP}
592
                 NO_DEFAULT_PATH
593
        )
594

595 596
    if(NOT QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCORE_LIBRARY_DEBUG)
      find_library(QT_QTCORE_LIBRARY_RELEASE
597 598 599
                   NAMES QtCore${QT_LIBINFIX} QtCore${QT_LIBINFIX}4
                   HINTS ${QT_LIBRARY_DIR_TMP}
          )
600
      find_library(QT_QTCORE_LIBRARY_DEBUG
601 602 603
                   NAMES QtCore${QT_LIBINFIX}_debug QtCore${QT_LIBINFIX}d QtCore${QT_LIBINFIX}d4
                   HINTS ${QT_LIBRARY_DIR_TMP}
          )
604
    endif()
605

606
    # try dropping a hint if trying to use Visual Studio with Qt built by MinGW
607 608
    if(NOT QT_QTCORE_LIBRARY_RELEASE AND MSVC)
      if(EXISTS ${QT_LIBRARY_DIR_TMP}/libqtmain.a)
609
        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.")
610 611
      endif()
    endif()
612

613
  endif ()
614

615
  # set QT_LIBRARY_DIR based on location of QtCore found.
616 617 618 619 620 621 622 623 624
  if(QT_QTCORE_LIBRARY_RELEASE)
    get_filename_component(QT_LIBRARY_DIR_TMP "${QT_QTCORE_LIBRARY_RELEASE}" PATH)
    set(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE)
    set(QT_QTCORE_FOUND 1)
  elseif(QT_QTCORE_LIBRARY_DEBUG)
    get_filename_component(QT_LIBRARY_DIR_TMP "${QT_QTCORE_LIBRARY_DEBUG}" PATH)
    set(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE)
    set(QT_QTCORE_FOUND 1)
  else()
625 626 627 628 629 630 631
    if(NOT Qt4_FIND_QUIETLY)
      message(WARNING
        "${QT_QMAKE_EXECUTABLE} reported QT_INSTALL_LIBS as "
        "\"${QT_LIBRARY_DIR_TMP}\" "
        "but QtCore could not be found there.  "
        "Qt is NOT installed correctly for the target build environment.")
    endif()
632
    set(Qt4_FOUND FALSE)
633 634
    if(Qt4_FIND_REQUIRED)
      message( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.")
635 636
    else()
      return()
637
    endif()
638
  endif()
639

640
  # ask qmake for the binary dir
641
  if (NOT QT_BINARY_DIR  OR  QT_QMAKE_CHANGED)
642
    _qt4_query_qmake(QT_INSTALL_BINS qt_bins)
643
    set(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "" FORCE)
644
  endif ()
645 646 647 648 649 650

  if (APPLE)
    set(CMAKE_FIND_FRAMEWORK_OLD ${CMAKE_FIND_FRAMEWORK})
    if (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
      set(QT_USE_FRAMEWORKS ON CACHE INTERNAL "" FORCE)
      set(CMAKE_FIND_FRAMEWORK FIRST)
651
    else ()
652 653
      set(QT_USE_FRAMEWORKS OFF CACHE INTERNAL "" FORCE)
      set(CMAKE_FIND_FRAMEWORK LAST)
654 655
    endif ()
  endif ()
656

657
  # ask qmake for the include dir
658
  if (QT_LIBRARY_DIR AND (NOT QT_QTCORE_INCLUDE_DIR OR NOT QT_HEADERS_DIR OR  QT_QMAKE_CHANGED))
659
      _qt4_query_qmake(QT_INSTALL_HEADERS qt_headers)
660 661
      set(QT_QTCORE_INCLUDE_DIR NOTFOUND)
      find_path(QT_QTCORE_INCLUDE_DIR QtCore
662
                HINTS ${qt_headers} ${QT_LIBRARY_DIR}
663
                PATH_SUFFIXES QtCore qt4/QtCore
664
                NO_DEFAULT_PATH
665
        )
666 667 668 669 670 671
      if(NOT QT_QTCORE_INCLUDE_DIR)
        find_path(QT_QTCORE_INCLUDE_DIR QtCore
                  HINTS ${qt_headers} ${QT_LIBRARY_DIR}
                  PATH_SUFFIXES QtCore qt4/QtCore
          )
      endif()
672 673

      # Set QT_HEADERS_DIR based on finding QtCore header
674 675 676
      if(QT_QTCORE_INCLUDE_DIR)
        if(QT_USE_FRAMEWORKS)
          set(QT_HEADERS_DIR "${qt_headers}" CACHE INTERNAL "" FORCE)
677
        else()
678 679
          get_filename_component(qt_headers "${QT_QTCORE_INCLUDE_DIR}/../" ABSOLUTE)
          set(QT_HEADERS_DIR "${qt_headers}" CACHE INTERNAL "" FORCE)
680
        endif()
681 682 683 684 685 686 687 688
      elseif()
        message("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_HEADERS as ${qt_headers}")
        message("Warning: But QtCore couldn't be found.  Qt must NOT be installed correctly.")
      endif()
  endif()

  if(APPLE)
    set(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_OLD})
689
  endif()
690

691
  # Set QT_INCLUDE_DIR based on QT_HEADERS_DIR
692 693
  if(QT_HEADERS_DIR)
    if(QT_USE_FRAMEWORKS)
694 695 696
      # Qt/Mac frameworks has two include dirs.
      # One is the framework include for which CMake will add a -F flag
      # and the other is an include dir for non-framework Qt modules
697
      set(QT_INCLUDE_DIR ${QT_HEADERS_DIR} ${QT_QTCORE_LIBRARY_RELEASE} )
698
    else()
699
      set(QT_INCLUDE_DIR ${QT_HEADERS_DIR})
700 701
    endif()
  endif()
702 703

  # Set QT_INCLUDES
704
  set( QT_INCLUDES ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR})
705 706 707


  # ask qmake for the documentation directory
708
  if (QT_LIBRARY_DIR AND NOT QT_DOC_DIR  OR  QT_QMAKE_CHANGED)
709
    _qt4_query_qmake(QT_INSTALL_DOCS qt_doc_dir)
710
    set(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs" FORCE)
711
  endif ()
712 713


714
  # ask qmake for the plugins directory
715
  if (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR  OR  QT_QMAKE_CHANGED)
716
    _qt4_query_qmake(QT_INSTALL_PLUGINS qt_plugins_dir)
717
    set(QT_PLUGINS_DIR NOTFOUND)
718 719
    foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH})
      set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/plugins")
720
    endforeach()
721
    find_path(QT_PLUGINS_DIR NAMES accessible imageformats sqldrivers codecs designer
722
      HINTS ${qt_cross_paths} ${qt_plugins_dir}
723 724
      DOC "The location of the Qt plugins"
      NO_CMAKE_FIND_ROOT_PATH)
725
  endif ()
Clinton Stimpson's avatar
Clinton Stimpson committed
726 727

  # ask qmake for the translations directory
728
  if (QT_LIBRARY_DIR AND NOT QT_TRANSLATIONS_DIR  OR  QT_QMAKE_CHANGED)
729
    _qt4_query_qmake(QT_INSTALL_TRANSLATIONS qt_translations_dir)
730
    set(QT_TRANSLATIONS_DIR ${qt_translations_dir} CACHE PATH "The location of the Qt translations" FORCE)
731
  endif ()
Clinton Stimpson's avatar
Clinton Stimpson committed
732

733
  # ask qmake for the imports directory
734
  if (QT_LIBRARY_DIR AND NOT QT_IMPORTS_DIR OR QT_QMAKE_CHANGED)
735 736
    _qt4_query_qmake(QT_INSTALL_IMPORTS qt_imports_dir)
    if(qt_imports_dir)
737
      set(QT_IMPORTS_DIR NOTFOUND)
738 739
      foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH})
        set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/imports")
740
      endforeach()
741
      find_path(QT_IMPORTS_DIR NAMES Qt
742 743
        HINTS ${qt_cross_paths} ${qt_imports_dir}
        DOC "The location of the Qt imports"
744
        NO_CMAKE_FIND_ROOT_PATH
745 746 747
        NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH
        NO_CMAKE_SYSTEM_PATH)
      mark_as_advanced(QT_IMPORTS_DIR)
748 749
    endif()
  endif ()
750

751
  # Make variables changeable to the advanced user
752
  mark_as_advanced( QT_LIBRARY_DIR QT_DOC_DIR QT_MKSPECS_DIR
753 754 755
                    QT_PLUGINS_DIR QT_TRANSLATIONS_DIR)


756 757


758 759 760 761 762
  #############################################
  #
  # Find out what window system we're using
  #
  #############################################
763
  cmake_push_check_state()
764
  # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES
765
  set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}")
766
  set(CMAKE_REQUIRED_QUIET ${Qt4_FIND_QUIETLY})
767
  # Check for Window system symbols (note: only one should end up being set)
768 769 770 771
  CHECK_CXX_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11)
  CHECK_CXX_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN)
  CHECK_CXX_SYMBOL_EXISTS(Q_WS_QWS "QtCore/qglobal.h" Q_WS_QWS)
  CHECK_CXX_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC)
772 773 774
  if(Q_WS_MAC)
    if(QT_QMAKE_CHANGED)
      unset(QT_MAC_USE_COCOA CACHE)
775
    endif()
776
    CHECK_CXX_SYMBOL_EXISTS(QT_MAC_USE_COCOA "QtCore/qconfig.h" QT_MAC_USE_COCOA)
777
  endif()
778

779
  if (QT_QTCOPY_REQUIRED)
780
     CHECK_CXX_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY)
781 782
     if (NOT QT_IS_QTCOPY)
        message(FATAL_ERROR "qt-copy is required, but hasn't been found")
783 784
     endif ()
  endif ()
785

786
  cmake_pop_check_state()
787 788 789 790 791
  #
  #############################################



792 793 794 795 796
  ########################################
  #
  #       Setting the INCLUDE-Variables
  #
  ########################################
797

798
  set(QT_MODULES QtGui Qt3Support QtSvg QtScript QtTest QtUiTools
799
                 QtHelp QtWebKit QtXmlPatterns phonon QtNetwork QtMultimedia
800 801
                 QtNsPlugin QtOpenGL QtSql QtXml QtDesigner QtDBus QtScriptTools
                 QtDeclarative)
802

803 804
  if(Q_WS_X11)
    set(QT_MODULES ${QT_MODULES} QtMotif)
805
  endif()
806 807 808 809 810 811 812

  if(QT_QMAKE_CHANGED)
    foreach(QT_MODULE ${QT_MODULES})
      string(TOUPPER ${QT_MODULE} _upper_qt_module)
      set(QT_${_upper_qt_module}_INCLUDE_DIR NOTFOUND)
      set(QT_${_upper_qt_module}_LIBRARY_RELEASE NOTFOUND)
      set(QT_${_upper_qt_module}_LIBRARY_DEBUG NOTFOUND)
813
    endforeach()
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833
    set(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR NOTFOUND)
    set(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NOTFOUND)
    set(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NOTFOUND)
    set(QT_QTASSISTANTCLIENT_INCLUDE_DIR NOTFOUND)
    set(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NOTFOUND)
    set(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NOTFOUND)
    set(QT_QTASSISTANT_INCLUDE_DIR NOTFOUND)
    set(QT_QTASSISTANT_LIBRARY_RELEASE NOTFOUND)
    set(QT_QTASSISTANT_LIBRARY_DEBUG NOTFOUND)
    set(QT_QTCLUCENE_LIBRARY_RELEASE NOTFOUND)
    set(QT_QTCLUCENE_LIBRARY_DEBUG NOTFOUND)
    set(QT_QAXCONTAINER_INCLUDE_DIR NOTFOUND)
    set(QT_QAXCONTAINER_LIBRARY_RELEASE NOTFOUND)
    set(QT_QAXCONTAINER_LIBRARY_DEBUG NOTFOUND)
    set(QT_QAXSERVER_INCLUDE_DIR NOTFOUND)
    set(QT_QAXSERVER_LIBRARY_RELEASE NOTFOUND)
    set(QT_QAXSERVER_LIBRARY_DEBUG NOTFOUND)
    if(Q_WS_WIN)
      set(QT_QTMAIN_LIBRARY_DEBUG NOTFOUND)
      set(QT_QTMAIN_LIBRARY_RELEASE NOTFOUND)
834 835
    endif()
  endif()
836 837 838 839

  foreach(QT_MODULE ${QT_MODULES})
    string(TOUPPER ${QT_MODULE} _upper_qt_module)
    find_path(QT_${_upper_qt_module}_INCLUDE_DIR ${QT_MODULE}
840 841 842
              PATHS
              ${QT_HEADERS_DIR}/${QT_MODULE}
              ${QT_LIBRARY_DIR}/${QT_MODULE}.framework/Headers
843
              NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
844
      )
845 846
    # phonon doesn't seem consistent, let's try phonondefs.h for some
    # installations
847 848
    if(${QT_MODULE} STREQUAL "phonon")
      find_path(QT_${_upper_qt_module}_INCLUDE_DIR phonondefs.h
849 850 851
                PATHS
                ${QT_HEADERS_DIR}/${QT_MODULE}
                ${QT_LIBRARY_DIR}/${QT_MODULE}.framework/Headers
852
                NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
853
        )
854 855
    endif()
  endforeach()
856

857
  if(Q_WS_WIN)
858
    set(QT_MODULES ${QT_MODULES} QAxContainer QAxServer)
859 860 861 862 863 864 865 866 867
    # Set QT_AXCONTAINER_INCLUDE_DIR and QT_AXSERVER_INCLUDE_DIR
    find_path(QT_QAXCONTAINER_INCLUDE_DIR ActiveQt
      PATHS ${QT_HEADERS_DIR}/ActiveQt
      NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
      )
    find_path(QT_QAXSERVER_INCLUDE_DIR ActiveQt
      PATHS ${QT_HEADERS_DIR}/ActiveQt
      NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
      )
868
  endif()
869

870
  # Set QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR
871
  find_path(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR QDesignerComponents
Bill Hoffman's avatar
Bill Hoffman committed
872
    PATHS
873
    ${QT_HEADERS_DIR}/QtDesigner
874
    ${QT_LIBRARY_DIR}/QtDesigner.framework/Headers
875
    NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
876
    )
877

878
  # Set QT_QTASSISTANT_INCLUDE_DIR
879
  find_path(QT_QTASSISTANT_INCLUDE_DIR QtAssistant
880
    PATHS
881
    ${QT_HEADERS_DIR}/QtAssistant
882
    ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers
883
    NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
884
    )
885

886
  # Set QT_QTASSISTANTCLIENT_INCLUDE_DIR
887
  find_path(QT_QTASSISTANTCLIENT_INCLUDE_DIR QAssistantClient
888
    PATHS
889
    ${QT_HEADERS_DIR}/QtAssistant
890
    ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers
891
    NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
892
    )
893 894 895 896 897 898

  ########################################
  #
  #       Setting the LIBRARY-Variables
  #
  ########################################
899

900
  # find the libraries
901 902 903
  foreach(QT_MODULE ${QT_MODULES})
    string(TOUPPER ${QT_MODULE} _upper_qt_module)
    find_library(QT_${_upper_qt_module}_LIBRARY_RELEASE
904
                 NAMES ${QT_MODULE}${QT_LIBINFIX} ${QT_MODULE}${QT_LIBINFIX}4
905
                 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
906
        )
907
    find_library(QT_${_upper_qt_module}_LIBRARY_DEBUG
908
                 NAMES ${QT_MODULE}${QT_LIBINFIX}_debug ${QT_MODULE}${QT_LIBINFIX}d ${QT_MODULE}${QT_LIBINFIX}d4
909
                 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
910
        )
911 912 913 914 915 916 917 918 919 920 921 922
    if(QT_${_upper_qt_module}_LIBRARY_RELEASE MATCHES "/${QT_MODULE}\\.framework$")
      if(NOT EXISTS "${QT_${_upper_qt_module}_LIBRARY_RELEASE}/${QT_MODULE}")
        # Release framework library file does not exist... Force to NOTFOUND:
        set(QT_${_upper_qt_module}_LIBRARY_RELEASE "QT_${_upper_qt_module}_LIBRARY_RELEASE-NOTFOUND" CACHE FILEPATH "Path to a library." FORCE)
      endif()
    endif()
    if(QT_${_upper_qt_module}_LIBRARY_DEBUG MATCHES "/${QT_MODULE}\\.framework$")
      if(NOT EXISTS "${QT_${_upper_qt_module}_LIBRARY_DEBUG}/${QT_MODULE}")
        # Debug framework library file does not exist... Force to NOTFOUND:
        set(QT_${_upper_qt_module}_LIBRARY_DEBUG "QT_${_upper_qt_module}_LIBRARY_DEBUG-NOTFOUND" CACHE FILEPATH "Path to a library." FORCE)
      endif()
    endif()
923
  endforeach()
924

925 926
  # QtUiTools is sometimes not in the same directory as the other found libraries
  # e.g. on Mac, its never a framework like the others are
927 928
  if(QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE)
    find_library(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR})
929
  endif()
930

931
  # Set QT_QTDESIGNERCOMPONENTS_LIBRARY
932 933
  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)
  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)
934

Bill Hoffman's avatar
Bill Hoffman committed
935
  # Set QT_QTMAIN_LIBRARY
936 937 938
  if(Q_WS_WIN)
    find_library(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
    find_library(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmain${QT_LIBINFIX}d PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
939
  endif()
940

941
  # Set QT_QTASSISTANTCLIENT_LIBRARY
942 943
  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)
  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)
944

945
  # Set QT_QTASSISTANT_LIBRARY
946 947
  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)
  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)
948 949

  # Set QT_QTHELP_LIBRARY
950 951 952 953
  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)
  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)
  if(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE)
    find_library(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR})
954
  endif()
955

956

957 958 959 960 961 962
  ############################################
  #
  # Check the existence of the libraries.
  #
  ############################################

963

964 965 966
  macro(_qt4_add_target_depends_internal _QT_MODULE _PROPERTY)
    if (TARGET Qt4::${_QT_MODULE})
      foreach(_DEPEND ${ARGN})
967 968 969
        set(_VALID_DEPENDS)
        if (TARGET Qt4::Qt${_DEPEND})
          list(APPEND _VALID_DEPENDS Qt4::Qt${_DEPEND})
970
        endif()
971 972 973 974 975 976 977
        if (_VALID_DEPENDS)
          set_property(TARGET Qt4::${_QT_MODULE} APPEND PROPERTY
            ${_PROPERTY}
            "${_VALID_DEPENDS}"
          )
        endif()
        set(_VALID_DEPENDS)
978 979 980 981 982
      endforeach()
    endif()
  endmacro()

  macro(_qt4_add_target_depends _QT_MODULE)
983 984 985 986 987 988 989 990
    if (TARGET Qt4::${_QT_MODULE})
      get_target_property(_configs Qt4::${_QT_MODULE} IMPORTED_CONFIGURATIONS)
      _qt4_add_target_depends_internal(${_QT_MODULE} INTERFACE_LINK_LIBRARIES ${ARGN})
      foreach(_config ${_configs})
        _qt4_add_target_depends_internal(${_QT_MODULE} IMPORTED_LINK_INTERFACE_LIBRARIES_${_config} ${ARGN})
      endforeach()
      set(_configs)
    endif()
991 992 993
  endmacro()

  macro(_qt4_add_target_private_depends _QT_MODULE)
994 995 996 997 998 999 1000
    if (TARGET Qt4::${_QT_MODULE})
      get_target_property(_configs Qt4::${_QT_MODULE} IMPORTED_CONFIGURATIONS)
      foreach(_config ${_configs})
        _qt4_add_target_depends_internal(${_QT_MODULE} IMPORTED_LINK_DEPENDENT_LIBRARIES_${_config} ${ARGN})
      endforeach()
      set(_configs)
    endif()
1001 1002 1003
  endmacro()


1004
  # Set QT_xyz_LIBRARY variable and add
1005
  # library include path to QT_INCLUDES
1006
  _QT4_ADJUST_LIB_VARS(QtCore)
1007 1008 1009 1010 1011
  set_property(TARGET Qt4::QtCore APPEND PROPERTY
    INTERFACE_INCLUDE_DIRECTORIES
      "${QT_MKSPECS_DIR}/default"
      ${QT_INCLUDE_DIR}
  )
1012 1013 1014 1015
  set_property(TARGET Qt4::QtCore APPEND PROPERTY
    INTERFACE_COMPILE_DEFINITIONS
      $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>
  )
1016 1017 1018 1019 1020 1021
  set_property(TARGET Qt4::QtCore PROPERTY
    INTERFACE_QT_MAJOR_VERSION 4
  )
  set_property(TARGET Qt4::QtCore APPEND PROPERTY
    COMPATIBLE_INTERFACE_STRING QT_MAJOR_VERSION
  )
1022

1023
  foreach(QT_MODULE ${QT_MODULES})
1024
    _QT4_ADJUST_LIB_VARS(${QT_MODULE})
1025
    _qt4_add_target_depends(${QT_MODULE} Core)
1026
  endforeach()
1027

1028 1029 1030 1031
  _QT4_ADJUST_LIB_VARS(QtAssistant)
  _QT4_ADJUST_LIB_VARS(QtAssistantClient)
  _QT4_ADJUST_LIB_VARS(QtCLucene)
  _QT4_ADJUST_LIB_VARS(QtDesignerComponents)
1032 1033

  # platform dependent libraries
1034
  if(Q_WS_WIN)
1035
    _QT4_ADJUST_LIB_VARS(qtmain)
1036

1037
    _QT4_ADJUST_LIB_VARS(QAxServer)
1038 1039 1040 1041 1042 1043 1044
    if(QT_QAXSERVER_FOUND)
      set_property(TARGET Qt4::QAxServer PROPERTY
        INTERFACE_QT4_NO_LINK_QTMAIN ON
      )
      set_property(TARGET Qt4::QAxServer APPEND PROPERTY
        COMPATIBLE_INTERFACE_BOOL QT4_NO_LINK_QTMAIN)
    endif()
1045

1046
    _QT4_ADJUST_LIB_VARS(QAxContainer)
1047
  endif()
1048

1049 1050 1051 1052 1053 1054
  # Only public dependencies are listed here.
  # Eg, QtDBus links to QtXml, but users of QtDBus do not need to
  # link to QtXml because QtDBus only uses it internally, not in public
  # headers.
  # Everything depends on QtCore, but that is covered above already
  _qt4_add_target_depends(Qt3Support Sql Gui Network)
1055 1056 1057 1058
  if (TARGET Qt4::Qt3Support)
    # An additional define is required for QT3_SUPPORT
    set_property(TARGET Qt4::Qt3Support APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS QT3_SUPPORT)
  endif()
1059 1060 1061 1062 1063 1064 1065 1066 1067
  _qt4_add_target_depends(QtDeclarative Script Gui)
  _qt4_add_target_depends(QtDesigner Gui)
  _qt4_add_target_depends(QtHelp Gui)
  _qt4_add_target_depends(QtMultimedia Gui)
  _qt4_add_target_depends(QtOpenGL Gui)
  _qt4_add_target_depends(QtSvg Gui)
  _qt4_add_target_depends(QtWebKit Gui Network)

  _qt4_add_target_private_depends(Qt3Support Xml)
1068 1069 1070
  if(QT_VERSION VERSION_GREATER 4.6)
    _qt4_add_target_private_depends(QtSvg Xml)
  endif()
1071 1072 1073 1074 1075 1076 1077 1078 1079
  _qt4_add_target_private_depends(QtDBus Xml)
  _qt4_add_target_private_depends(QtUiTools Xml Gui)
  _qt4_add_target_private_depends(QtHelp Sql Xml Network)
  _qt4_add_target_private_depends(QtXmlPatterns Network)
  _qt4_add_target_private_depends(QtScriptTools Gui)
  _qt4_add_target_private_depends(QtWebKit XmlPatterns)
  _qt4_add_target_private_depends(QtDeclarative XmlPatterns Svg Sql Gui)
  _qt4_add_target_private_depends(QtMultimedia Gui)
  _qt4_add_target_private_depends(QtOpenGL Gui)
1080 1081 1082 1083 1084 1085
  if(QT_QAXSERVER_FOUND)
    _qt4_add_target_private_depends(QAxServer Gui)
  endif()
  if(QT_QAXCONTAINER_FOUND)
    _qt4_add_target_private_depends(QAxContainer Gui)
  endif()
1086 1087 1088 1089
  _qt4_add_target_private_depends(phonon Gui)
  if(QT_QTDBUS_FOUND)
    _qt4_add_target_private_depends(phonon DBus)
  endif()
1090

1091 1092 1093 1094 1095
  if (WIN32 AND NOT QT4_NO_LINK_QTMAIN)
    set(_isExe $<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>)
    set(_isWin32 $<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>)
    set(_isNotExcluded $<NOT:$<BOOL:$<TARGET_PROPERTY:QT4_NO_LINK_QTMAIN>>>)
    set(_isPolicyNEW $<TARGET_POLICY:CMP0020>)
1096
    get_target_property(_configs Qt4::QtCore IMPORTED_CONFIGURATIONS)
1097 1098 1099 1100
    set_property(TARGET Qt4::QtCore APPEND PROPERTY
        INTERFACE_LINK_LIBRARIES
          $<$<AND:${_isExe},${_isWin32},${_isNotExcluded},${_isPolicyNEW}>:Qt4::qtmain>
    )
1101 1102 1103 1104 1105 1106 1107
    foreach(_config ${_configs})
      set_property(TARGET Qt4::QtCore APPEND PROPERTY
        IMPORTED_LINK_INTERFACE_LIBRARIES_${_config}
          $<$<AND:${_isExe},${_isWin32},${_isNotExcluded},${_isPolicyNEW}>:Qt4::qtmain>
      )
    endforeach()
    unset(_configs)
1108 1109 1110 1111 1112 1113
    unset(_isExe)
    unset(_isWin32)
    unset(_isNotExcluded)
    unset(_isPolicyNEW)
  endif()

1114 1115
  #######################################
  #
1116
  #       Check the executables of Qt
1117 1118 1119
  #          ( moc, uic, rcc )
  #
  #######################################
1120

1121

1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133
  if(QT_QMAKE_CHANGED)
    set(QT_UIC_EXECUTABLE NOTFOUND)
    set(QT_MOC_EXECUTABLE NOTFOUND)
    set(QT_UIC3_EXECUTABLE NOTFOUND)
    set(QT_RCC_EXECUTABLE NOTFOUND)
    set(QT_DBUSCPP2XML_EXECUTABLE NOTFOUND)
    set(QT_DBUSXML2CPP_EXECUTABLE NOTFOUND)
    set(QT_LUPDATE_EXECUTABLE NOTFOUND)
    set(QT_LRELEASE_EXECUTABLE NOTFOUND)
    set(QT_QCOLLECTIONGENERATOR_EXECUTABLE NOTFOUND)
    set(QT_DESIGNER_EXECUTABLE NOTFOUND)
    set(QT_LINGUIST_EXECUTABLE NOTFOUND)
1134
  endif()
1135

1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146
  macro(_find_qt4_program VAR NAME)
    find_program(${VAR}
      NAMES ${ARGN}
      PATHS ${QT_BINARY_DIR}
      NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
      )
    if (${VAR} AND NOT TARGET ${NAME})
      add_executable(${NAME} IMPORTED)
      set_property(TARGET ${NAME} PROPERTY IMPORTED_LOCATION ${${VAR}})
    endif()
  endmacro()
1147

1148 1149
  _find_qt4_program(QT_MOC_EXECUTABLE Qt4::moc moc-qt4 moc4 moc)
  _find_qt4_program(QT_UIC_EXECUTABLE Qt4::uic uic-qt4 uic4 uic)
1150 1151 1152 1153
  _find_qt4_program(QT_UIC3_EXECUTABLE Qt4::uic3 uic3)
  _find_qt4_program(QT_RCC_EXECUTABLE Qt4::rcc rcc)
  _find_qt4_program(QT_DBUSCPP2XML_EXECUTABLE Qt4::qdbuscpp2xml qdbuscpp2xml)
  _find_qt4_program(QT_DBUSXML2CPP_EXECUTABLE Qt4::qdbusxml2cpp qdbusxml2cpp)
1154 1155
  _find_qt4_program(QT_LUPDATE_EXECUTABLE Qt4::lupdate lupdate-qt4 lupdate4 lupdate)
  _find_qt4_program(QT_LRELEASE_EXECUTABLE Qt4::lrelease lrelease-qt4 lrelease4 lrelease)
1156
  _find_qt4_program(QT_QCOLLECTIONGENERATOR_EXECUTABLE Qt4::qcollectiongenerator qcollectiongenerator-qt4 qcollectiongenerator)
1157 1158
  _find_qt4_program(QT_DESIGNER_EXECUTABLE Qt4::designer designer-qt4 designer4 designer)
  _find_qt4_program(QT_LINGUIST_EXECUTABLE Qt4::linguist linguist-qt4 linguist4 linguist)
1159

1160 1161 1162 1163 1164
  if (NOT TARGET Qt4::qmake)
    add_executable(Qt4::qmake IMPORTED)
    set_property(TARGET Qt4::qmake PROPERTY IMPORTED_LOCATION ${QT_QMAKE_EXECUTABLE})
  endif()

1165 1166
  if (QT_MOC_EXECUTABLE)
     set(QT_WRAP_CPP "YES")
1167
  endif ()
1168

1169 1170
  if (QT_UIC_EXECUTABLE)
     set(QT_WRAP_UI "YES")
1171
  endif ()
1172 1173 1174



1175
  mark_as_advanced( QT_UIC_EXECUTABLE QT_UIC3_EXECUTABLE QT_MOC_EXECUTABLE
1176
    QT_RCC_EXECUTABLE QT_DBUSXML2CPP_EXECUTABLE QT_DBUSCPP2XML_EXECUTABLE
1177 1178
    QT_LUPDATE_EXECUTABLE QT_LRELEASE_EXECUTABLE QT_QCOLLECTIONGENERATOR_EXECUTABLE
    QT_DESIGNER_EXECUTABLE QT_LINGUIST_EXECUTABLE)
1179

1180 1181

  # get the directory of the current file, used later on in the file
1182
  get_filename_component( _qt4_current_dir  "${CMAKE_CURRENT_LIST_FILE}" PATH)
1183

1184

1185 1186
  ###############################################
  #
1187
  #       configuration/system dependent settings
1188 1189 1190
  #
  ###############################################

1191
  include("${_qt4_current_dir}/Qt4ConfigDependentSettings.cmake")
1192

1193

1194 1195 1196 1197 1198 1199
  #######################################
  #
  #       Check the plugins of Qt
  #
  #######################################

1200 1201 1202
  set( QT_PLUGIN_TYPES accessible bearer codecs decorations designer gfxdrivers graphicssystems iconengines imageformats inputmethods mousedrivers phonon_backend script sqldrivers )

  set( QT_ACCESSIBLE_PLUGINS qtaccessiblecompatwidgets qtaccessiblewidgets )
1203
  set( QT_BEARER_PLUGINS qcorewlanbearer qgenericbearer qnativewifibearer )
1204 1205 1206 1207 1208 1209
  set( QT_CODECS_PLUGINS qcncodecs qjpcodecs qkrcodecs qtwcodecs )
  set( QT_DECORATIONS_PLUGINS qdecorationdefault qdecorationwindows )
  set( QT_DESIGNER_PLUGINS arthurplugin containerextension customwidgetplugin phononwidgets qdeclarativeview qt3supportwidgets qwebview taskmenuextension worldtimeclockplugin )
  set( QT_GRAPHICSDRIVERS_PLUGINS qgfxtransformed qgfxvnc qscreenvfb )
  set( QT_GRAPHICSSYSTEMS_PLUGINS qglgraphicssystem qtracegraphicssystem )
  set( QT_ICONENGINES_PLUGINS qsvgicon )
1210
  set( QT_IMAGEFORMATS_PLUGINS qgif qjpeg qmng qico qsvg qtiff qtga )
1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223
  set( QT_INPUTMETHODS_PLUGINS qimsw_multi )
  set( QT_MOUSEDRIVERS_PLUGINS qwstslibmousehandler )
  if(APPLE)
    set( QT_PHONON_BACKEND_PLUGINS phonon_qt7 )
  elseif(WIN32)
    set( QT_PHONON_BACKEND_PLUGINS phonon_ds9 )
  endif()
  set( QT_SCRIPT_PLUGINS qtscriptdbus )
  set( QT_SQLDRIVERS_PLUGINS qsqldb2 qsqlibase qsqlite qsqlite2 qsqlmysql qsqloci qsqlodbc qsqlpsql qsqltds )

  set( QT_PHONON_PLUGINS ${QT_PHONON_BACKEND_PLUGINS} )
  set( QT_QT3SUPPORT_PLUGINS qtaccessiblecompatwidgets )
  set( QT_QTCORE_PLUGINS ${QT_BEARER_PLUGINS} ${QT_CODECS_PLUGINS} )
1224
  set( QT_QTGUI_PLUGINS qtaccessiblewidgets ${QT_IMAGEFORMATS_PLUGINS} ${QT_DECORATIONS_PLUGINS} ${QT_GRAPHICSDRIVERS_PLUGINS} ${QT_GRAPHICSSYSTEMS_PLUGINS} ${QT_INPUTMETHODS_PLUGINS} ${QT_MOUSEDRIVERS_PLUGINS} )
1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240
  set( QT_QTSCRIPT_PLUGINS ${QT_SCRIPT_PLUGINS} )
  set( QT_QTSQL_PLUGINS ${QT_SQLDRIVERS_PLUGINS} )
  set( QT_QTSVG_PLUGINS qsvg qsvgicon )

  if(QT_QMAKE_CHANGED)
    foreach(QT_PLUGIN_TYPE ${QT_PLUGIN_TYPES})
      string(TOUPPER ${QT_PLUGIN_TYPE} _upper_qt_plugin_type)
      set(QT_${_upper_qt_plugin_type}_PLUGINS_DIR ${QT_PLUGINS_DIR}/${QT_PLUGIN_TYPE})
      foreach(QT_PLUGIN ${QT_${_upper_qt_plugin_type}_PLUGINS})
        string(TOUPPER ${QT_PLUGIN} _upper_qt_plugin)
        unset(QT_${_upper_qt_plugin}_LIBRARY_RELEASE CACHE)
        unset(QT_${_upper_qt_plugin}_LIBRARY_DEBUG CACHE)
        unset(QT_${_upper_qt_plugin}_LIBRARY CACHE)
        unset(QT_${_upper_qt_plugin}_PLUGIN_RELEASE CACHE)
        unset(QT_${_upper_qt_plugin}_PLUGIN_DEBUG CACHE)
        unset(QT_${_upper_qt_plugin}_PLUGIN CACHE)
1241 1242 1243
      endforeach()
    endforeach()
  endif()
1244 1245

  # find_library works better than find_file but we need to set prefixes to only match plugins
1246 1247 1248 1249 1250 1251 1252
  foreach(QT_PLUGIN_TYPE ${QT_PLUGIN_TYPES})
    string(TOUPPER ${QT_PLUGIN_TYPE} _upper_qt_plugin_type)
    set(QT_${_upper_qt_plugin_type}_PLUGINS_DIR ${QT_PLUGINS_DIR}/${QT_PLUGIN_TYPE})
    foreach(QT_PLUGIN ${QT_${_upper_qt_plugin_type}_PLUGINS})
      string(TOUPPER ${QT_PLUGIN} _upper_qt_plugin)
      if(QT_IS_STATIC)
        find_library(QT_${_upper_qt_plugin}_LIBRARY_RELEASE
1253
                     NAMES ${QT_PLUGIN}${QT_LIBINFIX} ${QT_PLUGIN}${QT_LIBINFIX}4
1254
                     PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
1255
            )
1256
        find_library(QT_${_upper_qt_plugin}_LIBRARY_DEBUG
1257
                     NAMES ${QT_PLUGIN}${QT_LIBINFIX}_debug ${QT_PLUGIN}${QT_LIBINFIX}d ${QT_PLUGIN}${QT_LIBINFIX}d4
1258
                     PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
1259 1260
            )
        _QT4_ADJUST_LIB_VARS(${QT_PLUGIN})
1261
      else()
1262
        # find_library works easier/better than find_file but we need to set suffixes to only match plugins
1263 1264 1265
        set(CMAKE_FIND_LIBRARY_SUFFIXES_DEFAULT ${CMAKE_FIND_LIBRARY_SUFFIXES})
        set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_MODULE_SUFFIX} ${CMAKE_SHARED_LIBRARY_SUFFIX})
        find_library(QT_${_upper_qt_plugin}_PLUGIN_RELEASE
1266
                     NAMES ${QT_PLUGIN}${QT_LIBINFIX} ${QT_PLUGIN}${QT_LIBINFIX}4
1267
                     PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
1268
            )
1269
        find_library(QT_${_upper_qt_plugin}_PLUGIN_DEBUG