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