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