Merge topic 'cxx-checks-tolerate-unused-arguments'
[kiteware-cmake.git] / Modules / Qt4ConfigDependentSettings.cmake
blob4699ecdad2922344d3e0f9cff89992fc5811521e
1 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 #[=======================================================================[.rst:
5 Qt4ConfigDependentSettings
6 --------------------------
10 This file is included by FindQt4.cmake, don't include it directly.
11 #]=======================================================================]
13 ###############################################
15 #       configuration/system dependent settings
17 ###############################################
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.
25 set(QT_QTGUI_LIB_DEPENDENCIES "")
26 set(QT_QTCORE_LIB_DEPENDENCIES "")
27 set(QT_QTNETWORK_LIB_DEPENDENCIES "")
28 set(QT_QTOPENGL_LIB_DEPENDENCIES "")
29 set(QT_QTDBUS_LIB_DEPENDENCIES "")
30 set(QT_QTHELP_LIB_DEPENDENCIES ${QT_QTCLUCENE_LIBRARY})
33 if(Q_WS_WIN)
34   # On Windows, qconfig.pri has "shared" for shared library builds
35   if(NOT QT_CONFIG MATCHES "shared")
36     set(QT_IS_STATIC 1)
37   endif()
38 else()
39   # On other platforms, check file extension to know if its static
40   if(QT_QTCORE_LIBRARY_RELEASE)
41     get_filename_component(qtcore_lib_ext "${QT_QTCORE_LIBRARY_RELEASE}" EXT)
42     if("${qtcore_lib_ext}" STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}")
43       set(QT_IS_STATIC 1)
44     endif()
45   endif()
46   if(QT_QTCORE_LIBRARY_DEBUG)
47     get_filename_component(qtcore_lib_ext "${QT_QTCORE_LIBRARY_DEBUG}" EXT)
48     if(${qtcore_lib_ext} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX})
49       set(QT_IS_STATIC 1)
50     endif()
51   endif()
52 endif()
54 # build using shared Qt needs -DQT_DLL on Windows
55 if(Q_WS_WIN  AND  NOT QT_IS_STATIC)
56   set(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_DLL)
57 endif()
59 if(NOT QT_IS_STATIC)
60   return()
61 endif()
63 # QtOpenGL dependencies
64 find_package(OpenGL)
65 set (QT_QTOPENGL_LIB_DEPENDENCIES ${OPENGL_glu_LIBRARY} ${OPENGL_gl_LIBRARY})
68 ## system png
69 if(QT_QCONFIG MATCHES "system-png")
70   find_package(PNG)
71   set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${PNG_LIBRARY})
72 endif()
74 ## system jpeg
75 if(QT_QCONFIG MATCHES "system-jpeg")
76   find_package(JPEG)
77   set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${JPEG_LIBRARIES})
78 endif()
80 ## system tiff
81 if(QT_QCONFIG MATCHES "system-tiff")
82   find_package(TIFF)
83   set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${TIFF_LIBRARIES})
84 endif()
86 ## system mng
87 if(QT_QCONFIG MATCHES "system-mng")
88   find_library(MNG_LIBRARY NAMES mng)
89   set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${MNG_LIBRARY})
90 endif()
92 # for X11, get X11 library directory
93 if(Q_WS_X11)
94   find_package(X11)
95 endif()
98 ## X11 SM
99 if(QT_QCONFIG MATCHES "x11sm")
100   if(X11_SM_LIB AND X11_ICE_LIB)
101     set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_SM_LIB} ${X11_ICE_LIB})
102   endif()
103 endif()
106 ## Xi
107 if(QT_QCONFIG MATCHES "tablet")
108   if(X11_Xi_LIB)
109     set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xi_LIB})
110   endif()
111 endif()
114 ## Xrender
115 if(QT_QCONFIG MATCHES "xrender")
116   if(X11_Xrender_LIB)
117     set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xrender_LIB})
118   endif()
119 endif()
122 ## Xrandr
123 if(QT_QCONFIG MATCHES "xrandr")
124   if(X11_Xrandr_LIB)
125     set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xrandr_LIB})
126   endif()
127 endif()
130 ## Xcursor
131 if(QT_QCONFIG MATCHES "xcursor")
132   if(X11_Xcursor_LIB)
133     set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xcursor_LIB})
134   endif()
135 endif()
138 ## Xinerama
139 if(QT_QCONFIG MATCHES "xinerama")
140   if(X11_Xinerama_LIB)
141     set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xinerama_LIB})
142   endif()
143 endif()
146 ## Xfixes
147 if(QT_QCONFIG MATCHES "xfixes")
148   if(X11_Xfixes_LIB)
149     set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xfixes_LIB})
150   endif()
151 endif()
154 ## fontconfig
155 if(QT_QCONFIG MATCHES "fontconfig")
156   find_library(QT_FONTCONFIG_LIBRARY NAMES fontconfig)
157   mark_as_advanced(QT_FONTCONFIG_LIBRARY)
158   if(QT_FONTCONFIG_LIBRARY)
159     set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY})
160   endif()
161 endif()
164 ## system-freetype
165 if(QT_QCONFIG MATCHES "system-freetype")
166   find_package(Freetype)
167   if(FREETYPE_LIBRARIES)
168     set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${FREETYPE_LIBRARIES})
169   endif()
170 endif()
173 ## system-zlib
174 if(QT_QCONFIG MATCHES "system-zlib")
175   find_package(ZLIB)
176   set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${ZLIB_LIBRARIES})
177 endif()
180 ## openssl
181 if(NOT Q_WS_WIN)
182   set(_QT_NEED_OPENSSL 0)
183   if(QT_VERSION_MINOR LESS 4 AND QT_QCONFIG MATCHES "openssl")
184     set(_QT_NEED_OPENSSL 1)
185   endif()
186   if(QT_VERSION_MINOR GREATER 3 AND QT_QCONFIG MATCHES "openssl-linked")
187     set(_QT_NEED_OPENSSL 1)
188   endif()
189   if(_QT_NEED_OPENSSL)
190     find_package(OpenSSL)
191     if(OPENSSL_LIBRARIES)
192       set(QT_QTNETWORK_LIB_DEPENDENCIES ${QT_QTNETWORK_LIB_DEPENDENCIES} ${OPENSSL_LIBRARIES})
193     endif()
194   endif()
195 endif()
198 ## dbus
199 if(QT_QCONFIG MATCHES "dbus")
201   find_library(QT_DBUS_LIBRARY NAMES dbus-1 )
202   if(QT_DBUS_LIBRARY)
203     set(QT_QTDBUS_LIB_DEPENDENCIES ${QT_QTDBUS_LIB_DEPENDENCIES} ${QT_DBUS_LIBRARY})
204   endif()
205   mark_as_advanced(QT_DBUS_LIBRARY)
207 endif()
210 ## glib
211 if(QT_QCONFIG MATCHES "glib")
213   # Qt 4.2.0+ uses glib-2.0
214   find_library(QT_GLIB_LIBRARY NAMES glib-2.0 )
215   find_library(QT_GTHREAD_LIBRARY NAMES gthread-2.0 )
216   mark_as_advanced(QT_GLIB_LIBRARY)
217   mark_as_advanced(QT_GTHREAD_LIBRARY)
219   if(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY)
220     set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES}
221         ${QT_GTHREAD_LIBRARY} ${QT_GLIB_LIBRARY})
222   endif()
225   # Qt 4.5+ also links to gobject-2.0
226   if(QT_VERSION_MINOR GREATER 4)
227      find_library(QT_GOBJECT_LIBRARY NAMES gobject-2.0 PATHS ${_glib_query_output} )
228      mark_as_advanced(QT_GOBJECT_LIBRARY)
230      if(QT_GOBJECT_LIBRARY)
231        set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES}
232            ${QT_GOBJECT_LIBRARY})
233      endif()
234   endif()
236 endif()
239 ## clock-monotonic, just see if we need to link with rt
240 if(QT_QCONFIG MATCHES "clock-monotonic")
241   set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
242   set(CMAKE_REQUIRED_LIBRARIES rt)
243   CHECK_SYMBOL_EXISTS(_POSIX_TIMERS "unistd.h;time.h" QT_POSIX_TIMERS)
244   set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
245   if(QT_POSIX_TIMERS)
246     find_library(QT_RT_LIBRARY NAMES rt)
247     mark_as_advanced(QT_RT_LIBRARY)
248     if(QT_RT_LIBRARY)
249       set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_RT_LIBRARY})
250     endif()
251   endif()
252 endif()
255 if(Q_WS_X11)
256   # X11 libraries Qt always depends on
257   set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xext_LIB} ${X11_X11_LIB})
259   find_package(Threads)
260   if(CMAKE_USE_PTHREADS_INIT)
261     set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${CMAKE_THREAD_LIBS_INIT})
262   endif()
264   set (QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${CMAKE_DL_LIBS})
266 endif()
269 if(Q_WS_WIN)
270   set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} imm32 winmm)
271   set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ws2_32)
272 endif()
275 if(Q_WS_MAC)
276   set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework Carbon")
278   # Qt 4.0, 4.1, 4.2 use QuickTime
279   if(QT_VERSION_MINOR LESS 3)
280     set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework QuickTime")
281   endif()
283   # Qt 4.2+ use AppKit
284   if(QT_VERSION_MINOR GREATER 1)
285     set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework AppKit")
286   endif()
288   set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} "-framework ApplicationServices")
289 endif()