a75b90eee9de31a028a6920dcc7627a173e46853
[WebKit-https.git] / Source / cmake / OptionsGTK.cmake
1 include(GNUInstallDirs)
2
3 set(PROJECT_VERSION_MAJOR 2)
4 set(PROJECT_VERSION_MINOR 7)
5 set(PROJECT_VERSION_MICRO 1)
6 set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_MICRO})
7 set(WEBKITGTK_API_VERSION 4.0)
8
9 # Libtool library version, not to be confused with API version.
10 # See http://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html
11 CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(WEBKIT2 39 0 2)
12 CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(JAVASCRIPTCORE 19 0 1)
13
14 set(ENABLE_CREDENTIAL_STORAGE ON CACHE BOOL "Whether or not to enable support for credential storage using libsecret.")
15 set(ENABLE_GTKDOC OFF CACHE BOOL "Whether or not to use generate gtkdoc.")
16 set(ENABLE_X11_TARGET ON CACHE BOOL "Whether to enable support for the X11 windowing target.")
17 set(ENABLE_WAYLAND_TARGET OFF CACHE BOOL "Whether to enable support for the Wayland windowing target.")
18
19 # These are shared variables, but we special case their definition so that we can use the
20 # CMAKE_INSTALL_* variables that are populated by the GNUInstallDirs macro.
21 set(LIB_INSTALL_DIR "${CMAKE_INSTALL_FULL_LIBDIR}" CACHE PATH "Absolute path to library installation directory")
22 set(EXEC_INSTALL_DIR "${CMAKE_INSTALL_FULL_BINDIR}" CACHE PATH "Absolute path to executable installation directory")
23 set(LIBEXEC_INSTALL_DIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}/webkit2gtk-${WEBKITGTK_API_VERSION}" CACHE PATH "Absolute path to install executables executed by the library")
24
25 set(DATA_BUILD_DIR "${CMAKE_BINARY_DIR}/share/${WebKit_OUTPUT_NAME}")
26 set(DATA_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/webkitgtk-${WEBKITGTK_API_VERSION}")
27 set(WEBKITGTK_HEADER_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/webkitgtk-${WEBKITGTK_API_VERSION}")
28 set(INTROSPECTION_INSTALL_GIRDIR "${CMAKE_INSTALL_FULL_DATADIR}/gir-1.0")
29 set(INTROSPECTION_INSTALL_TYPELIBDIR "${LIB_INSTALL_DIR}/girepository-1.0")
30
31 find_package(Cairo 1.10.2 REQUIRED)
32 find_package(Fontconfig 2.8.0 REQUIRED)
33 find_package(Freetype2 2.4.2 REQUIRED)
34 find_package(HarfBuzz 0.9.2 REQUIRED)
35 find_package(ICU REQUIRED)
36 find_package(JPEG REQUIRED)
37 find_package(LibSoup 2.42.0 REQUIRED)
38 find_package(LibXml2 2.8.0 REQUIRED)
39 find_package(LibXslt 1.1.7 REQUIRED)
40 find_package(PNG REQUIRED)
41 find_package(Sqlite REQUIRED)
42 find_package(Threads REQUIRED)
43 find_package(ZLIB REQUIRED)
44 find_package(ATK REQUIRED)
45 find_package(WebP REQUIRED)
46 find_package(ATSPI 2.5.3)
47 find_package(GObjectIntrospection)
48 find_package(OpenGL)
49 find_package(EGL)
50 find_package(GeoClue2 2.1.5)
51
52 if (NOT GEOCLUE2_FOUND)
53     find_package(GeoClue)
54 endif ()
55
56 if (ENABLE_X11_TARGET)
57     # We don't use find_package for GLX because it is part of -lGL, unlike EGL.
58     check_include_files("GL/glx.h" GLX_FOUND)
59 endif ()
60
61 WEBKIT_OPTION_BEGIN()
62 WEBKIT_OPTION_DEFINE(ENABLE_PLUGIN_PROCESS_GTK2 "Whether to build WebKitPluginProcess2 to load GTK2 based plugins." ON)
63
64 if (OPENGL_FOUND AND (GLX_FOUND OR EGL_FOUND))
65     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL ON)
66
67     if (GLX_FOUND)
68         list(APPEND CAIRO_GL_COMPONENTS cairo-glx)
69     endif ()
70     if (EGL_FOUND)
71         list(APPEND CAIRO_GL_COMPONENTS cairo-egl)
72     endif ()
73     find_package(CairoGL 1.10.2 COMPONENTS ${CAIRO_GL_COMPONENTS})
74     if (CAIRO_GL_FOUND)
75         WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS ON)
76     else ()
77         WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS OFF)
78     endif ()
79 else ()
80     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL OFF)
81     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS OFF)
82 endif ()
83
84 if (GEOCLUE2_FOUND OR GEOCLUE_FOUND)
85     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GEOLOCATION ON)
86 else ()
87     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GEOLOCATION OFF)
88 endif ()
89
90 if (DEVELOPER_MODE)
91     set(ENABLE_TOOLS ON)
92     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS ON)
93 else ()
94     set(ENABLE_TOOLS OFF)
95     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS OFF)
96     set(WebKit2_VERSION_SCRIPT "-Wl,--version-script,${CMAKE_MODULE_PATH}/gtksymbols.filter")
97 endif ()
98
99 if (CMAKE_SYSTEM_NAME MATCHES "Linux")
100     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEMORY_SAMPLER ON)
101 else ()
102     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEMORY_SAMPLER OFF)
103 endif ()
104
105 # FIXME: We want to expose fewer options to downstream, but for now everything is public.
106 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_3D_RENDERING ON)
107 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCESSIBILITY ON)
108 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BATTERY_STATUS OFF)
109 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CANVAS_PATH OFF)
110 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS3_TEXT OFF)
111 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_DEVICE_ADAPTATION OFF)
112 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_GRID_LAYOUT OFF)
113 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_IMAGE_SET ON)
114 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_REGIONS ON)
115 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_SELECTORS_LEVEL4 ON)
116 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CUSTOM_SCHEME_HANDLER OFF)
117 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DATALIST_ELEMENT OFF)
118 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DOWNLOAD_ATTRIBUTE OFF)
119 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DRAG_SUPPORT ON)
120 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ENCRYPTED_MEDIA OFF)
121 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ENCRYPTED_MEDIA_V2 OFF)
122 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FTPDIR OFF)
123 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FULLSCREEN_API ON)
124 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GAMEPAD OFF)
125 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GAMEPAD_DEPRECATED OFF)
126 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INDEXED_DATABASE OFF)
127 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INDEXED_DATABASE_IN_WORKERS OFF)
128 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INPUT_TYPE_COLOR OFF)
129 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LEGACY_WEB_AUDIO OFF)
130 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LINK_PREFETCH OFF)
131 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_CAPTURE OFF)
132 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_CONTROLS_SCRIPT ON)
133 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MHTML ON)
134 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NAVIGATOR_CONTENT_UTILS OFF)
135 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NAVIGATOR_HWCONCURRENCY ON)
136 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETSCAPE_PLUGIN_API ON)
137 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_PICTURE_SIZES ON)
138 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_QUOTA OFF)
139 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_RESOLUTION_MEDIA_QUERY OFF)
140 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REQUEST_ANIMATION_FRAME ON)
141 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SECCOMP_FILTERS OFF)
142 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SHARED_WORKERS ON)
143 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SPELLCHECK ON)
144 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SUBTLE_CRYPTO OFF)
145 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TEMPLATE_ELEMENT ON)
146 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TOUCH_EVENTS ON)
147 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_USERSELECT_ALL ON)
148 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_USER_MESSAGE_HANDLERS ON)
149 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIBRATION OFF)
150 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO ON)
151 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO_TRACK ON)
152 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIEW_MODE_CSS_MEDIA ON)
153 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_AUDIO ON)
154 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_TIMING ON)
155 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_XHR_TIMEOUT ON)
156 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETWORK_PROCESS ON)
157 WEBKIT_OPTION_DEFAULT_PORT_VALUE(WTF_USE_TILED_BACKING_STORE OFF)
158 WEBKIT_OPTION_END()
159
160 if (ENABLE_PLUGIN_PROCESS_GTK2)
161     find_package(GTK2 2.24.10 REQUIRED)
162     find_package(GDK2 2.24.10 REQUIRED)
163     add_definitions(-DENABLE_PLUGIN_PROCESS_GTK2=1)
164 endif ()
165
166 if (ENABLE_X11_TARGET)
167     add_definitions(-DWTF_PLATFORM_X11=1)
168     add_definitions(-DMOZ_X11=1)
169     if (WTF_OS_UNIX)
170         add_definitions(-DXP_UNIX)
171     endif ()
172 endif ()
173
174 if (ENABLE_WAYLAND_TARGET)
175     add_definitions(-DWTF_PLATFORM_WAYLAND=1)
176 endif ()
177
178 set(ENABLE_WEBCORE ON)
179 set(ENABLE_INSPECTOR ON)
180 set(ENABLE_WEBKIT OFF)
181 set(ENABLE_WEBKIT2 ON)
182 set(ENABLE_PLUGIN_PROCESS ON)
183 set(ENABLE_SMOOTH_SCROLLING ON)
184
185 set(GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_6)
186 set(GTK_API_VERSION 3.0)
187
188 set(WTF_USE_SOUP 1)
189 set(WTF_USE_UDIS86 1)
190
191 set(WTF_LIBRARY_TYPE STATIC)
192 set(WTF_OUTPUT_NAME WTFGTK)
193 set(JavaScriptCore_OUTPUT_NAME javascriptcoregtk-${WEBKITGTK_API_VERSION})
194 set(WebCore_OUTPUT_NAME WebCoreGTK)
195 set(WebKit_OUTPUT_NAME webkitgtk-${WEBKITGTK_API_VERSION})
196 set(WebKit2_OUTPUT_NAME webkit2gtk-${WEBKITGTK_API_VERSION})
197 set(WebKit2_WebProcess_OUTPUT_NAME WebKitWebProcess)
198 set(WebKit2_NetworkProcess_OUTPUT_NAME WebKitNetworkProcess)
199 set(WebKit2_PluginProcess_OUTPUT_NAME WebKitPluginProcess)
200
201 add_definitions(-DBUILDING_GTK__=1)
202 add_definitions(-DGETTEXT_PACKAGE="WebKit2GTK-${WEBKITGTK_API_VERSION}")
203 add_definitions(-DDATA_DIR="${CMAKE_INSTALL_DATADIR}")
204 add_definitions(-DUSER_AGENT_GTK_MAJOR_VERSION=601)
205 add_definitions(-DUSER_AGENT_GTK_MINOR_VERSION=1)
206 add_definitions(-DWEBKITGTK_API_VERSION_STRING="${WEBKITGTK_API_VERSION}")
207
208 if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO)
209     set(GSTREAMER_COMPONENTS app pbutils)
210     add_definitions(-DWTF_USE_GSTREAMER)
211     if (ENABLE_VIDEO)
212         list(APPEND GSTREAMER_COMPONENTS video mpegts tag)
213     endif ()
214
215     if (ENABLE_WEB_AUDIO)
216         list(APPEND GSTREAMER_COMPONENTS audio fft)
217         add_definitions(-DWTF_USE_WEBAUDIO_GSTREAMER)
218     endif ()
219
220     find_package(GStreamer 1.0.3 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS})
221
222     if (PC_GSTREAMER_MPEGTS_FOUND)
223         add_definitions(-DWTF_USE_GSTREAMER_MPEGTS)
224         set(USE_GSTREAMER_MPEGTS TRUE)
225     endif ()
226 endif ()
227
228 if (ENABLE_WAYLAND_TARGET)
229     set(GTK3_REQUIRED_VERSION 3.12.0)
230 else ()
231     set(GTK3_REQUIRED_VERSION 3.6.0)
232 endif ()
233
234 find_package(GTK3 ${GTK3_REQUIRED_VERSION} REQUIRED)
235 find_package(GDK3 ${GTK3_REQUIRED_VERSION} REQUIRED)
236 set(GTK_LIBRARIES ${GTK3_LIBRARIES})
237 set(GTK_INCLUDE_DIRS ${GTK3_INCLUDE_DIRS})
238 set(GDK_LIBRARIES ${GDK3_LIBRARIES})
239 set(GDK_INCLUDE_DIRS ${GDK3_INCLUDE_DIRS})
240
241 set(glib_components gio gobject gthread gmodule)
242 if (ENABLE_GAMEPAD_DEPRECATED OR ENABLE_GEOLOCATION)
243     list(APPEND glib_components gio-unix)
244 endif ()
245 find_package(GLIB 2.33.2 REQUIRED COMPONENTS ${glib_components})
246
247 if (ENABLE_GEOLOCATION)
248     if (GEOCLUE2_FOUND)
249       set(WTF_USE_GEOCLUE2 1)
250     else ()
251       set(WTF_USE_GEOCLUE2 0)
252     endif ()
253 endif ()
254
255 find_package(GTKUnixPrint)
256 if (GTK_UNIX_PRINT_FOUND)
257     set(HAVE_GTK_UNIX_PRINTING 1)
258 endif ()
259
260 if (ENABLE_CREDENTIAL_STORAGE)
261     find_package(Libsecret)
262     set(ENABLE_CREDENTIAL_STORAGE 1)
263 endif ()
264
265 if (GTK_SUPPORTS_GESTURES)
266     add_definitions(-DHAVE_GTK_GESTURES=1)
267 endif ()
268
269 # This part can be simplified once CMake 2.8.6 is required and
270 # CMakePushCheckState can be used. We need to have OPENGL_INCLUDE_DIR as part
271 # of the directories check_include_files() looks for in case OpenGL is
272 # installed into a non-standard location.
273 if (ENABLE_X11_TARGET)
274     set(REQUIRED_INCLUDES_OLD ${CMAKE_REQUIRED_INCLUDES})
275     set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${OPENGL_INCLUDE_DIR})
276     set(CMAKE_REQUIRED_INCLUDES ${REQUIRED_INCLUDES_OLD})
277
278     if (GLX_FOUND)
279         set(WTF_USE_GLX 1)
280     endif ()
281 endif ()
282
283 if (EGL_FOUND)
284     set(WTF_USE_EGL 1)
285 endif ()
286
287 if (ENABLE_SPELLCHECK)
288     find_package(Enchant REQUIRED)
289 endif ()
290
291 if (OPENGL_FOUND AND (GLX_FOUND OR EGL_FOUND))
292     set(ENABLE_TEXTURE_MAPPER 1)
293     set(WTF_USE_3D_GRAPHICS 1)
294
295     add_definitions(-DWTF_USE_OPENGL=1)
296     add_definitions(-DWTF_USE_3D_GRAPHICS=1)
297     add_definitions(-DWTF_USE_TEXTURE_MAPPER=1)
298     add_definitions(-DWTF_USE_TEXTURE_MAPPER_GL=1)
299     add_definitions(-DENABLE_3D_RENDERING=1)
300
301     if (EGL_FOUND)
302         add_definitions(-DWTF_USE_EGL=1)
303     endif ()
304
305     if (GLX_FOUND)
306         add_definitions(-DWTF_USE_GLX=1)
307     endif ()
308 endif ()
309
310 if (ENABLE_GAMEPAD_DEPRECATED)
311     find_package(GUdev)
312 endif ()
313
314 if (ENABLE_FTL_JIT)
315     find_package(LLVM REQUIRED)
316     find_package(LIBCXXABI REQUIRED)
317     set(HAVE_LLVM ON)
318 endif ()
319
320 set(CPACK_SOURCE_GENERATOR TBZ2)
321
322 set(DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR ${DERIVED_SOURCES_DIR}/webkitdom)
323 set(DERIVED_SOURCES_WEBKITGTK_DIR ${DERIVED_SOURCES_DIR}/webkitgtk)
324 set(DERIVED_SOURCES_WEBKITGTK_API_DIR ${DERIVED_SOURCES_WEBKITGTK_DIR}/webkit)
325 set(DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR ${DERIVED_SOURCES_DIR}/webkitdom)
326 set(DERIVED_SOURCES_WEBKIT2GTK_DIR ${DERIVED_SOURCES_DIR}/webkit2gtk)
327 set(DERIVED_SOURCES_WEBKIT2GTK_API_DIR ${DERIVED_SOURCES_WEBKIT2GTK_DIR}/webkit2)
328 set(FORWARDING_HEADERS_DIR ${DERIVED_SOURCES_DIR}/ForwardingHeaders)
329 set(FORWARDING_HEADERS_WEBKIT2GTK_DIR ${FORWARDING_HEADERS_DIR}/webkit2gtk)
330 set(FORWARDING_HEADERS_WEBKIT2GTK_EXTENSION_DIR ${FORWARDING_HEADERS_DIR}/webkit2gtk-webextension)
331
332 set(WebKit_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/Source/WebKit/gtk/webkitgtk-${WEBKITGTK_API_VERSION}.pc)
333 set(WebKit2_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/Source/WebKit2/webkit2gtk-${WEBKITGTK_API_VERSION}.pc)
334 set(WebKit2WebExtension_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/Source/WebKit2/webkit2gtk-web-extension-${WEBKITGTK_API_VERSION}.pc)
335
336 set(SHOULD_INSTALL_JS_SHELL ON)
337
338 # Push of rbp is needed after JSC JIT uses CStack. See http://wkbug.com/127777.
339 if (UNIX AND NOT APPLE)
340     if (CMAKE_COMPILER_IS_GNUCXX)
341         set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fno-omit-frame-pointer -fno-tree-dce")
342         set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-omit-frame-pointer -fno-tree-dce")
343     endif ()
344     if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
345         set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fno-omit-frame-pointer")
346         set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-omit-frame-pointer")
347     endif ()
348 endif ()
349
350 # Add a typelib file to the list of all typelib dependencies. This makes it easy to
351 # expose a 'gir' target with all gobject-introspection files.
352 macro(ADD_TYPELIB typelib)
353     get_filename_component(target_name ${typelib} NAME_WE)
354     add_custom_target(${target_name}-gir ALL DEPENDS ${typelib})
355     list(APPEND GObjectIntrospectionTargets ${target_name}-gir)
356     set(GObjectIntrospectionTargets ${GObjectIntrospectionTargets} PARENT_SCOPE)
357 endmacro()
358
359 # CMake does not automatically add --whole-archive when building shared objects from
360 # a list of convenience libraries. This can lead to missing symbols in the final output.
361 # We add --whole-archive to all libraries manually to prevent the linker from trimming
362 # symbols that we actually need later.
363 macro(ADD_WHOLE_ARCHIVE_TO_LIBRARIES _list_name)
364     foreach (library IN LISTS ${_list_name})
365       list(APPEND ${_list_name}_TMP -Wl,--whole-archive ${library} -Wl,--no-whole-archive)
366     endforeach ()
367     set(${_list_name} "${${_list_name}_TMP}")
368 endmacro()
369
370 if (CMAKE_MAJOR_VERSION LESS 3)
371     # Before CMake 3 it was necessary to use a build script instead of using cmake --build directly
372     # to preserve colors and pretty-printing.
373
374     build_command(COMMAND_LINE_TO_BUILD)
375     # build_command unconditionally adds -i (ignore errors) for make, and there's
376     # no reasonable way to turn that off, so we just replace it with -k, which has
377     # the same effect, except that the return code will indicate that an error occurred.
378     # See: http://www.cmake.org/cmake/help/v3.0/command/build_command.html
379     string(REPLACE " -i" " -k" COMMAND_LINE_TO_BUILD ${COMMAND_LINE_TO_BUILD})
380     file(WRITE
381         ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/build.sh
382         "#!/bin/sh\n"
383         "${COMMAND_LINE_TO_BUILD} $@"
384     )
385     file(COPY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/build.sh
386         DESTINATION ${CMAKE_BINARY_DIR}
387         FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
388     )
389 endif ()
390
391 if (ENABLE_SUBTLE_CRYPTO)
392     find_package(GnuTLS 3.0.0 REQUIRED)
393 endif ()