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