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