FindQt4.cmake 51 KB

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