Qt4ConfigDependentSettings.cmake 7.61 KB
Newer Older
1 2 3
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

4 5 6 7 8 9 10 11
#[=======================================================================[.rst:
Qt4ConfigDependentSettings
--------------------------



This file is included by FindQt4.cmake, don't include it directly.
#]=======================================================================]
12 13 14

###############################################
#
15
#       configuration/system dependent settings
16 17 18 19 20
#
###############################################

# find dependencies for some Qt modules
# when doing builds against a static Qt, they are required
21
# when doing builds against a shared Qt, they are not required
22 23 24
# if a user needs the dependencies, and they couldn't be found, they can set
# the variables themselves.

25 26 27 28 29 30
set(QT_QTGUI_LIB_DEPENDENCIES "")
set(QT_QTCORE_LIB_DEPENDENCIES "")
set(QT_QTNETWORK_LIB_DEPENDENCIES "")
set(QT_QTOPENGL_LIB_DEPENDENCIES "")
set(QT_QTDBUS_LIB_DEPENDENCIES "")
set(QT_QTHELP_LIB_DEPENDENCIES ${QT_QTCLUCENE_LIBRARY})
31 32


33
if(Q_WS_WIN)
34
  # On Windows, qconfig.pri has "shared" for shared library builds
35 36
  if(NOT QT_CONFIG MATCHES "shared")
    set(QT_IS_STATIC 1)
37 38
  endif()
else()
39
  # On other platforms, check file extension to know if its static
40 41 42 43
  if(QT_QTCORE_LIBRARY_RELEASE)
    get_filename_component(qtcore_lib_ext "${QT_QTCORE_LIBRARY_RELEASE}" EXT)
    if("${qtcore_lib_ext}" STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}")
      set(QT_IS_STATIC 1)
44 45
    endif()
  endif()
46 47 48 49
  if(QT_QTCORE_LIBRARY_DEBUG)
    get_filename_component(qtcore_lib_ext "${QT_QTCORE_LIBRARY_DEBUG}" EXT)
    if(${qtcore_lib_ext} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX})
      set(QT_IS_STATIC 1)
50 51 52
    endif()
  endif()
endif()
53 54

# build using shared Qt needs -DQT_DLL on Windows
55 56
if(Q_WS_WIN  AND  NOT QT_IS_STATIC)
  set(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_DLL)
57
endif()
58

59 60
if(NOT QT_IS_STATIC)
  return()
61
endif()
62 63

# QtOpenGL dependencies
64
find_package(OpenGL)
65
set (QT_QTOPENGL_LIB_DEPENDENCIES ${OPENGL_glu_LIBRARY} ${OPENGL_gl_LIBRARY})
66 67 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()
73

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()
79 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()
85 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()
91 92

# for X11, get X11 library directory
93 94
if(Q_WS_X11)
  find_package(X11)
95
endif()
96 97 98


## X11 SM
99 100 101
if(QT_QCONFIG MATCHES "x11sm")
  if(X11_SM_LIB AND X11_ICE_LIB)
    set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_SM_LIB} ${X11_ICE_LIB})
102 103
  endif()
endif()
104 105 106


## Xi
107 108 109
if(QT_QCONFIG MATCHES "tablet")
  if(X11_Xi_LIB)
    set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xi_LIB})
110 111
  endif()
endif()
112 113 114


## Xrender
115 116 117
if(QT_QCONFIG MATCHES "xrender")
  if(X11_Xrender_LIB)
    set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xrender_LIB})
118 119
  endif()
endif()
120 121 122


## Xrandr
123 124 125
if(QT_QCONFIG MATCHES "xrandr")
  if(X11_Xrandr_LIB)
    set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xrandr_LIB})
126 127
  endif()
endif()
128 129 130


## Xcursor
131 132 133
if(QT_QCONFIG MATCHES "xcursor")
  if(X11_Xcursor_LIB)
    set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xcursor_LIB})
134 135
  endif()
endif()
136 137 138


## Xinerama
139 140 141
if(QT_QCONFIG MATCHES "xinerama")
  if(X11_Xinerama_LIB)
    set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xinerama_LIB})
142 143
  endif()
endif()
144 145 146


## Xfixes
147 148 149
if(QT_QCONFIG MATCHES "xfixes")
  if(X11_Xfixes_LIB)
    set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xfixes_LIB})
150 151
  endif()
endif()
152 153 154


## fontconfig
155 156 157 158 159
if(QT_QCONFIG MATCHES "fontconfig")
  find_library(QT_FONTCONFIG_LIBRARY NAMES fontconfig)
  mark_as_advanced(QT_FONTCONFIG_LIBRARY)
  if(QT_FONTCONFIG_LIBRARY)
    set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY})
160 161
  endif()
endif()
162 163


164
## system-freetype
165
if(QT_QCONFIG MATCHES "system-freetype")
166 167
  find_package(Freetype)
  if(FREETYPE_LIBRARIES)
168
    set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${FREETYPE_LIBRARIES})
169 170
  endif()
endif()
171 172


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()
178 179 180


## openssl
181 182 183 184
if(NOT Q_WS_WIN)
  set(_QT_NEED_OPENSSL 0)
  if(QT_VERSION_MINOR LESS 4 AND QT_QCONFIG MATCHES "openssl")
    set(_QT_NEED_OPENSSL 1)
185
  endif()
186 187
  if(QT_VERSION_MINOR GREATER 3 AND QT_QCONFIG MATCHES "openssl-linked")
    set(_QT_NEED_OPENSSL 1)
188
  endif()
189 190 191 192
  if(_QT_NEED_OPENSSL)
    find_package(OpenSSL)
    if(OPENSSL_LIBRARIES)
      set(QT_QTNETWORK_LIB_DEPENDENCIES ${QT_QTNETWORK_LIB_DEPENDENCIES} ${OPENSSL_LIBRARIES})
193 194 195
    endif()
  endif()
endif()
196 197 198


## dbus
199
if(QT_QCONFIG MATCHES "dbus")
200

201 202 203
  find_library(QT_DBUS_LIBRARY NAMES dbus-1 )
  if(QT_DBUS_LIBRARY)
    set(QT_QTDBUS_LIB_DEPENDENCIES ${QT_QTDBUS_LIB_DEPENDENCIES} ${QT_DBUS_LIBRARY})
204
  endif()
205
  mark_as_advanced(QT_DBUS_LIBRARY)
206

207
endif()
208 209 210


## glib
211
if(QT_QCONFIG MATCHES "glib")
212 213

  # Qt 4.2.0+ uses glib-2.0
214 215 216 217
  find_library(QT_GLIB_LIBRARY NAMES glib-2.0 )
  find_library(QT_GTHREAD_LIBRARY NAMES gthread-2.0 )
  mark_as_advanced(QT_GLIB_LIBRARY)
  mark_as_advanced(QT_GTHREAD_LIBRARY)
218

219 220
  if(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY)
    set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES}
221
        ${QT_GTHREAD_LIBRARY} ${QT_GLIB_LIBRARY})
222
  endif()
223 224 225


  # Qt 4.5+ also links to gobject-2.0
226 227 228
  if(QT_VERSION_MINOR GREATER 4)
     find_library(QT_GOBJECT_LIBRARY NAMES gobject-2.0 PATHS ${_glib_query_output} )
     mark_as_advanced(QT_GOBJECT_LIBRARY)
229

230 231
     if(QT_GOBJECT_LIBRARY)
       set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES}
232
           ${QT_GOBJECT_LIBRARY})
233 234
     endif()
  endif()
235

236
endif()
237 238 239


## clock-monotonic, just see if we need to link with rt
240 241 242
if(QT_QCONFIG MATCHES "clock-monotonic")
  set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
  set(CMAKE_REQUIRED_LIBRARIES rt)
243
  CHECK_SYMBOL_EXISTS(_POSIX_TIMERS "unistd.h;time.h" QT_POSIX_TIMERS)
244 245 246 247 248 249
  set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
  if(QT_POSIX_TIMERS)
    find_library(QT_RT_LIBRARY NAMES rt)
    mark_as_advanced(QT_RT_LIBRARY)
    if(QT_RT_LIBRARY)
      set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_RT_LIBRARY})
250 251 252
    endif()
  endif()
endif()
253 254 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})
258

259 260
  find_package(Threads)
  if(CMAKE_USE_PTHREADS_INIT)
261
    set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${CMAKE_THREAD_LIBS_INIT})
262
  endif()
263

264
  set (QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${CMAKE_DL_LIBS})
265

266
endif()
267 268


269 270 271
if(Q_WS_WIN)
  set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} imm32 winmm)
  set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ws2_32)
272
endif()
273 274


275 276
if(Q_WS_MAC)
  set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework Carbon")
277 278

  # Qt 4.0, 4.1, 4.2 use QuickTime
279 280
  if(QT_VERSION_MINOR LESS 3)
    set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework QuickTime")
281
  endif()
282 283

  # Qt 4.2+ use AppKit
284 285
  if(QT_VERSION_MINOR GREATER 1)
    set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} "-framework AppKit")
286
  endif()
287

288
  set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} "-framework ApplicationServices")
289
endif()
290