[CMake] Autogenerate cmakeconfig.h.cmake
[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_GTKDOC OFF CACHE BOOL "Whether or not to use generate gtkdoc.")
15 set(ENABLE_X11_TARGET ON CACHE BOOL "Whether to enable support for the X11 windowing target.")
16 set(ENABLE_WAYLAND_TARGET OFF CACHE BOOL "Whether to enable support for the Wayland windowing target.")
17 set(ENABLE_INTROSPECTION ON CACHE BOOL "Whether to enable GObject introspection.")
18 set(ENABLE_GLES2 OFF CACHE BOOL "Whether to enable OpenGL ES 2.0.")
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(EGL)
50 find_package(GeoClue2 2.1.5)
51 find_package(GnuTLS 3.0.0)
52 find_package(LibNotify)
53
54 if (NOT GEOCLUE2_FOUND)
55     find_package(GeoClue)
56 endif ()
57
58 if (ENABLE_GLES2)
59     find_package(OpenGLES2 REQUIRED)
60     if (OPENGLES2_FOUND AND NOT(EGL_FOUND))
61         message(FATAL_ERROR "EGL is needed for OpenGL ES 2.0.")
62     endif ()
63 else ()
64     find_package(OpenGL)
65 endif ()
66
67 if (ENABLE_X11_TARGET)
68     # With cmake 3.2.x we have to explicitly ask for X11 otherwise the X11_X11_LIB
69     # variable won't be set thus the X11 linker flags won't be added and the build
70     # will fail.
71     find_package(X11 REQUIRED)
72     if (OPENGL_FOUND)
73         # We don't use find_package for GLX because it is part of -lGL, unlike EGL.
74         check_include_files("GL/glx.h" GLX_FOUND)
75     endif ()
76 endif ()
77
78 if (ENABLE_WAYLAND_TARGET)
79     find_package(Wayland REQUIRED)
80 endif ()
81
82 WEBKIT_OPTION_BEGIN()
83 WEBKIT_OPTION_DEFINE(ENABLE_PLUGIN_PROCESS_GTK2 "Whether to build WebKitPluginProcess2 to load GTK2 based plugins." PUBLIC ON)
84 WEBKIT_OPTION_DEFINE(USE_REDIRECTED_XCOMPOSITE_WINDOW "Whether to use a Redirected XComposite Window for accelerated compositing in X11." PRIVATE ON)
85
86 if ((OPENGL_FOUND OR OPENGLES2_FOUND) AND (GLX_FOUND OR EGL_FOUND))
87     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL PRIVATE ON)
88
89     if (ENABLE_X11_TARGET)
90         WEBKIT_OPTION_DEFAULT_PORT_VALUE(USE_REDIRECTED_XCOMPOSITE_WINDOW PRIVATE ON)
91     else ()
92         WEBKIT_OPTION_DEFAULT_PORT_VALUE(USE_REDIRECTED_XCOMPOSITE_WINDOW PRIVATE OFF)
93     endif ()
94
95     if (OPENGL_FOUND)
96         if (GLX_FOUND)
97             list(APPEND CAIRO_GL_COMPONENTS cairo-glx)
98         endif ()
99         if (EGL_FOUND)
100             list(APPEND CAIRO_GL_COMPONENTS cairo-egl)
101         endif ()
102         find_package(CairoGL 1.10.2 COMPONENTS ${CAIRO_GL_COMPONENTS})
103         if (CAIRO_GL_FOUND)
104             WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS PRIVATE ON)
105         else ()
106             WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS PRIVATE OFF)
107         endif ()
108     else ()
109         # FIXME: Should we search for cairo-glesv2 instead of cairo-gl in this case?
110         WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS PRIVATE OFF)
111     endif ()
112 else ()
113     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL PRIVATE OFF)
114     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS PRIVATE OFF)
115     WEBKIT_OPTION_DEFAULT_PORT_VALUE(USE_REDIRECTED_XCOMPOSITE_WINDOW PRIVATE OFF)
116 endif ()
117
118 if (ENABLE_ACCELERATED_2D_CANVAS AND NOT(CAIRO_GL_FOUND))
119     message(FATAL_ERROR "cairo-gl is needed for Accelerated 2D Canvas support")
120 endif ()
121
122 if (GNUTLS_FOUND)
123     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SUBTLE_CRYPTO PUBLIC ON)
124 else ()
125     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SUBTLE_CRYPTO PUBLIC OFF)
126 endif ()
127
128 if (ENABLE_SUBTLE_CRYPTO AND NOT(GNUTLS_FOUND))
129     message(FATAL_ERROR "Subtle crypto support needs GnuTLS 3.0.0")
130 endif ()
131
132 if (GEOCLUE2_FOUND OR GEOCLUE_FOUND)
133     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GEOLOCATION PUBLIC ON)
134 else ()
135     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GEOLOCATION PUBLIC OFF)
136 endif ()
137
138 # FIXME: There is no reason these should be different.
139 SET_AND_EXPOSE_TO_BUILD(DEVELOPMENT_BUILD ${DEVELOPER_MODE})
140 if (DEVELOPER_MODE)
141     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MINIBROWSER PUBLIC ON)
142     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS PUBLIC ON)
143 else ()
144     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MINIBROWSER PUBLIC OFF)
145     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS PUBLIC OFF)
146     set(WebKit2_VERSION_SCRIPT "-Wl,--version-script,${CMAKE_MODULE_PATH}/gtksymbols.filter")
147 endif ()
148
149 if (CMAKE_SYSTEM_NAME MATCHES "Linux")
150     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEMORY_SAMPLER PUBLIC ON)
151 else ()
152     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEMORY_SAMPLER PUBLIC OFF)
153 endif ()
154
155 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CREDENTIAL_STORAGE PUBLIC ON)
156 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DRAG_SUPPORT PUBLIC ON)
157 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ICONDATABASE PUBLIC ON)
158 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_JIT PUBLIC ON)
159 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SPELLCHECK PUBLIC ON)
160 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TOUCH_EVENTS PUBLIC ON)
161 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO PUBLIC ON)
162 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_AUDIO PUBLIC ON)
163 WEBKIT_OPTION_DEFAULT_PORT_VALUE(USE_SYSTEM_MALLOC PUBLIC OFF)
164
165 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_3D_TRANSFORMS PRIVATE ON)
166 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCESSIBILITY PRIVATE ON)
167 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ATTACHMENT_ELEMENT PRIVATE OFF)
168 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BATTERY_STATUS PRIVATE OFF)
169 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CANVAS_PATH PRIVATE OFF)
170 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS3_TEXT PRIVATE OFF)
171 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_DEVICE_ADAPTATION PRIVATE OFF)
172 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_GRID_LAYOUT PRIVATE OFF)
173 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_IMAGE_SET PRIVATE ON)
174 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_REGIONS PRIVATE ON)
175 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_SELECTORS_LEVEL4 PRIVATE ON)
176 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CUSTOM_SCHEME_HANDLER PRIVATE OFF)
177 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DATALIST_ELEMENT PRIVATE OFF)
178 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DOWNLOAD_ATTRIBUTE PRIVATE OFF)
179 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ENCRYPTED_MEDIA PRIVATE OFF)
180 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ENCRYPTED_MEDIA_V2 PRIVATE OFF)
181 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FILTERS_LEVEL_2 PRIVATE OFF)
182 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FTPDIR PRIVATE OFF)
183 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FULLSCREEN_API PRIVATE ON)
184 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GAMEPAD PRIVATE OFF)
185 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GAMEPAD_DEPRECATED PRIVATE OFF)
186 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INDEXED_DATABASE PRIVATE OFF)
187 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INDEXED_DATABASE_IN_WORKERS PRIVATE OFF)
188 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INPUT_TYPE_COLOR PRIVATE ON)
189 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LEGACY_WEB_AUDIO PRIVATE OFF)
190 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LINK_PREFETCH PRIVATE OFF)
191 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_CAPTURE PRIVATE OFF)
192 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_CONTROLS_SCRIPT PRIVATE ON)
193 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MHTML PRIVATE ON)
194 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NAVIGATOR_CONTENT_UTILS PRIVATE OFF)
195 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NAVIGATOR_HWCONCURRENCY PRIVATE ON)
196 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETSCAPE_PLUGIN_API PRIVATE ON)
197 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NOTIFICATIONS PRIVATE ON)
198 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_PICTURE_SIZES PRIVATE ON)
199 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_QUOTA PRIVATE OFF)
200 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_RESOLUTION_MEDIA_QUERY PRIVATE OFF)
201 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REQUEST_ANIMATION_FRAME PRIVATE ON)
202 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SECCOMP_FILTERS PRIVATE OFF)
203 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SMOOTH_SCROLLING PUBLIC ON)
204 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TEMPLATE_ELEMENT PRIVATE ON)
205 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_USERSELECT_ALL PRIVATE ON)
206 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_USER_MESSAGE_HANDLERS PRIVATE ON)
207 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIBRATION PRIVATE OFF)
208 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO_TRACK PRIVATE ON)
209 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIEW_MODE_CSS_MEDIA PRIVATE ON)
210 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_TIMING PRIVATE ON)
211 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_XHR_TIMEOUT PRIVATE ON)
212 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETWORK_PROCESS PRIVATE ON)
213 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_THREADED_COMPOSITOR PRIVATE OFF)
214 WEBKIT_OPTION_END()
215
216 if (ENABLE_PLUGIN_PROCESS_GTK2)
217     find_package(GTK2 2.24.10 REQUIRED)
218     find_package(GDK2 2.24.10 REQUIRED)
219 endif ()
220
221 SET_AND_EXPOSE_TO_BUILD(WTF_USE_LIBNOTIFY ${LIBNOTIFY_FOUND})
222 SET_AND_EXPOSE_TO_BUILD(WTF_PLATFORM_X11 ${ENABLE_X11_TARGET})
223 SET_AND_EXPOSE_TO_BUILD(MOZ_X11 ${ENABLE_X11_TARGET})
224 SET_AND_EXPOSE_TO_BUILD(XP_UNIX ${WTF_OS_UNIX})
225 SET_AND_EXPOSE_TO_BUILD(WTF_PLATFORM_WAYLAND ${ENABLE_WAYLAND_TARGET})
226
227 set(ENABLE_WEBKIT OFF)
228 set(ENABLE_WEBKIT2 ON)
229 set(ENABLE_PLUGIN_PROCESS ON)
230
231 set(GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_6)
232 set(GTK_API_VERSION 3.0)
233
234 set(WTF_USE_SOUP 1)
235 set(WTF_USE_UDIS86 1)
236
237 set(WTF_LIBRARY_TYPE STATIC)
238 set(WTF_OUTPUT_NAME WTFGTK)
239 set(JavaScriptCore_OUTPUT_NAME javascriptcoregtk-${WEBKITGTK_API_VERSION})
240 set(WebCore_OUTPUT_NAME WebCoreGTK)
241 set(WebKit_OUTPUT_NAME webkitgtk-${WEBKITGTK_API_VERSION})
242 set(WebKit2_OUTPUT_NAME webkit2gtk-${WEBKITGTK_API_VERSION})
243 set(WebKit2_WebProcess_OUTPUT_NAME WebKitWebProcess)
244 set(WebKit2_NetworkProcess_OUTPUT_NAME WebKitNetworkProcess)
245 set(WebKit2_PluginProcess_OUTPUT_NAME WebKitPluginProcess)
246 set(WebKit2_DatabaseProcess_OUTPUT_NAME WebKitDatabaseProcess)
247
248 add_definitions(-DBUILDING_GTK__=1)
249 add_definitions(-DGETTEXT_PACKAGE="WebKit2GTK-${WEBKITGTK_API_VERSION}")
250 add_definitions(-DDATA_DIR="${CMAKE_INSTALL_DATADIR}")
251 add_definitions(-DUSER_AGENT_GTK_MAJOR_VERSION=601)
252 add_definitions(-DUSER_AGENT_GTK_MINOR_VERSION=1)
253 add_definitions(-DWEBKITGTK_API_VERSION_STRING="${WEBKITGTK_API_VERSION}")
254
255 if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO)
256     set(GSTREAMER_COMPONENTS app pbutils)
257     SET_AND_EXPOSE_TO_BUILD(WTF_USE_GSTREAMER TRUE)
258     if (ENABLE_VIDEO)
259         list(APPEND GSTREAMER_COMPONENTS video mpegts tag gl)
260     endif ()
261
262     if (ENABLE_WEB_AUDIO)
263         list(APPEND GSTREAMER_COMPONENTS audio fft)
264         SET_AND_EXPOSE_TO_BUILD(WTF_USE_WEBAUDIO_GSTREAMER TRUE)
265     endif ()
266
267     find_package(GStreamer 1.0.3 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS})
268
269     if (PC_GSTREAMER_MPEGTS_FOUND)
270         SET_AND_EXPOSE_TO_BUILD(WTF_USE_GSTREAMER_MPEGTS TRUE)
271     endif ()
272 endif ()
273
274 if (ENABLE_WAYLAND_TARGET)
275     set(GTK3_REQUIRED_VERSION 3.12.0)
276 else ()
277     set(GTK3_REQUIRED_VERSION 3.6.0)
278 endif ()
279
280 find_package(GTK3 ${GTK3_REQUIRED_VERSION} REQUIRED)
281 find_package(GDK3 ${GTK3_REQUIRED_VERSION} REQUIRED)
282 set(GTK_LIBRARIES ${GTK3_LIBRARIES})
283 set(GTK_INCLUDE_DIRS ${GTK3_INCLUDE_DIRS})
284 set(GDK_LIBRARIES ${GDK3_LIBRARIES})
285 set(GDK_INCLUDE_DIRS ${GDK3_INCLUDE_DIRS})
286
287 set(glib_components gio gobject gthread gmodule)
288 if (ENABLE_GAMEPAD_DEPRECATED OR ENABLE_GEOLOCATION)
289     list(APPEND glib_components gio-unix)
290 endif ()
291 find_package(GLIB 2.33.2 REQUIRED COMPONENTS ${glib_components})
292
293 if (ENABLE_GEOLOCATION)
294     SET_AND_EXPOSE_TO_BUILD(WTF_USE_GEOCLUE2 ${GEOCLUE2_FOUND})
295 endif ()
296
297 if (ENABLE_MEDIA_STREAM)
298     find_package(OpenWebRTC)
299     SET_AND_EXPOSE_TO_BUILD(WTF_USE_OPENWEBRTC ${OPENWEBRTC_FOUND})
300 endif ()
301
302 find_package(GTKUnixPrint)
303 SET_AND_EXPOSE_TO_BUILD(HAVE_GTK_UNIX_PRINTING ${GTK_UNIX_PRINT_FOUND})
304
305 if (ENABLE_CREDENTIAL_STORAGE)
306     find_package(Libsecret REQUIRED)
307 endif ()
308
309 SET_AND_EXPOSE_TO_BUILD(HAVE_GTK_GESTURES ${GTK_SUPPORTS_GESTURES})
310
311 # This part can be simplified once CMake 2.8.6 is required and
312 # CMakePushCheckState can be used. We need to have OPENGL_INCLUDE_DIR as part
313 # of the directories check_include_files() looks for in case OpenGL is
314 # installed into a non-standard location.
315 if (ENABLE_X11_TARGET)
316     set(REQUIRED_INCLUDES_OLD ${CMAKE_REQUIRED_INCLUDES})
317     set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${OPENGL_INCLUDE_DIR})
318     set(CMAKE_REQUIRED_INCLUDES ${REQUIRED_INCLUDES_OLD})
319 endif ()
320
321 if (ENABLE_SPELLCHECK)
322     find_package(Enchant REQUIRED)
323 endif ()
324
325 if ((OPENGL_FOUND OR OPENGLES2_FOUND) AND (GLX_FOUND OR EGL_FOUND))
326     set(ENABLE_TEXTURE_MAPPER 1)
327
328     SET_AND_EXPOSE_TO_BUILD(WTF_USE_3D_GRAPHICS TRUE)
329     SET_AND_EXPOSE_TO_BUILD(WTF_USE_TEXTURE_MAPPER TRUE)
330     SET_AND_EXPOSE_TO_BUILD(WTF_USE_TEXTURE_MAPPER_GL TRUE)
331     set(ENABLE_3D_RENDERING ON) # This is already exposed by WEBKIT_OPTION_DEFINE.
332
333     if (ENABLE_X11_TARGET AND USE_REDIRECTED_XCOMPOSITE_WINDOW)
334         add_definitions(-DWTF_USE_REDIRECTED_XCOMPOSITE_WINDOW=1)
335     endif ()
336
337     if (OPENGLES2_FOUND)
338         SET_AND_EXPOSE_TO_BUILD(WTF_USE_OPENGL_ES_2 TRUE)
339     else ()
340         SET_AND_EXPOSE_TO_BUILD(WTF_USE_OPENGL TRUE)
341     endif ()
342
343     SET_AND_EXPOSE_TO_BUILD(WTF_USE_EGL ${EGL_FOUND})
344     SET_AND_EXPOSE_TO_BUILD(WTF_USE_GLX ${GLX_FOUND})
345
346     SET_AND_EXPOSE_TO_BUILD(WTF_USE_TILED_BACKING_STORE ${ENABLE_THREADED_COMPOSITOR})
347     SET_AND_EXPOSE_TO_BUILD(WTF_USE_COORDINATED_GRAPHICS ${ENABLE_THREADED_COMPOSITOR})
348     SET_AND_EXPOSE_TO_BUILD(WTF_USE_COORDINATED_GRAPHICS_THREADED ${ENABLE_THREADED_COMPOSITOR})
349
350     SET_AND_EXPOSE_TO_BUILD(WTF_USE_GSTREAMER_GL ${PC_GSTREAMER_GL_FOUND})
351 endif ()
352
353 if (ENABLE_GAMEPAD_DEPRECATED)
354     find_package(GUdev)
355 endif ()
356
357 if (ENABLE_FTL_JIT)
358     find_package(LLVM REQUIRED)
359     SET_AND_EXPOSE_TO_BUILD(HAVE_LLVM TRUE)
360 endif ()
361
362 set(CPACK_SOURCE_GENERATOR TBZ2)
363
364 set(DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR ${DERIVED_SOURCES_DIR}/webkitdom)
365 set(DERIVED_SOURCES_WEBKITGTK_DIR ${DERIVED_SOURCES_DIR}/webkitgtk)
366 set(DERIVED_SOURCES_WEBKITGTK_API_DIR ${DERIVED_SOURCES_WEBKITGTK_DIR}/webkit)
367 set(DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR ${DERIVED_SOURCES_DIR}/webkitdom)
368 set(DERIVED_SOURCES_WEBKIT2GTK_DIR ${DERIVED_SOURCES_DIR}/webkit2gtk)
369 set(DERIVED_SOURCES_WEBKIT2GTK_API_DIR ${DERIVED_SOURCES_WEBKIT2GTK_DIR}/webkit2)
370 set(FORWARDING_HEADERS_DIR ${DERIVED_SOURCES_DIR}/ForwardingHeaders)
371 set(FORWARDING_HEADERS_WEBKIT2GTK_DIR ${FORWARDING_HEADERS_DIR}/webkit2gtk)
372 set(FORWARDING_HEADERS_WEBKIT2GTK_EXTENSION_DIR ${FORWARDING_HEADERS_DIR}/webkit2gtk-webextension)
373
374 set(WebKit_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/Source/WebKit/gtk/webkitgtk-${WEBKITGTK_API_VERSION}.pc)
375 set(WebKit2_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/Source/WebKit2/webkit2gtk-${WEBKITGTK_API_VERSION}.pc)
376 set(WebKit2WebExtension_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/Source/WebKit2/webkit2gtk-web-extension-${WEBKITGTK_API_VERSION}.pc)
377
378 set(SHOULD_INSTALL_JS_SHELL ON)
379
380 # Add a typelib file to the list of all typelib dependencies. This makes it easy to
381 # expose a 'gir' target with all gobject-introspection files.
382 macro(ADD_TYPELIB typelib)
383     if (ENABLE_INTROSPECTION)
384         get_filename_component(target_name ${typelib} NAME_WE)
385         add_custom_target(${target_name}-gir ALL DEPENDS ${typelib})
386         list(APPEND GObjectIntrospectionTargets ${target_name}-gir)
387         set(GObjectIntrospectionTargets ${GObjectIntrospectionTargets} PARENT_SCOPE)
388     endif ()
389 endmacro()
390
391 # CMake does not automatically add --whole-archive when building shared objects from
392 # a list of convenience libraries. This can lead to missing symbols in the final output.
393 # We add --whole-archive to all libraries manually to prevent the linker from trimming
394 # symbols that we actually need later.
395 macro(ADD_WHOLE_ARCHIVE_TO_LIBRARIES _list_name)
396     foreach (library IN LISTS ${_list_name})
397       list(APPEND ${_list_name}_TMP -Wl,--whole-archive ${library} -Wl,--no-whole-archive)
398     endforeach ()
399     set(${_list_name} "${${_list_name}_TMP}")
400 endmacro()
401
402 if (CMAKE_MAJOR_VERSION LESS 3)
403     # Before CMake 3 it was necessary to use a build script instead of using cmake --build directly
404     # to preserve colors and pretty-printing.
405
406     build_command(COMMAND_LINE_TO_BUILD)
407     # build_command unconditionally adds -i (ignore errors) for make, and there's
408     # no reasonable way to turn that off, so we just replace it with -k, which has
409     # the same effect, except that the return code will indicate that an error occurred.
410     # See: http://www.cmake.org/cmake/help/v3.0/command/build_command.html
411     string(REPLACE " -i" " -k" COMMAND_LINE_TO_BUILD ${COMMAND_LINE_TO_BUILD})
412     file(WRITE
413         ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/build.sh
414         "#!/bin/sh\n"
415         "${COMMAND_LINE_TO_BUILD} $@"
416     )
417     file(COPY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/build.sh
418         DESTINATION ${CMAKE_BINARY_DIR}
419         FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
420     )
421 endif ()