Qt4ConfigDependentSettings.cmake 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. # This file is included by FindQt4.cmake, don't include it directly.
  2. #=============================================================================
  3. # Copyright 2005-2009 Kitware, Inc.
  4. #
  5. # Distributed under the OSI-approved BSD License (the "License");
  6. # see accompanying file Copyright.txt for details.
  7. #
  8. # This software is distributed WITHOUT ANY WARRANTY; without even the
  9. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. # See the License for more information.
  11. #=============================================================================
  12. # (To distributed this file outside of CMake, substitute the full
  13. # License text for the above reference.)
  14. ###############################################
  15. #
  16. # configuration/system dependent settings
  17. #
  18. ###############################################
  19. # find dependencies for some Qt modules
  20. # when doing builds against a static Qt, they are required
  21. # when doing builds against a shared Qt, they are not required
  22. # if a user needs the dependencies, and they couldn't be found, they can set
  23. # the variables themselves.
  24. SET(QT_QTGUI_LIB_DEPENDENCIES "")
  25. SET(QT_QTCORE_LIB_DEPENDENCIES "")
  26. SET(QT_QTNETWORK_LIB_DEPENDENCIES "")
  27. SET(QT_QTOPENGL_LIB_DEPENDENCIES "")
  28. SET(QT_QTDBUS_LIB_DEPENDENCIES "")
  29. SET(QT_QTHELP_LIB_DEPENDENCIES ${QT_QTCLUCENE_LIBRARY})
  30. IF(WIN32)
  31. # On Windows, qconfig.pri has "static" for static library builds
  32. IF(QT_CONFIG MATCHES "static")
  33. SET(QT_IS_STATIC 1)
  34. ENDIF(QT_CONFIG MATCHES "static")
  35. ELSE(WIN32)
  36. # On other platforms, check file extension to know if its static
  37. IF(QT_QTCORE_LIBRARY_RELEASE)
  38. GET_FILENAME_COMPONENT(qtcore_lib_ext "${QT_QTCORE_LIBRARY_RELEASE}" EXT)
  39. IF("${qtcore_lib_ext}" STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}")
  40. SET(QT_IS_STATIC 1)
  41. ENDIF("${qtcore_lib_ext}" STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}")
  42. ENDIF(QT_QTCORE_LIBRARY_RELEASE)
  43. IF(QT_QTCORE_LIBRARY_DEBUG)
  44. GET_FILENAME_COMPONENT(qtcore_lib_ext "${QT_QTCORE_LIBRARY_DEBUG}" EXT)
  45. IF(${qtcore_lib_ext} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX})
  46. SET(QT_IS_STATIC 1)
  47. ENDIF(${qtcore_lib_ext} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX})
  48. ENDIF(QT_QTCORE_LIBRARY_DEBUG)
  49. ENDIF(WIN32)
  50. # build using shared Qt needs -DQT_DLL on Windows
  51. IF(WIN32 AND NOT QT_IS_STATIC)
  52. SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_DLL)
  53. ENDIF(WIN32 AND NOT QT_IS_STATIC)
  54. # QtOpenGL dependencies
  55. QT_QUERY_QMAKE(QMAKE_LIBS_OPENGL "QMAKE_LIBS_OPENGL")
  56. IF(Q_WS_MAC)
  57. # On the Mac OpenGL is probably frameworks and QMAKE_LIBS_OPENGL can be
  58. # e.g. "-framework OpenGL -framework AGL". The separate_arguments() call in
  59. # the other branch makes "-framework;-OpenGL;-framework;-lAGL" appear in the
  60. # linker command. So we need to protect the "-framework foo" as
  61. # non-separatable strings. We do this by replacing the space after
  62. # "-framework" with an underscore, then calling separate_arguments(), and
  63. # then we replace the underscores again with spaces. So we get proper linker
  64. # commands. Alex
  65. STRING(REGEX REPLACE "-framework +" "-framework_" QMAKE_LIBS_OPENGL "${QMAKE_LIBS_OPENGL}")
  66. SEPARATE_ARGUMENTS(QMAKE_LIBS_OPENGL)
  67. STRING(REGEX REPLACE "-framework_" "-framework " QMAKE_LIBS_OPENGL "${QMAKE_LIBS_OPENGL}")
  68. ELSE(Q_WS_MAC)
  69. SEPARATE_ARGUMENTS(QMAKE_LIBS_OPENGL)
  70. ENDIF(Q_WS_MAC)
  71. SET (QT_QTOPENGL_LIB_DEPENDENCIES ${QT_QTOPENGL_LIB_DEPENDENCIES} ${QMAKE_LIBS_OPENGL})
  72. ## system png
  73. IF(QT_QCONFIG MATCHES "system-png")
  74. FIND_LIBRARY(QT_PNG_LIBRARY NAMES png)
  75. MARK_AS_ADVANCED(QT_PNG_LIBRARY)
  76. IF(QT_PNG_LIBRARY)
  77. SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY})
  78. ENDIF(QT_PNG_LIBRARY)
  79. ENDIF(QT_QCONFIG MATCHES "system-png")
  80. # for X11, get X11 library directory
  81. IF(Q_WS_X11)
  82. QT_QUERY_QMAKE(QMAKE_LIBDIR_X11 "QMAKE_LIBDIR_X11")
  83. ENDIF(Q_WS_X11)
  84. ## X11 SM
  85. IF(QT_QCONFIG MATCHES "x11sm")
  86. # ask qmake where the x11 libs are
  87. FIND_LIBRARY(QT_X11_SM_LIBRARY NAMES SM PATHS ${QMAKE_LIBDIR_X11})
  88. FIND_LIBRARY(QT_X11_ICE_LIBRARY NAMES ICE PATHS ${QMAKE_LIBDIR_X11})
  89. MARK_AS_ADVANCED(QT_X11_SM_LIBRARY)
  90. MARK_AS_ADVANCED(QT_X11_ICE_LIBRARY)
  91. IF(QT_X11_SM_LIBRARY AND QT_X11_ICE_LIBRARY)
  92. SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_X11_SM_LIBRARY} ${QT_X11_ICE_LIBRARY})
  93. ENDIF(QT_X11_SM_LIBRARY AND QT_X11_ICE_LIBRARY)
  94. ENDIF(QT_QCONFIG MATCHES "x11sm")
  95. ## Xi
  96. IF(QT_QCONFIG MATCHES "tablet")
  97. FIND_LIBRARY(QT_XI_LIBRARY NAMES Xi PATHS ${QMAKE_LIBDIR_X11})
  98. MARK_AS_ADVANCED(QT_XI_LIBRARY)
  99. IF(QT_XI_LIBRARY)
  100. SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XI_LIBRARY})
  101. ENDIF(QT_XI_LIBRARY)
  102. ENDIF(QT_QCONFIG MATCHES "tablet")
  103. ## Xrender
  104. IF(QT_QCONFIG MATCHES "xrender")
  105. FIND_LIBRARY(QT_XRENDER_LIBRARY NAMES Xrender PATHS ${QMAKE_LIBDIR_X11})
  106. MARK_AS_ADVANCED(QT_XRENDER_LIBRARY)
  107. IF(QT_XRENDER_LIBRARY)
  108. SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRENDER_LIBRARY})
  109. ENDIF(QT_XRENDER_LIBRARY)
  110. ENDIF(QT_QCONFIG MATCHES "xrender")
  111. ## Xrandr
  112. IF(QT_QCONFIG MATCHES "xrandr")
  113. FIND_LIBRARY(QT_XRANDR_LIBRARY NAMES Xrandr PATHS ${QMAKE_LIBDIR_X11})
  114. MARK_AS_ADVANCED(QT_XRANDR_LIBRARY)
  115. IF(QT_XRANDR_LIBRARY)
  116. SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRANDR_LIBRARY})
  117. ENDIF(QT_XRANDR_LIBRARY)
  118. ENDIF(QT_QCONFIG MATCHES "xrandr")
  119. ## Xcursor
  120. IF(QT_QCONFIG MATCHES "xcursor")
  121. FIND_LIBRARY(QT_XCURSOR_LIBRARY NAMES Xcursor PATHS ${QMAKE_LIBDIR_X11})
  122. MARK_AS_ADVANCED(QT_XCURSOR_LIBRARY)
  123. IF(QT_XCURSOR_LIBRARY)
  124. SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XCURSOR_LIBRARY})
  125. ENDIF(QT_XCURSOR_LIBRARY)
  126. ENDIF(QT_QCONFIG MATCHES "xcursor")
  127. ## Xinerama
  128. IF(QT_QCONFIG MATCHES "xinerama")
  129. FIND_LIBRARY(QT_XINERAMA_LIBRARY NAMES Xinerama PATHS ${QMAKE_LIBDIR_X11})
  130. MARK_AS_ADVANCED(QT_XINERAMA_LIBRARY)
  131. IF(QT_XINERAMA_LIBRARY)
  132. SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XINERAMA_LIBRARY})
  133. ENDIF(QT_XINERAMA_LIBRARY)
  134. ENDIF(QT_QCONFIG MATCHES "xinerama")
  135. ## Xfixes
  136. IF(QT_QCONFIG MATCHES "xfixes")
  137. FIND_LIBRARY(QT_XFIXES_LIBRARY NAMES Xfixes PATHS ${QMAKE_LIBDIR_X11})
  138. MARK_AS_ADVANCED(QT_XFIXES_LIBRARY)
  139. IF(QT_XFIXES_LIBRARY)
  140. SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XFIXES_LIBRARY})
  141. ENDIF(QT_XFIXES_LIBRARY)
  142. ENDIF(QT_QCONFIG MATCHES "xfixes")
  143. ## system-freetype
  144. IF(QT_QCONFIG MATCHES "system-freetype")
  145. FIND_LIBRARY(QT_FREETYPE_LIBRARY NAMES freetype)
  146. MARK_AS_ADVANCED(QT_FREETYPE_LIBRARY)
  147. IF(QT_FREETYPE_LIBRARY)
  148. SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY})
  149. ENDIF(QT_FREETYPE_LIBRARY)
  150. ENDIF(QT_QCONFIG MATCHES "system-freetype")
  151. ## fontconfig
  152. IF(QT_QCONFIG MATCHES "fontconfig")
  153. FIND_LIBRARY(QT_FONTCONFIG_LIBRARY NAMES fontconfig)
  154. MARK_AS_ADVANCED(QT_FONTCONFIG_LIBRARY)
  155. IF(QT_FONTCONFIG_LIBRARY)
  156. SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY})
  157. ENDIF(QT_FONTCONFIG_LIBRARY)
  158. ENDIF(QT_QCONFIG MATCHES "fontconfig")
  159. ## system-zlib
  160. IF(QT_QCONFIG MATCHES "system-zlib")
  161. FIND_LIBRARY(QT_ZLIB_LIBRARY NAMES z)
  162. MARK_AS_ADVANCED(QT_ZLIB_LIBRARY)
  163. IF(QT_ZLIB_LIBRARY)
  164. SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY})
  165. ENDIF(QT_ZLIB_LIBRARY)
  166. ENDIF(QT_QCONFIG MATCHES "system-zlib")
  167. ## openssl
  168. IF(NOT Q_WS_WIN)
  169. SET(_QT_NEED_OPENSSL 0)
  170. IF(QT_VERSION_MINOR LESS 4 AND QT_QCONFIG MATCHES "openssl")
  171. SET(_QT_NEED_OPENSSL 1)
  172. ENDIF(QT_VERSION_MINOR LESS 4 AND QT_QCONFIG MATCHES "openssl")
  173. IF(QT_VERSION_MINOR GREATER 3 AND QT_QCONFIG MATCHES "openssl-linked")
  174. SET(_QT_NEED_OPENSSL 1)
  175. ENDIF(QT_VERSION_MINOR GREATER 3 AND QT_QCONFIG MATCHES "openssl-linked")
  176. IF(_QT_NEED_OPENSSL)
  177. FIND_PACKAGE(OpenSSL)
  178. IF(OPENSSL_LIBRARIES)
  179. SET(QT_QTNETWORK_LIB_DEPENDENCIES ${QT_QTNETWORK_LIB_DEPENDENCIES} ${OPENSSL_LIBRARIES})
  180. ENDIF(OPENSSL_LIBRARIES)
  181. ENDIF(_QT_NEED_OPENSSL)
  182. ENDIF(NOT Q_WS_WIN)
  183. ## dbus
  184. IF(QT_QCONFIG MATCHES "dbus")
  185. # if the dbus library isn't found, we'll assume its not required to build
  186. # shared Qt on Linux doesn't require it
  187. IF(NOT QT_DBUS_LIBRARY)
  188. EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L dbus-1
  189. OUTPUT_VARIABLE _dbus_query_output
  190. RESULT_VARIABLE _dbus_result
  191. ERROR_VARIABLE _dbus_query_output )
  192. IF(_dbus_result MATCHES 0)
  193. STRING(REPLACE "-L" "" _dbus_query_output "${_dbus_query_output}")
  194. SEPARATE_ARGUMENTS(_dbus_query_output)
  195. ELSE(_dbus_result MATCHES 0)
  196. SET(_dbus_query_output)
  197. ENDIF(_dbus_result MATCHES 0)
  198. FIND_LIBRARY(QT_DBUS_LIBRARY NAMES dbus-1 PATHS ${_dbus_query_output} )
  199. IF(QT_DBUS_LIBRARY)
  200. SET(QT_QTDBUS_LIB_DEPENDENCIES ${QT_QTDBUS_LIB_DEPENDENCIES} ${QT_DBUS_LIBRARY})
  201. ENDIF(QT_DBUS_LIBRARY)
  202. MARK_AS_ADVANCED(QT_DBUS_LIBRARY)
  203. ENDIF(NOT QT_DBUS_LIBRARY)
  204. ENDIF(QT_QCONFIG MATCHES "dbus")
  205. ## glib
  206. IF(QT_QCONFIG MATCHES "glib")
  207. # if the glib libraries aren't found, we'll assume its not required to build
  208. # shared Qt on Linux doesn't require it
  209. # Qt 4.2.0+ uses glib-2.0
  210. IF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY)
  211. EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L glib-2.0 gthread-2.0
  212. OUTPUT_VARIABLE _glib_query_output
  213. RESULT_VARIABLE _glib_result
  214. ERROR_VARIABLE _glib_query_output )
  215. IF(_glib_result MATCHES 0)
  216. STRING(REPLACE "-L" "" _glib_query_output "${_glib_query_output}")
  217. SEPARATE_ARGUMENTS(_glib_query_output)
  218. ELSE(_glib_result MATCHES 0)
  219. SET(_glib_query_output)
  220. ENDIF(_glib_result MATCHES 0)
  221. FIND_LIBRARY(QT_GLIB_LIBRARY NAMES glib-2.0 PATHS ${_glib_query_output} )
  222. FIND_LIBRARY(QT_GTHREAD_LIBRARY NAMES gthread-2.0 PATHS ${_glib_query_output} )
  223. MARK_AS_ADVANCED(QT_GLIB_LIBRARY)
  224. MARK_AS_ADVANCED(QT_GTHREAD_LIBRARY)
  225. ENDIF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY)
  226. IF(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY)
  227. SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES}
  228. ${QT_GTHREAD_LIBRARY} ${QT_GLIB_LIBRARY})
  229. ENDIF(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY)
  230. # Qt 4.5+ also links to gobject-2.0
  231. IF(QT_VERSION_MINOR GREATER 4)
  232. IF(NOT QT_GOBJECT_LIBRARY)
  233. EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L gobject-2.0
  234. OUTPUT_VARIABLE _glib_query_output
  235. RESULT_VARIABLE _glib_result
  236. ERROR_VARIABLE _glib_query_output )
  237. IF(_glib_result MATCHES 0)
  238. STRING(REPLACE "-L" "" _glib_query_output "${_glib_query_output}")
  239. SEPARATE_ARGUMENTS(_glib_query_output)
  240. ELSE(_glib_result MATCHES 0)
  241. SET(_glib_query_output)
  242. ENDIF(_glib_result MATCHES 0)
  243. FIND_LIBRARY(QT_GOBJECT_LIBRARY NAMES gobject-2.0 PATHS ${_glib_query_output} )
  244. MARK_AS_ADVANCED(QT_GOBJECT_LIBRARY)
  245. ENDIF(NOT QT_GOBJECT_LIBRARY)
  246. IF(QT_GOBJECT_LIBRARY)
  247. SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES}
  248. ${QT_GOBJECT_LIBRARY})
  249. ENDIF(QT_GOBJECT_LIBRARY)
  250. ENDIF(QT_VERSION_MINOR GREATER 4)
  251. ENDIF(QT_QCONFIG MATCHES "glib")
  252. ## clock-monotonic, just see if we need to link with rt
  253. IF(QT_QCONFIG MATCHES "clock-monotonic")
  254. SET(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
  255. SET(CMAKE_REQUIRED_LIBRARIES rt)
  256. CHECK_SYMBOL_EXISTS(_POSIX_TIMERS "unistd.h;time.h" QT_POSIX_TIMERS)
  257. SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
  258. IF(QT_POSIX_TIMERS)
  259. FIND_LIBRARY(QT_RT_LIBRARY NAMES rt)
  260. MARK_AS_ADVANCED(QT_RT_LIBRARY)
  261. IF(QT_RT_LIBRARY)
  262. SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_RT_LIBRARY})
  263. ENDIF(QT_RT_LIBRARY)
  264. ENDIF(QT_POSIX_TIMERS)
  265. ENDIF(QT_QCONFIG MATCHES "clock-monotonic")
  266. IF(Q_WS_X11)
  267. # X11 libraries Qt absolutely depends on
  268. QT_QUERY_QMAKE(QT_LIBS_X11 "QMAKE_LIBS_X11")
  269. SEPARATE_ARGUMENTS(QT_LIBS_X11)
  270. FOREACH(QT_X11_LIB ${QT_LIBS_X11})
  271. STRING(REGEX REPLACE "-l" "" QT_X11_LIB "${QT_X11_LIB}")
  272. SET(QT_TMP_STR "QT_X11_${QT_X11_LIB}_LIBRARY")
  273. FIND_LIBRARY(${QT_TMP_STR} NAMES "${QT_X11_LIB}" PATHS ${QMAKE_LIBDIR_X11})
  274. MARK_AS_ADVANCED(${QT_TMP_STR})
  275. IF(${QT_TMP_STR})
  276. SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${${QT_TMP_STR}})
  277. ENDIF(${QT_TMP_STR})
  278. ENDFOREACH(QT_X11_LIB)
  279. QT_QUERY_QMAKE(QT_LIBS_THREAD "QMAKE_LIBS_THREAD")
  280. SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_LIBS_THREAD})
  281. QT_QUERY_QMAKE(QMAKE_LIBS_DYNLOAD "QMAKE_LIBS_DYNLOAD")
  282. SET (QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QMAKE_LIBS_DYNLOAD})
  283. ENDIF(Q_WS_X11)
  284. IF(Q_WS_WIN)
  285. SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} imm32 winmm)
  286. SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ws2_32)
  287. ENDIF(Q_WS_WIN)
  288. IF(Q_WS_MAC)
  289. SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework Carbon")
  290. # Qt 4.0, 4.1, 4.2 use QuickTime
  291. IF(QT_VERSION_MINOR LESS 3)
  292. SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework QuickTime")
  293. ENDIF(QT_VERSION_MINOR LESS 3)
  294. # Qt 4.2+ use AppKit
  295. IF(QT_VERSION_MINOR GREATER 1)
  296. SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework AppKit")
  297. ENDIF(QT_VERSION_MINOR GREATER 1)
  298. SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} "-framework ApplicationServices")
  299. ENDIF(Q_WS_MAC)