FindQt4.cmake 52 KB

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