FindQt4.cmake 61 KB

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