FindQt4.cmake 54 KB

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