FindQt4.cmake 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. # - Find QT 4
  2. # This module can be used to find Qt4.
  3. # This module defines a number of key variables and macros. First is
  4. # QT_USE_FILE which is the path to a CMake file that can be included to compile
  5. # Qt 4 applications and libraries. By default, the QtCore and QtGui
  6. # libraries are loaded. This behavior can be changed by setting one or more
  7. # of the following variables to true:
  8. # QT_DONT_USE_QTCORE
  9. # QT_DONT_USE_QTGUI
  10. # QT_USE_QT3SUPPORT
  11. # QT_USE_QTASSISTANT
  12. # QT_USE_QTDESIGNER
  13. # QT_USE_QTMOTIF
  14. # QT_USE_QTNETWORK
  15. # QT_USE_QTNSPLUGIN
  16. # QT_USE_QTOPENGL
  17. # QT_USE_QTSQL
  18. # QT_USE_QTXML
  19. # All the libraries required are stored in a variable called QT_LIBRARIES.
  20. # Add this variable to your TARGET_LINK_LIBRARIES.
  21. #
  22. # macro QT4_WRAP_CPP(outfiles inputfile ... )
  23. # macro QT4_WRAP_UI(outfiles inputfile ... )
  24. # macro QT4_ADD_RESOURCE(outfiles inputfile ... )
  25. #
  26. # QT_FOUND If false, don't try to use Qt.
  27. # QT4_FOUND If false, don't try to use Qt 4.
  28. #
  29. # QT_QTCORE_FOUND True if QtCore was found.
  30. # QT_QTGUI_FOUND True if QtGui was found.
  31. # QT_QT3SUPPORT_FOUND True if Qt3Support was found.
  32. # QT_QTASSISTANT_FOUND True if QtAssistant was found.
  33. # QT_QTDESIGNER_FOUND True if QtDesigner was found.
  34. # QT_QTMOTIF_FOUND True if QtMotif was found.
  35. # QT_QTNETWORK_FOUND True if QtNetwork was found.
  36. # QT_QTNSPLUGIN_FOUND True if QtNsPlugin was found.
  37. # QT_QTOPENGL_FOUND True if QtOpenGL was found.
  38. # QT_QTSQL_FOUND True if QtSql was found.
  39. # QT_QTXML_FOUND True if QtXml was found.
  40. #
  41. # QT_DEFINITIONS Definitions to use when compiling code that
  42. # uses Qt.
  43. #
  44. # QT_INCLUDES List of paths to all include directories of
  45. # Qt4 QT_INCLUDE_DIR, QT_QT_INCLUDE_DIR,
  46. # and QT_QTGUI_INCLUDE_DIR are
  47. # always in this variable even if NOTFOUND,
  48. # all other INCLUDE_DIRS are
  49. # only added if they are found.
  50. #
  51. # QT_INCLUDE_DIR Path to "include" of Qt4
  52. # QT_QT_INCLUDE_DIR Path to "include/Qt"
  53. # QT_QT3SUPPORT_INCLUDE_DIR Path to "include/Qt3Support"
  54. # QT_QTASSISTANT_INCLUDE_DIR Path to "include/QtAssistant"
  55. # QT_QTCORE_INCLUDE_DIR Path to "include/QtCore"
  56. # QT_QTDESIGNER_INCLUDE_DIR Path to "include/QtDesigner"
  57. # QT_QTGUI_INCLUDE_DIR Path to "include/QtGui"
  58. # QT_QTMOTIF_INCLUDE_DIR Path to "include/QtMotif"
  59. # QT_QTNETWORK_INCLUDE_DIR Path to "include/QtNetwork"
  60. # QT_QTNSPLUGIN_INCLUDE_DIR Path to "include/QtNsPlugin"
  61. # QT_QTOPENGL_INCLUDE_DIR Path to "include/QtOpenGL"
  62. # QT_QTSQL_INCLUDE_DIR Path to "include/QtSql"
  63. # QT_QTXML_INCLUDE_DIR Path to "include/QtXml"
  64. #
  65. # QT_LIBRARY_DIR Path to "lib" of Qt4
  66. #
  67. # QT_QT3SUPPORT_LIBRARY Fullpath to Qt3Support library
  68. # QT_QTASSISTANT_LIBRARY Fullpath to QtAssistant library
  69. # QT_QTCORE_LIBRARY Fullpath to QtCore library
  70. # QT_QTDESIGNER_LIBRARY Fullpath to QtDesigner library
  71. # QT_QTGUI_LIBRARY Fullpath to QtGui library
  72. # QT_QTMOTIF_LIBRARY Fullpath to QtMotif library
  73. # QT_QTNETWORK_LIBRARY Fullpath to QtNetwork library
  74. # QT_QTNSPLUGIN_LIBRARY Fullpath to QtNsPlugin library
  75. # QT_QTOPENGL_LIBRARY Fullpath to QtOpenGL library
  76. # QT_QTSQL_LIBRARY Fullpath to QtSql library
  77. # QT_QTXML_LIBRARY Fullpath to QtXml library
  78. #
  79. # QT_QT3SUPPORT_LIBRARY_DEBUG Fullpath to Qt3Support_debug library
  80. # QT_QTASSISTANT_LIBRARY_DEBUG Fullpath to QtAssistant_debug library
  81. #
  82. # QT_QTCORE_LIBRARY_DEBUG Fullpath to QtCore_debug
  83. # QT_QTDESIGNER_LIBRARY_DEBUG Fullpath to QtDesigner_debug
  84. # QT_QTGUI_LIBRARY_DEBUG Fullpath to QtGui_debug
  85. # QT_QTMOTIF_LIBRARY_DEBUG Fullpath to QtMotif_debug
  86. # QT_QTNETWORK_LIBRARY_DEBUG Fullpath to QtNetwork_debug
  87. # QT_QTNSPLUGIN_LIBRARY_DEBUG Fullpath to QtNsPlugin_debug
  88. # QT_QTOPENGL_LIBRARY_DEBUG Fullpath to QtOpenGL_debug
  89. # QT_QTSQL_LIBRARY_DEBUG Fullpath to QtSql_debug
  90. # QT_QTXML_LIBRARY_DEBUG Fullpath to QtXml_debug
  91. #
  92. # also defined, but not for general use are
  93. # QT_MOC_EXECUTABLE Where to find the moc tool.
  94. # QT_UIC_EXECUTABLE Where to find the uic tool.
  95. # QT_RCC_EXECUTABLE Where to find the rcc tool
  96. #
  97. # These are around for backwards compatibility
  98. # they will be set
  99. # QT_WRAP_CPP Set true if QT_MOC_EXECUTABLE is found
  100. # QT_WRAP_UI Set true if QT_UIC_EXECUTABLE is found
  101. #
  102. # These variables do _NOT_ have any effect anymore (compared to FindQt.cmake)
  103. # QT_MT_REQUIRED Qt4 is now always multithreaded
  104. #
  105. # These variables are set to "" Because Qt structure changed
  106. # (They make no sense in Qt4)
  107. # QT_QT_LIBRARY Qt-Library is now splitt
  108. # QT_QTMAIN_LIBRARY Qt-Library is now splitt
  109. SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake)
  110. SET( QT_DEFINITIONS "")
  111. IF (WIN32)
  112. SET(QT_DEFINITIONS -DQT_DLL)
  113. ENDIF(WIN32)
  114. FILE(GLOB GLOB_TEMP_VAR /usr/local/Trolltech/Qt-4*/)
  115. SET(GLOB_TEMP_VAR)
  116. IF(GLOB_TEMP_VAR)
  117. SET(QT4_PATHS ${QT4_PATHS} ${GLOB_TEMP_VAR})
  118. ENDIF(GLOB_TEMP_VAR)
  119. SET(GLOB_TEMP_VAR)
  120. FILE(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-4*/bin/)
  121. IF(GLOB_TEMP_VAR)
  122. SET(QT4_PATHS ${QT4_PATHS} ${GLOB_TEMP_VAR})
  123. ENDIF(GLOB_TEMP_VAR)
  124. # check for qmake
  125. FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake-qt4 qmake PATHS
  126. "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
  127. "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
  128. $ENV{QTDIR}/bin
  129. ${QT4_PATHS}
  130. )
  131. IF(QT_QMAKE_EXECUTABLE)
  132. EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION"
  133. OUTPUT_VARIABLE QTVERSION)
  134. IF(QTVERSION MATCHES "4.*")
  135. SET(QT4_QMAKE_FOUND TRUE)
  136. ENDIF(QTVERSION MATCHES "4.*")
  137. ENDIF(QT_QMAKE_EXECUTABLE)
  138. IF(QT4_QMAKE_FOUND)
  139. # Set QT_LIBRARY_DIR
  140. IF(NOT QT_LIBRARY_DIR)
  141. EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
  142. ARGS "-query QT_INSTALL_LIBS"
  143. OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP )
  144. IF(EXISTS "${QT_LIBRARY_DIR_TMP}")
  145. SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir")
  146. ELSE(EXISTS "${QT_LIBRARY_DIR_TMP}")
  147. MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}")
  148. MESSAGE("Warning: ${QT_LIBRARY_DIR_TMP} does not exist, Qt must not be installed correctly.")
  149. ENDIF(EXISTS "${QT_LIBRARY_DIR_TMP}")
  150. ENDIF(NOT QT_LIBRARY_DIR)
  151. IF (APPLE)
  152. IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
  153. SET(QT_USE_FRAMEWORKS ON
  154. CACHE BOOL "Set to ON if Qt build uses frameworks.")
  155. ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
  156. SET(QT_USE_FRAMEWORKS OFF
  157. CACHE BOOL "Set to ON if Qt build uses frameworks.")
  158. ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework)
  159. MARK_AS_ADVANCED(QT_USE_FRAMEWORKS)
  160. ENDIF (APPLE)
  161. ########################################
  162. #
  163. # Setting the INCLUDE-Variables
  164. #
  165. ########################################
  166. IF (NOT QT_HEADERS_DIR)
  167. # Set QT_QT_INCLUDE_DIR by searching for qglobal.h
  168. IF(QT_QMAKE_EXECUTABLE)
  169. EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
  170. ARGS "-query QT_INSTALL_HEADERS"
  171. OUTPUT_VARIABLE qt_headers )
  172. SET(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "")
  173. ENDIF(QT_QMAKE_EXECUTABLE)
  174. ENDIF (NOT QT_HEADERS_DIR)
  175. FILE(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-3*/include/Qt/)
  176. SET(QT_PATH_INCLUDE ${GLOB_TEMP_VAR})
  177. FILE(GLOB GLOB_TEMP_VAR /usr/local/Trolltech/Qt-4*/include/Qt/)
  178. SET(QT_PATH_INCLUDE ${GLOB_TEMP_VAR})
  179. FIND_PATH( QT_QT_INCLUDE_DIR qglobal.h
  180. "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/include/Qt"
  181. ${QT_PATH_INCLUDE}
  182. ${QT_HEADERS_DIR}/Qt
  183. ${QT_LIBRARY_DIR}/QtCore.framework/Headers
  184. $ENV{QTDIR}/include/Qt
  185. /usr/local/qt/include/Qt
  186. /usr/local/include/Qt
  187. /usr/lib/qt/include/Qt
  188. /usr/include/Qt
  189. /usr/share/qt4/include/Qt
  190. "$ENV{ProgramFiles}/qt/include/Qt"
  191. "C:/Program Files/qt/include/Qt"
  192. /usr/include/qt4/Qt)
  193. # Set QT_INCLUDE_DIR by removine "/Qt" in the string ${QT_QT_INCLUDE_DIR}
  194. IF( QT_QT_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
  195. IF (QT_USE_FRAMEWORKS)
  196. SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR})
  197. ELSE (QT_USE_FRAMEWORKS)
  198. STRING( REGEX REPLACE "/Qt$" "" qt4_include_dir ${QT_QT_INCLUDE_DIR})
  199. SET( QT_INCLUDE_DIR ${qt4_include_dir} CACHE PATH "")
  200. ENDIF (QT_USE_FRAMEWORKS)
  201. ENDIF( QT_QT_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
  202. IF( NOT QT_INCLUDE_DIR)
  203. IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
  204. MESSAGE( FATAL_ERROR "Could not find qglobal.h")
  205. ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED)
  206. ENDIF( NOT QT_INCLUDE_DIR)
  207. IF (QT_USE_FRAMEWORKS)
  208. SET(QT_DEFINITIONS ${QT_DEFINITIONS}
  209. -F${QT_LIBRARY_DIR}
  210. )
  211. ENDIF (QT_USE_FRAMEWORKS)
  212. # Set QT_QT3SUPPORT_INCLUDE_DIR
  213. FIND_PATH( QT_QT3SUPPORT_INCLUDE_DIR Qt3Support
  214. ${QT_INCLUDE_DIR}/Qt3Support
  215. ${QT_LIBRARY_DIR}/Qt3Support.framework/Headers
  216. )
  217. # Set QT_QTCORE_INCLUDE_DIR
  218. FIND_PATH( QT_QTCORE_INCLUDE_DIR QtCore
  219. ${QT_INCLUDE_DIR}/QtCore
  220. ${QT_LIBRARY_DIR}/QtCore.framework/Headers
  221. )
  222. # Set QT_QTGUI_INCLUDE_DIR
  223. FIND_PATH( QT_QTGUI_INCLUDE_DIR QtGui
  224. ${QT_INCLUDE_DIR}/QtGui
  225. ${QT_LIBRARY_DIR}/QtGui.framework/Headers
  226. )
  227. # Set QT_QTMOTIF_INCLUDE_DIR
  228. FIND_PATH( QT_QTMOTIF_INCLUDE_DIR QtMotif ${QT_INCLUDE_DIR}/QtMotif)
  229. # Set QT_QTNETWORK_INCLUDE_DIR
  230. FIND_PATH( QT_QTNETWORK_INCLUDE_DIR QtNetwork
  231. ${QT_INCLUDE_DIR}/QtNetwork
  232. ${QT_LIBRARY_DIR}/QtNetwork.framework/Headers
  233. )
  234. # Set QT_QTNSPLUGIN_INCLUDE_DIR
  235. FIND_PATH( QT_QTNSPLUGIN_INCLUDE_DIR QtNsPlugin
  236. ${QT_INCLUDE_DIR}/QtNsPlugin
  237. ${QT_LIBRARY_DIR}/QtNsPlugin.framework/Headers
  238. )
  239. # Set QT_QTOPENGL_INCLUDE_DIR
  240. FIND_PATH( QT_QTOPENGL_INCLUDE_DIR QtOpenGL
  241. ${QT_INCLUDE_DIR}/QtOpenGL
  242. ${QT_LIBRARY_DIR}/QtOpenGL.framework/Headers
  243. )
  244. # Set QT_QTSQL_INCLUDE_DIR
  245. FIND_PATH( QT_QTSQL_INCLUDE_DIR QtSql
  246. ${QT_INCLUDE_DIR}/QtSql
  247. ${QT_LIBRARY_DIR}/QtSql.framework/Headers
  248. )
  249. # Set QT_QTXML_INCLUDE_DIR
  250. FIND_PATH( QT_QTXML_INCLUDE_DIR QtXml
  251. ${QT_INCLUDE_DIR}/QtXml
  252. ${QT_LIBRARY_DIR}/QtXml.framework/Headers
  253. )
  254. # Set QT_QTASSISTANT_INCLUDE_DIR
  255. FIND_PATH( QT_QTASSISTANT_INCLUDE_DIR QtAssistant
  256. ${QT_INCLUDE_DIR}/QtAssistant
  257. ${QT_HEADERS_DIR}/QtAssistant
  258. )
  259. # Set QT_QTDESIGNER_INCLUDE_DIR
  260. FIND_PATH( QT_QTDESIGNER_INCLUDE_DIR QDesignerComponents
  261. ${QT_INCLUDE_DIR}/QtDesigner
  262. ${QT_HEADERS_DIR}/QtDesigner
  263. )
  264. # Make variables changeble to the advanced user
  265. MARK_AS_ADVANCED(
  266. QT_LIBRARY_DIR
  267. QT_INCLUDE_DIR
  268. QT_QT_INCLUDE_DIR
  269. QT_QT3SUPPORT_INCLUDE_DIR
  270. QT_QTASSISTANT_INCLUDE_DIR
  271. QT_QTCORE_INCLUDE_DIR
  272. QT_QTDESIGNER_INCLUDE_DIR
  273. QT_QTGUI_INCLUDE_DIR
  274. QT_QTMOTIF_INCLUDE_DIR
  275. QT_QTNETWORK_INCLUDE_DIR
  276. QT_QTNSPLUGIN_INCLUDE_DIR
  277. QT_QTOPENGL_INCLUDE_DIR
  278. QT_QTSQL_INCLUDE_DIR
  279. QT_QTXML_INCLUDE_DIR
  280. )
  281. # Set QT_INCLUDES
  282. SET( QT_INCLUDES
  283. ${QT_INCLUDE_DIR}
  284. ${QT_QTCORE_INCLUDE_DIR}
  285. ${QT_QT_INCLUDE_DIR}
  286. ${QT_QTGUI_INCLUDE_DIR}
  287. )
  288. # append optional flags
  289. MACRO(QT4_APPEND_INCLUDES_FLAG FLAG)
  290. IF(${FLAG})
  291. SET(QT_INCLUDES ${QT_INCLUDES} "${${FLAG}}")
  292. ENDIF(${FLAG})
  293. ENDMACRO(QT4_APPEND_INCLUDES_FLAG)
  294. QT4_APPEND_INCLUDES_FLAG(QT_QT3SUPPORT_INCLUDE_DIR)
  295. QT4_APPEND_INCLUDES_FLAG(QT_QTASSISTANT_INCLUDE_DIR)
  296. QT4_APPEND_INCLUDES_FLAG(QT_QTDESIGNER_INCLUDE_DIR)
  297. QT4_APPEND_INCLUDES_FLAG(QT_QTDESIGNER_INCLUDE_DIR)
  298. QT4_APPEND_INCLUDES_FLAG(QT_QTMOTIF_INCLUDE_DIR)
  299. QT4_APPEND_INCLUDES_FLAG(QT_QTNETWORK_INCLUDE_DIR)
  300. QT4_APPEND_INCLUDES_FLAG(QT_QTNSPLUGIN_INCLUDE_DIR)
  301. QT4_APPEND_INCLUDES_FLAG(QT_QTOPENGL_INCLUDE_DIR)
  302. QT4_APPEND_INCLUDES_FLAG(QT_QTSQL_INCLUDE_DIR)
  303. QT4_APPEND_INCLUDES_FLAG(QT_QTXML_INCLUDE_DIR)
  304. ########################################
  305. #
  306. # Setting the LIBRARY-Variables
  307. #
  308. ########################################
  309. IF (QT_USE_FRAMEWORKS)
  310. # If FIND_LIBRARY found libraries in Apple frameworks, we would not have
  311. # to jump through these hoops.
  312. SET(QT_QTCORE_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtCore"
  313. CACHE STRING "The QtCore library.")
  314. SET(QT_QTCORE_LIBRARY_DEBUG "-F${QT_LIBRARY_DIR} -framework QtCore"
  315. CACHE STRING "The QtCore library.")
  316. SET(QT_QT3SUPPORT_LIBRARY "-framework Qt3Support"
  317. CACHE STRING "The Qt3Support library.")
  318. SET(QT_QT3SUPPORT_LIBRARY_DEBUG "-framework Qt3Support"
  319. CACHE STRING "The Qt3Support library.")
  320. SET(QT_QTGUI_LIBRARY "-framework QtGui"
  321. CACHE STRING "The QtGui library.")
  322. SET(QT_QTGUI_LIBRARY_DEBUG "-framework QtGui"
  323. CACHE STRING "The QtGui library.")
  324. SET(QT_QTNETWORK_LIBRARY "-framework QtNetwork"
  325. CACHE STRING "The QtNetwork library.")
  326. SET(QT_QTNETWORK_LIBRARY_DEBUG "-framework QtNetwork"
  327. CACHE STRING "The QtNetwork library.")
  328. SET(QT_QTOPENGL_LIBRARY "-framework QtOpenGL"
  329. CACHE STRING "The QtOpenGL library.")
  330. SET(QT_QTOPENGL_LIBRARY_DEBUG "-framework QtOpenGL"
  331. CACHE STRING "The QtOpenGL library.")
  332. SET(QT_QTSQL_LIBRARY "-framework QtSql"
  333. CACHE STRING "The QtSql library.")
  334. SET(QT_QTSQL_LIBRARY_DEBUG "-framework QtSql"
  335. CACHE STRING "The QtSql library.")
  336. SET(QT_QTXML_LIBRARY "-framework QtXml"
  337. CACHE STRING "The QtXml library.")
  338. SET(QT_QTXML_LIBRARY_DEBUG "-framework QtXml"
  339. CACHE STRING "The QtXml library.")
  340. ELSE (QT_USE_FRAMEWORKS)
  341. # Set QT_QTCORE_LIBRARY by searching for a lib with "QtCore." as part of
  342. # the filename
  343. FIND_LIBRARY( QT_QTCORE_LIBRARY
  344. NAMES QtCore QtCore4
  345. PATHS
  346. ${QT_LIBRARY_DIR}
  347. $ENV{QTDIR}/lib
  348. /usr/local/qt/lib
  349. /usr/local/lib
  350. /usr/lib/qt/lib
  351. /usr/lib
  352. /usr/share/qt4/lib
  353. C:/Progra~1/qt/lib
  354. /usr/lib/qt4 )
  355. # Set QT_QTCORE_LIBRARY_DEBUG by searching for a lib with "QtCore_debug"
  356. # as part of the filename
  357. FIND_LIBRARY( QT_QTCORE_LIBRARY_DEBUG
  358. NAMES QtCore_debug QtCored4
  359. PATHS
  360. ${QT_LIBRARY_DIR}
  361. $ENV{QTDIR}/lib
  362. /usr/local/qt/lib
  363. /usr/local/lib
  364. /usr/lib/qt/lib
  365. /usr/lib
  366. /usr/share/qt4/lib
  367. C:/Progra~1/qt/lib
  368. /usr/lib/qt4 )
  369. # Set QT_QT3SUPPORT_LIBRARY
  370. FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY NAMES Qt3Support Qt3Support4 PATHS ${QT_LIBRARY_DIR})
  371. FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG NAMES Qt3Support_debug Qt3Supportd4 PATHS ${QT_LIBRARY_DIR})
  372. # Set QT_QTGUI_LIBRARY
  373. FIND_LIBRARY(QT_QTGUI_LIBRARY NAMES QtGui QtGui4 PATHS ${QT_LIBRARY_DIR})
  374. FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG NAMES QtGui_debug QtGuid4 PATHS ${QT_LIBRARY_DIR})
  375. # Set QT_QTMOTIF_LIBRARY
  376. FIND_LIBRARY(QT_QTMOTIF_LIBRARY NAMES QtMotif PATHS ${QT_LIBRARY_DIR})
  377. FIND_LIBRARY(QT_QTMOTIF_LIBRARY_DEBUG NAMES QtMotif_debug PATHS ${QT_LIBRARY_DIR})
  378. # Set QT_QTNETWORK_LIBRARY
  379. FIND_LIBRARY(QT_QTNETWORK_LIBRARY NAMES QtNetwork QtNetwork4 PATHS ${QT_LIBRARY_DIR})
  380. FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG NAMES QtNetwork_debug QtNetworkd4 PATHS ${QT_LIBRARY_DIR})
  381. # Set QT_QTNSPLUGIN_LIBRARY
  382. FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY NAMES QtNsPlugin PATHS ${QT_LIBRARY_DIR})
  383. FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_DEBUG NAMES QtNsPlugin_debug PATHS ${QT_LIBRARY_DIR})
  384. # Set QT_QTOPENGL_LIBRARY
  385. FIND_LIBRARY(QT_QTOPENGL_LIBRARY NAMES QtOpenGL QtOpenGL4 PATHS ${QT_LIBRARY_DIR})
  386. FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG NAMES QtOpenGL_debug QtOpenGLd4 PATHS ${QT_LIBRARY_DIR})
  387. # Set QT_QTSQL_LIBRARY
  388. FIND_LIBRARY(QT_QTSQL_LIBRARY NAMES QtSql QtSql4 PATHS ${QT_LIBRARY_DIR})
  389. FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG NAMES QtSql_debug QtSqld4 PATHS ${QT_LIBRARY_DIR})
  390. # Set QT_QTXML_LIBRARY
  391. FIND_LIBRARY(QT_QTXML_LIBRARY NAMES QtXml QtXml4 PATHS ${QT_LIBRARY_DIR})
  392. FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG NAMES QtXml_debug QtXmld4 PATHS ${QT_LIBRARY_DIR})
  393. ENDIF (QT_USE_FRAMEWORKS)
  394. # Set QT_QTASSISTANT_LIBRARY
  395. FIND_LIBRARY(QT_QTASSISTANT_LIBRARY NAMES QtAssistant QtAssistant4 PATHS ${QT_LIBRARY_DIR})
  396. FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistant_debug QtAssistantd4 PATHS ${QT_LIBRARY_DIR})
  397. # Set QT_QTDESIGNER_LIBRARY
  398. FIND_LIBRARY(QT_QTDESIGNER_LIBRARY NAMES QtDesigner QtDesigner4 PATHS ${QT_LIBRARY_DIR})
  399. FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_DEBUG NAMES QtDesigner_debug QtDesignerd4 PATHS ${QT_LIBRARY_DIR})
  400. # Make variables changeble to the advanced user
  401. MARK_AS_ADVANCED(
  402. QT_QT3SUPPORT_LIBRARY
  403. QT_QTASSISTANT_LIBRARY
  404. QT_QTCORE_LIBRARY
  405. QT_QTDESIGNER_LIBRARY
  406. QT_QTGUI_LIBRARY
  407. QT_QTMOTIF_LIBRARY
  408. QT_QTNETWORK_LIBRARY
  409. QT_QTNSPLUGIN_LIBRARY
  410. QT_QTOPENGL_LIBRARY
  411. QT_QTSQL_LIBRARY
  412. QT_QTXML_LIBRARY )
  413. # Make variables changeble to the advanced user
  414. MARK_AS_ADVANCED(
  415. QT_QT3SUPPORT_LIBRARY_DEBUG
  416. QT_QTASSISTANT_LIBRARY_DEBUG
  417. QT_QTCORE_LIBRARY_DEBUG
  418. QT_QTDESIGNER_LIBRARY_DEBUG
  419. QT_QTGUI_LIBRARY_DEBUG
  420. QT_QTMOTIF_LIBRARY_DEBUG
  421. QT_QTNETWORK_LIBRARY_DEBUG
  422. QT_QTNSPLUGIN_LIBRARY_DEBUG
  423. QT_QTOPENGL_LIBRARY_DEBUG
  424. QT_QTSQL_LIBRARY_DEBUG
  425. QT_QTXML_LIBRARY_DEBUG )
  426. ############################################
  427. #
  428. # Check the existence of the libraries.
  429. #
  430. ############################################
  431. IF (QT_QTCORE_INCLUDE_DIR AND QT_QTCORE_LIBRARY)
  432. SET(QT_QTCORE_FOUND 1)
  433. IF (NOT QT_QTCORE_LIBRARY_DEBUG)
  434. SET(QT_QTCORE_LIBRARY_DEBUG ${QT_QTCORE_LIBRARY})
  435. ENDIF (NOT QT_QTCORE_LIBRARY_DEBUG)
  436. ENDIF (QT_QTCORE_INCLUDE_DIR AND QT_QTCORE_LIBRARY)
  437. IF (QT_QTGUI_INCLUDE_DIR AND QT_QTGUI_LIBRARY)
  438. SET(QT_QTGUI_FOUND 1)
  439. IF (NOT QT_QTGUI_LIBRARY_DEBUG)
  440. SET(QT_QTGUI_LIBRARY_DEBUG ${QT_QTGUI_LIBRARY})
  441. ENDIF (NOT QT_QTGUI_LIBRARY_DEBUG)
  442. ENDIF (QT_QTGUI_INCLUDE_DIR AND QT_QTGUI_LIBRARY)
  443. IF (QT_QT3SUPPORT_INCLUDE_DIR AND QT_QT3SUPPORT_LIBRARY)
  444. SET(QT_QT3SUPPORT_FOUND 1)
  445. IF (NOT QT_QT3SUPPORT_LIBRARY_DEBUG)
  446. SET(QT_QT3SUPPORT_LIBRARY_DEBUG ${QT_QT3SUPPORT_LIBRARY})
  447. ENDIF (NOT QT_QT3SUPPORT_LIBRARY_DEBUG)
  448. ENDIF (QT_QT3SUPPORT_INCLUDE_DIR AND QT_QT3SUPPORT_LIBRARY)
  449. IF (QT_QTASSISTANT_INCLUDE_DIR AND QT_QTASSISTANT_LIBRARY)
  450. SET(QT_QTASSISTANT_FOUND 1)
  451. IF (NOT QT_QTASSISTANT_LIBRARY_DEBUG)
  452. SET(QT_QTASSISTANT_LIBRARY_DEBUG ${QT_QTASSISTANT_LIBRARY})
  453. ENDIF (NOT QT_QTASSISTANT_LIBRARY_DEBUG)
  454. ENDIF (QT_QTASSISTANT_INCLUDE_DIR AND QT_QTASSISTANT_LIBRARY)
  455. IF (QT_QTDESIGNER_INCLUDE_DIR AND QT_QTDESIGNER_LIBRARY)
  456. SET(QT_QTDESIGNER_FOUND 1)
  457. IF (NOT QT_QTDESIGNER_LIBRARY_DEBUG)
  458. SET(QT_QTDESIGNER_LIBRARY_DEBUG ${QT_QTDESIGNER_LIBRARY})
  459. ENDIF (NOT QT_QTDESIGNER_LIBRARY_DEBUG)
  460. ENDIF (QT_QTDESIGNER_INCLUDE_DIR AND QT_QTDESIGNER_LIBRARY)
  461. IF (QT_QTMOTIF_INCLUDE_DIR AND QT_QTMOTIF_LIBRARY)
  462. SET(QT_QTMOTIF_FOUND 1)
  463. IF (NOT QT_QTMOTIF_LIBRARY_DEBUG)
  464. SET(QT_QTMOTIF_LIBRARY_DEBUG ${QT_QTMOTIF_LIBRARY})
  465. ENDIF (NOT QT_QTMOTIF_LIBRARY_DEBUG)
  466. ENDIF (QT_QTMOTIF_INCLUDE_DIR AND QT_QTMOTIF_LIBRARY)
  467. IF (QT_QTNETWORK_INCLUDE_DIR AND QT_QTNETWORK_LIBRARY)
  468. SET(QT_QTNETWORK_FOUND 1)
  469. IF (NOT QT_QTNETWORK_LIBRARY_DEBUG)
  470. SET(QT_QTNETWORK_LIBRARY_DEBUG ${QT_QTNETWORK_LIBRARY})
  471. ENDIF (NOT QT_QTNETWORK_LIBRARY_DEBUG)
  472. ENDIF (QT_QTNETWORK_INCLUDE_DIR AND QT_QTNETWORK_LIBRARY)
  473. IF (QT_QTNSPLUGIN_INCLUDE_DIR AND QT_QTNSPLUGIN_LIBRARY)
  474. SET(QT_QTNSPLUGIN_FOUND 1)
  475. IF (NOT QT_QTNSPLUGIN_LIBRARY_DEBUG)
  476. SET(QT_QTNSPLUGIN_LIBRARY_DEBUG ${QT_QTNSPLUGIN_LIBRARY})
  477. ENDIF (NOT QT_QTNSPLUGIN_LIBRARY_DEBUG)
  478. ENDIF (QT_QTNSPLUGIN_INCLUDE_DIR AND QT_QTNSPLUGIN_LIBRARY)
  479. IF (QT_QTOPENGL_INCLUDE_DIR AND QT_QTOPENGL_LIBRARY)
  480. SET(QT_QTOPENGL_FOUND 1)
  481. IF (NOT QT_QTOPENGL_LIBRARY_DEBUG)
  482. SET(QT_QTOPENGL_LIBRARY_DEBUG ${QT_QTOPENGL_LIBRARY})
  483. ENDIF (NOT QT_QTOPENGL_LIBRARY_DEBUG)
  484. ENDIF (QT_QTOPENGL_INCLUDE_DIR AND QT_QTOPENGL_LIBRARY)
  485. IF (QT_QTSQL_INCLUDE_DIR AND QT_QTSQL_LIBRARY)
  486. SET(QT_QTSQL_FOUND 1)
  487. IF (NOT QT_QTSQL_LIBRARY_DEBUG)
  488. SET(QT_QTSQL_LIBRARY_DEBUG ${QT_QTSQL_LIBRARY})
  489. ENDIF (NOT QT_QTSQL_LIBRARY_DEBUG)
  490. ENDIF (QT_QTSQL_INCLUDE_DIR AND QT_QTSQL_LIBRARY)
  491. IF (QT_QTXML_INCLUDE_DIR AND QT_QTXML_LIBRARY)
  492. SET(QT_QTXML_FOUND 1)
  493. IF (NOT QT_QTXML_LIBRARY_DEBUG)
  494. SET(QT_QTXML_LIBRARY_DEBUG ${QT_QTXML_LIBRARY})
  495. ENDIF (NOT QT_QTXML_LIBRARY_DEBUG)
  496. ENDIF (QT_QTXML_INCLUDE_DIR AND QT_QTXML_LIBRARY)
  497. #######################################
  498. #
  499. # Check the executables of Qt
  500. # ( moc, uic, rcc )
  501. #
  502. #######################################
  503. IF (NOT QT_BINARY_DIR)
  504. EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
  505. ARGS "-query QT_INSTALL_BINS"
  506. OUTPUT_VARIABLE qt_bins )
  507. SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "")
  508. ENDIF (NOT QT_BINARY_DIR)
  509. FIND_PROGRAM(QT_MOC_EXECUTABLE
  510. NAMES moc
  511. PATHS
  512. ${QT_BINARY_DIR}
  513. $ENV{QTDIR}/bin
  514. /usr/local/qt/bin
  515. /usr/local/bin
  516. /usr/lib/qt/bin
  517. /usr/bin
  518. /usr/share/qt4/bin
  519. C:/Progra~1/qt/bin
  520. /usr/bin/qt4
  521. )
  522. IF(QT_MOC_EXECUTABLE)
  523. SET ( QT_WRAP_CPP "YES")
  524. ENDIF(QT_MOC_EXECUTABLE)
  525. FIND_PROGRAM(QT_UIC_EXECUTABLE
  526. NAMES uic
  527. PATHS
  528. ${QT_BINARY_DIR}
  529. $ENV{QTDIR}/bin
  530. /usr/local/qt/bin
  531. /usr/local/bin
  532. /usr/lib/qt/bin
  533. /usr/bin
  534. /usr/share/qt4/bin
  535. C:/Progra~1/qt/bin
  536. /usr/bin/qt4
  537. )
  538. IF(QT_UIC_EXECUTABLE)
  539. SET ( QT_WRAP_UI "YES")
  540. ENDIF(QT_UIC_EXECUTABLE)
  541. FIND_PROGRAM(QT_RCC_EXECUTABLE
  542. NAMES rcc
  543. PATHS
  544. ${QT_BINARY_DIR}
  545. $ENV{QTDIR}/bin
  546. /usr/local/qt/bin
  547. /usr/local/bin
  548. /usr/lib/qt/bin
  549. /usr/bin
  550. /usr/share/qt4/bin
  551. C:/Progra~1/qt/bin
  552. /usr/bin/qt4
  553. )
  554. MARK_AS_ADVANCED(
  555. QT_UIC_EXECUTABLE
  556. QT_MOC_EXECUTABLE
  557. QT_RCC_EXECUTABLE )
  558. ######################################
  559. #
  560. # Macros for building Qt files
  561. #
  562. ######################################
  563. # QT4_WRAP_CPP(outfiles inputfile ... )
  564. # TODO perhaps add support for -D, -U and other minor options
  565. MACRO(QT4_WRAP_CPP outfiles )
  566. # get include dirs
  567. GET_DIRECTORY_PROPERTY(moc_includes_tmp INCLUDE_DIRECTORIES)
  568. SET(moc_includes)
  569. FOREACH(it ${moc_includes_tmp})
  570. SET(moc_includes ${moc_includes} "-I${it}")
  571. ENDFOREACH(it)
  572. FOREACH(it ${ARGN})
  573. GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
  574. SET(infile ${CMAKE_CURRENT_SOURCE_DIR}/${it})
  575. SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/moc_${outfile}.cxx)
  576. ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
  577. COMMAND ${QT_MOC_EXECUTABLE}
  578. ARGS ${moc_includes} -o ${outfile} ${infile}
  579. MAIN_DEPENDENCY ${infile})
  580. SET(${outfiles} ${${outfiles}} ${outfile})
  581. ENDFOREACH(it)
  582. ENDMACRO(QT4_WRAP_CPP)
  583. # QT4_WRAP_UI(outfiles inputfile ... )
  584. MACRO(QT4_WRAP_UI outfiles )
  585. FOREACH(it ${ARGN})
  586. GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
  587. SET(infile ${CMAKE_CURRENT_SOURCE_DIR}/${it})
  588. SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
  589. ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
  590. COMMAND ${QT_UIC_EXECUTABLE}
  591. ARGS -o ${outfile} ${infile}
  592. MAIN_DEPENDENCY ${infile})
  593. SET(${outfiles} ${${outfiles}} ${outfile})
  594. ENDFOREACH(it)
  595. ENDMACRO(QT4_WRAP_UI)
  596. # QT4_ADD_RESOURCE(outfiles inputfile ... )
  597. # TODO perhaps consider adding support for compression and root options to rcc
  598. MACRO(QT4_ADD_RESOURCES outfiles )
  599. FOREACH(it ${ARGN})
  600. GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
  601. SET(infile ${CMAKE_CURRENT_SOURCE_DIR}/${it})
  602. SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
  603. ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
  604. COMMAND ${QT_RCC_EXECUTABLE}
  605. ARGS -name ${outfilename} -o ${outfile} ${infile}
  606. MAIN_DEPENDENCY ${infile} )
  607. SET(${outfiles} ${${outfiles}} ${outfile})
  608. ENDFOREACH(it)
  609. ENDMACRO(QT4_ADD_RESOURCES)
  610. ######################################
  611. #
  612. # decide if Qt got found
  613. #
  614. ######################################
  615. # if the includes,libraries,moc,uic and rcc are found then we have it
  616. IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
  617. SET( QT4_FOUND "YES" )
  618. IF( NOT Qt4_FIND_QUIETLY)
  619. MESSAGE(STATUS "Found Qt-Version ${QTVERSION}")
  620. ENDIF( NOT Qt4_FIND_QUIETLY)
  621. ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
  622. SET( QT4_FOUND "NO")
  623. IF( Qt4_FIND_REQUIRED)
  624. MESSAGE( FATAL_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!")
  625. ENDIF( Qt4_FIND_REQUIRED)
  626. ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
  627. SET(QT_FOUND ${QT4_FOUND})
  628. #######################################
  629. #
  630. # System dependent settings
  631. #
  632. #######################################
  633. # for unix add X11 stuff
  634. IF(UNIX)
  635. FIND_PACKAGE(X11)
  636. ENDIF(UNIX)
  637. #######################################
  638. #
  639. # compatibility settings
  640. #
  641. #######################################
  642. # Backwards compatibility for CMake1.4 and 1.2
  643. SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} )
  644. SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} )
  645. SET( QT_QT_LIBRARY "")
  646. SET( QT_QTMAIN_LIBRARY "")
  647. ELSE(QT4_QMAKE_FOUND)
  648. IF(QT_QMAKE_EXECUTABLE)
  649. MESSAGE("QT_QMAKE_EXECUTABLE set to qmake version: QTVERSION = ${QTVERSION}\nQT_QMAKE_EXECUTABLE = ${QT_QMAKE_EXECUTABLE}, please set to path to qmake from qt4.")
  650. ENDIF(QT_QMAKE_EXECUTABLE)
  651. IF( Qt4_FIND_REQUIRED)
  652. MESSAGE( FATAL_ERROR "Qt qmake not found!")
  653. ENDIF( Qt4_FIND_REQUIRED)
  654. ENDIF(QT4_QMAKE_FOUND)