Qt4ConfigDependentSettings.cmake 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. Qt4ConfigDependentSettings
  5. --------------------------
  6. This file is included by FindQt4.cmake, don't include it directly.
  7. #]=======================================================================]
  8. ###############################################
  9. #
  10. # configuration/system dependent settings
  11. #
  12. ###############################################
  13. # find dependencies for some Qt modules
  14. # when doing builds against a static Qt, they are required
  15. # when doing builds against a shared Qt, they are not required
  16. # if a user needs the dependencies, and they couldn't be found, they can set
  17. # the variables themselves.
  18. set(QT_QTGUI_LIB_DEPENDENCIES "")
  19. set(QT_QTCORE_LIB_DEPENDENCIES "")
  20. set(QT_QTNETWORK_LIB_DEPENDENCIES "")
  21. set(QT_QTOPENGL_LIB_DEPENDENCIES "")
  22. set(QT_QTDBUS_LIB_DEPENDENCIES "")
  23. set(QT_QTHELP_LIB_DEPENDENCIES ${QT_QTCLUCENE_LIBRARY})
  24. if(Q_WS_WIN)
  25. # On Windows, qconfig.pri has "shared" for shared library builds
  26. if(NOT QT_CONFIG MATCHES "shared")
  27. set(QT_IS_STATIC 1)
  28. endif()
  29. else()
  30. # On other platforms, check file extension to know if its static
  31. if(QT_QTCORE_LIBRARY_RELEASE)
  32. get_filename_component(qtcore_lib_ext "${QT_QTCORE_LIBRARY_RELEASE}" EXT)
  33. if("${qtcore_lib_ext}" STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}")
  34. set(QT_IS_STATIC 1)
  35. endif()
  36. endif()
  37. if(QT_QTCORE_LIBRARY_DEBUG)
  38. get_filename_component(qtcore_lib_ext "${QT_QTCORE_LIBRARY_DEBUG}" EXT)
  39. if(${qtcore_lib_ext} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX})
  40. set(QT_IS_STATIC 1)
  41. endif()
  42. endif()
  43. endif()
  44. # build using shared Qt needs -DQT_DLL on Windows
  45. if(Q_WS_WIN AND NOT QT_IS_STATIC)
  46. set(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_DLL)
  47. endif()
  48. if(NOT QT_IS_STATIC)
  49. return()
  50. endif()
  51. # QtOpenGL dependencies
  52. find_package(OpenGL)
  53. set (QT_QTOPENGL_LIB_DEPENDENCIES ${OPENGL_glu_LIBRARY} ${OPENGL_gl_LIBRARY})
  54. ## system png
  55. if(QT_QCONFIG MATCHES "system-png")
  56. find_package(PNG)
  57. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${PNG_LIBRARY})
  58. endif()
  59. ## system jpeg
  60. if(QT_QCONFIG MATCHES "system-jpeg")
  61. find_package(JPEG)
  62. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${JPEG_LIBRARIES})
  63. endif()
  64. ## system tiff
  65. if(QT_QCONFIG MATCHES "system-tiff")
  66. find_package(TIFF)
  67. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${TIFF_LIBRARIES})
  68. endif()
  69. ## system mng
  70. if(QT_QCONFIG MATCHES "system-mng")
  71. find_library(MNG_LIBRARY NAMES mng)
  72. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${MNG_LIBRARY})
  73. endif()
  74. # for X11, get X11 library directory
  75. if(Q_WS_X11)
  76. find_package(X11)
  77. endif()
  78. ## X11 SM
  79. if(QT_QCONFIG MATCHES "x11sm")
  80. if(X11_SM_LIB AND X11_ICE_LIB)
  81. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_SM_LIB} ${X11_ICE_LIB})
  82. endif()
  83. endif()
  84. ## Xi
  85. if(QT_QCONFIG MATCHES "tablet")
  86. if(X11_Xi_LIB)
  87. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xi_LIB})
  88. endif()
  89. endif()
  90. ## Xrender
  91. if(QT_QCONFIG MATCHES "xrender")
  92. if(X11_Xrender_LIB)
  93. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xrender_LIB})
  94. endif()
  95. endif()
  96. ## Xrandr
  97. if(QT_QCONFIG MATCHES "xrandr")
  98. if(X11_Xrandr_LIB)
  99. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xrandr_LIB})
  100. endif()
  101. endif()
  102. ## Xcursor
  103. if(QT_QCONFIG MATCHES "xcursor")
  104. if(X11_Xcursor_LIB)
  105. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xcursor_LIB})
  106. endif()
  107. endif()
  108. ## Xinerama
  109. if(QT_QCONFIG MATCHES "xinerama")
  110. if(X11_Xinerama_LIB)
  111. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xinerama_LIB})
  112. endif()
  113. endif()
  114. ## Xfixes
  115. if(QT_QCONFIG MATCHES "xfixes")
  116. if(X11_Xfixes_LIB)
  117. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xfixes_LIB})
  118. endif()
  119. endif()
  120. ## fontconfig
  121. if(QT_QCONFIG MATCHES "fontconfig")
  122. find_library(QT_FONTCONFIG_LIBRARY NAMES fontconfig)
  123. mark_as_advanced(QT_FONTCONFIG_LIBRARY)
  124. if(QT_FONTCONFIG_LIBRARY)
  125. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY})
  126. endif()
  127. endif()
  128. ## system-freetype
  129. if(QT_QCONFIG MATCHES "system-freetype")
  130. find_package(Freetype)
  131. if(FREETYPE_LIBRARIES)
  132. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${FREETYPE_LIBRARIES})
  133. endif()
  134. endif()
  135. ## system-zlib
  136. if(QT_QCONFIG MATCHES "system-zlib")
  137. find_package(ZLIB)
  138. set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${ZLIB_LIBRARIES})
  139. endif()
  140. ## openssl
  141. if(NOT Q_WS_WIN)
  142. set(_QT_NEED_OPENSSL 0)
  143. if(QT_VERSION_MINOR LESS 4 AND QT_QCONFIG MATCHES "openssl")
  144. set(_QT_NEED_OPENSSL 1)
  145. endif()
  146. if(QT_VERSION_MINOR GREATER 3 AND QT_QCONFIG MATCHES "openssl-linked")
  147. set(_QT_NEED_OPENSSL 1)
  148. endif()
  149. if(_QT_NEED_OPENSSL)
  150. find_package(OpenSSL)
  151. if(OPENSSL_LIBRARIES)
  152. set(QT_QTNETWORK_LIB_DEPENDENCIES ${QT_QTNETWORK_LIB_DEPENDENCIES} ${OPENSSL_LIBRARIES})
  153. endif()
  154. endif()
  155. endif()
  156. ## dbus
  157. if(QT_QCONFIG MATCHES "dbus")
  158. find_library(QT_DBUS_LIBRARY NAMES dbus-1 )
  159. if(QT_DBUS_LIBRARY)
  160. set(QT_QTDBUS_LIB_DEPENDENCIES ${QT_QTDBUS_LIB_DEPENDENCIES} ${QT_DBUS_LIBRARY})
  161. endif()
  162. mark_as_advanced(QT_DBUS_LIBRARY)
  163. endif()
  164. ## glib
  165. if(QT_QCONFIG MATCHES "glib")
  166. # Qt 4.2.0+ uses glib-2.0
  167. find_library(QT_GLIB_LIBRARY NAMES glib-2.0 )
  168. find_library(QT_GTHREAD_LIBRARY NAMES gthread-2.0 )
  169. mark_as_advanced(QT_GLIB_LIBRARY)
  170. mark_as_advanced(QT_GTHREAD_LIBRARY)
  171. if(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY)
  172. set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES}
  173. ${QT_GTHREAD_LIBRARY} ${QT_GLIB_LIBRARY})
  174. endif()
  175. # Qt 4.5+ also links to gobject-2.0
  176. if(QT_VERSION_MINOR GREATER 4)
  177. find_library(QT_GOBJECT_LIBRARY NAMES gobject-2.0 PATHS ${_glib_query_output} )
  178. mark_as_advanced(QT_GOBJECT_LIBRARY)
  179. if(QT_GOBJECT_LIBRARY)
  180. set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES}
  181. ${QT_GOBJECT_LIBRARY})
  182. endif()
  183. endif()
  184. endif()
  185. ## clock-monotonic, just see if we need to link with rt
  186. if(QT_QCONFIG MATCHES "clock-monotonic")
  187. set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
  188. set(CMAKE_REQUIRED_LIBRARIES rt)
  189. CHECK_SYMBOL_EXISTS(_POSIX_TIMERS "unistd.h;time.h" QT_POSIX_TIMERS)
  190. set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
  191. if(QT_POSIX_TIMERS)
  192. find_library(QT_RT_LIBRARY NAMES rt)
  193. mark_as_advanced(QT_RT_LIBRARY)
  194. if(QT_RT_LIBRARY)
  195. set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_RT_LIBRARY})
  196. endif()
  197. endif()
  198. endif()
  199. if(Q_WS_X11)
  200. # X11 libraries Qt always depends on
  201. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xext_LIB} ${X11_X11_LIB})
  202. find_package(Threads)
  203. if(CMAKE_USE_PTHREADS_INIT)
  204. set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${CMAKE_THREAD_LIBS_INIT})
  205. endif()
  206. set (QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${CMAKE_DL_LIBS})
  207. endif()
  208. if(Q_WS_WIN)
  209. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} imm32 winmm)
  210. set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ws2_32)
  211. endif()
  212. if(Q_WS_MAC)
  213. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework Carbon")
  214. # Qt 4.0, 4.1, 4.2 use QuickTime
  215. if(QT_VERSION_MINOR LESS 3)
  216. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework QuickTime")
  217. endif()
  218. # Qt 4.2+ use AppKit
  219. if(QT_VERSION_MINOR GREATER 1)
  220. set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework AppKit")
  221. endif()
  222. set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} "-framework ApplicationServices")
  223. endif()