FindQt4.cmake 59 KB

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