Support ENABLE_ENCRYPTED_MEDIA in cmake builds
[WebKit-https.git] / Source / cmake / OptionsGTK.cmake
1 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
2 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
3 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
4
5 include(GNUInstallDirs)
6
7 set(PROJECT_VERSION_MAJOR 2)
8 set(PROJECT_VERSION_MINOR 3)
9 set(PROJECT_VERSION_PATCH 3)
10 set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
11
12 # Libtool library version, not to be confused with API version.
13 # See http://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html
14 CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(WEBKIT 22 0 22)
15 CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(WEBKIT2 32 0 7)
16 CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(JAVASCRIPTCORE 16 2 16)
17
18 # This is a little confusing: WEBKIT_MICRO_VERSION and friends are used as
19 # macros in files like WebKitVersion.h.in to expose the project version to
20 # the API. Meanwhile WEBKIT_VERSION_MICRO (note the transposed words) is used
21 # by the CMake files to hold the *library* version number, which we calculated
22 # from the libtool triple above. We should consider ditching these below
23 # and using PROJECT_VERSION_* directly.
24 set(WEBKIT_MICRO_VERSION ${PROJECT_VERSION_PATCH})
25 set(WEBKIT_MINOR_VERSION ${PROJECT_VERSION_MINOR})
26 set(WEBKIT_MAJOR_VERSION ${PROJECT_VERSION_MAJOR})
27
28 set(USE_GTK2 OFF CACHE BOOL "Whether or not to use GTK+ 2. WebKit2 only supports GTK+ 3.")
29
30 # FIXME: We want to expose fewer options to downstream, but for now everything is public.
31 WEBKIT_OPTION_BEGIN()
32 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_3D_RENDERING ON)
33 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCESSIBILITY ON)
34 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS ON)
35 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BATTERY_STATUS OFF)
36 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BLOB ON)
37 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS3_TEXT ON)
38 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_DEVICE_ADAPTATION ON)
39 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_GRID_LAYOUT OFF)
40 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_IMAGE_SET ON)
41 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_REGIONS ON)
42 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_STICKY_POSITION ON)
43 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CUSTOM_SCHEME_HANDLER OFF)
44 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DATALIST_ELEMENT ON)
45 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DOWNLOAD_ATTRIBUTE ON)
46 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DRAG_SUPPORT ON)
47 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ENCRYPTED_MEDIA OFF)
48 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ENCRYPTED_MEDIA_V2 OFF)
49 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FAST_MOBILE_SCROLLING ON)
50 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FILTERS ON)
51 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FULLSCREEN_API ON)
52 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GAMEPAD OFF)
53 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INDEXED_DATABASE ON)
54 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INPUT_TYPE_COLOR OFF)
55 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LINK_PREFETCH ON)
56 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LLINT ON)
57 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_CAPTURE ON)
58 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_CONTROLS_SCRIPT ON)
59 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEMORY_SAMPLER ON)
60 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MHTML ON)
61 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NAVIGATOR_CONTENT_UTILS ON)
62 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETSCAPE_PLUGIN_API ON)
63 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETWORK_INFO ON)
64 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_PAGE_VISIBILITY_API ON)
65 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_QUOTA OFF)
66 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_RESOLUTION_MEDIA_QUERY OFF)
67 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REQUEST_ANIMATION_FRAME ON)
68 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SECCOMP_FILTERS OFF)
69 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SHARED_WORKERS ON)
70 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SPELLCHECK ON)
71 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TEMPLATE_ELEMENT ON)
72 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TOUCH_EVENTS ON)
73 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_USERSELECT_ALL ON)
74 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIBRATION OFF)
75 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO ON)
76 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO_TRACK ON)
77 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIEW_MODE_CSS_MEDIA ON)
78 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_AUDIO ON)
79 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_TIMING ON)
80 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL OFF)
81 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_XHR_TIMEOUT ON)
82 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETWORK_PROCESS ON)
83 WEBKIT_OPTION_DEFAULT_PORT_VALUE(WTF_USE_TILED_BACKING_STORE OFF)
84
85 # FIXME: Perhaps we need a more generic way of defining dependencies between features.
86 # VIDEO_TRACK depends on VIDEO.
87 if (NOT ENABLE_VIDEO AND ENABLE_VIDEO_TRACK)
88     message(STATUS "Disabling VIDEO_TRACK since VIDEO support is disabled.")
89     set(ENABLE_VIDEO_TRACK OFF)
90 endif ()
91
92 if (PRODUCTION_MODE)
93     set(ENABLE_TOOLS OFF)
94     set(ENABLE_API_TESTS OFF)
95     set(VERSION_SCRIPT "-Wl,--version-script,${CMAKE_SOURCE_DIR}/Source/autotools/symbols.filter")
96 else ()
97     set(ENABLE_TOOLS ON)
98     set(ENABLE_API_TESTS ON)
99 endif ()
100
101 WEBKIT_OPTION_END()
102
103 set(ENABLE_WEBCORE ON)
104 set(ENABLE_INSPECTOR ON)
105 set(ENABLE_WEBKIT ON)
106 if (NOT USE_GTK2)
107     set(WEBKITGTK_API_VERSION 3.0)
108     set(GTK_API_VERSION 3.0)
109     set(ENABLE_PLUGIN_PROCESS ON)
110     set(ENABLE_WEBKIT2 ON)
111 else ()
112     set(WEBKITGTK_API_VERSION 2.0)
113     set(GTK_API_VERSION 2.0)
114     set(ENABLE_PLUGIN_PROCESS OFF)
115     set(ENABLE_WEBKIT2 OFF)
116 endif ()
117
118 # These are used to generate the pkg-config files.
119 set(prefix ${CMAKE_INSTALL_PREFIX})
120 set(exec_prefix ${CMAKE_INSTALL_PREFIX})
121 set(libdir "${prefix}/${CMAKE_INSTALL_LIBDIR}")
122 set(includedir "${prefix}/include")
123 set(VERSION ${PROJECT_VERSION})
124
125 set(WTF_USE_SOUP 1)
126
127 set(WTF_OUTPUT_NAME WTFGTK)
128 set(JavaScriptCore_OUTPUT_NAME javascriptcoregtk-${WEBKITGTK_API_VERSION})
129 set(WebCore_OUTPUT_NAME WebCoreGTK)
130 set(WebKit_OUTPUT_NAME webkitgtk-${WEBKITGTK_API_VERSION})
131 set(WebKit2_OUTPUT_NAME webkit2gtk-${WEBKITGTK_API_VERSION})
132 set(WebKit2_WebProcess_OUTPUT_NAME WebKitWebProcess)
133 set(WebKit2_NetworkProcess_OUTPUT_NAME WebKitNetworkProcess)
134
135 set(DATA_BUILD_DIR "${CMAKE_BINARY_DIR}/share/${WebKit_OUTPUT_NAME}")
136 set(DATA_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/webkitgtk-${WEBKITGTK_API_VERSION}")
137 set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Where to install libraries")
138 set(EXEC_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "Where to install executables")
139 set(LIBEXEC_INSTALL_DIR "${CMAKE_INSTALL_LIBEXECDIR}" CACHE PATH "Where to install executables executed by the library")
140 set(WEBKITGTK_HEADER_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/webkitgtk-${WEBKITGTK_API_VERSION}")
141
142 add_definitions(-DBUILDING_GTK__=1)
143 add_definitions(-DGETTEXT_PACKAGE="WebKitGTK-${WEBKITGTK_API_VERSION}")
144 add_definitions(-DDATA_DIR="${CMAKE_INSTALL_DATADIR}")
145 add_definitions(-DUSER_AGENT_GTK_MAJOR_VERSION=537)
146 add_definitions(-DUSER_AGENT_GTK_MINOR_VERSION=30)
147 add_definitions(-DWEBKITGTK_API_VERSION_STRING="${WEBKITGTK_API_VERSION}")
148
149 if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO)
150     add_definitions(-DWTF_USE_GSTREAMER)
151 endif ()
152
153 if (ENABLE_WEB_AUDIO)
154     add_definitions(-DWTF_USE_WEBAUDIO_GSTREAMER)
155 endif ()
156
157 # FIXME: These need to be configurable.
158 add_definitions(-DWTF_PLATFORM_X11=1)
159 add_definitions(-DMOZ_X11)
160
161 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
162     set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> cruT <TARGET> <LINK_FLAGS> <OBJECTS>")
163     set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cruT <TARGET> <LINK_FLAGS> <OBJECTS>")
164     set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> ruT <TARGET> <LINK_FLAGS> <OBJECTS>")
165     set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> ruT <TARGET> <LINK_FLAGS> <OBJECTS>")
166 endif ()
167
168 find_package(Cairo 1.10.2 REQUIRED)
169 find_package(Fontconfig 2.8.0 REQUIRED)
170 find_package(Freetype 2.4.2 REQUIRED)
171 find_package(GTK2 2.24.10 REQUIRED)
172 find_package(GDK2 2.24.10 REQUIRED)
173 find_package(HarfBuzz 0.9.2 REQUIRED)
174 find_package(ICU REQUIRED)
175 find_package(JPEG REQUIRED)
176 find_package(LibSoup 2.40.3 REQUIRED)
177 find_package(LibXml2 2.8.0 REQUIRED)
178 find_package(LibXslt 1.1.7 REQUIRED)
179 find_package(PNG REQUIRED)
180 find_package(Sqlite REQUIRED)
181 find_package(Threads REQUIRED)
182 find_package(ZLIB REQUIRED)
183 find_package(Xt REQUIRED)
184 find_package(ATK REQUIRED)
185 find_package(WebP REQUIRED)
186 find_package(GStreamer 1.0.3 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS})
187 find_package(ATSPI 2.5.3)
188 find_package(GObjectIntrospection)
189
190 if (NOT USE_GTK2)
191     find_package(GTK3 3.6.0 REQUIRED)
192     find_package(GDK3 3.6.0 REQUIRED)
193     set(GTK_LIBRARIES ${GTK3_LIBRARIES})
194     set(GTK_INCLUDE_DIRS ${GTK3_INCLUDE_DIRS})
195     set(GDK_LIBRARIES ${GDK3_LIBRARIES})
196     set(GDK_INCLUDE_DIRS ${GDK3_INCLUDE_DIRS})
197 else ()
198     set(GTK_LIBRARIES ${GTK2_LIBRARIES})
199     set(GTK_INCLUDE_DIRS ${GTK2_INCLUDE_DIRS})
200     set(GDK_LIBRARIES ${GDK2_LIBRARIES})
201     set(GDK_INCLUDE_DIRS ${GDK2_INCLUDE_DIRS})
202     add_definitions(-DGTK_API_VERSION_2)
203     add_definitions(-DWEBKITGTK_API_VERSION_STRING="2.0")
204 endif ()
205
206 set(glib_components gio gobject gthread gmodule)
207 if (ENABLE_GAMEPAD)
208     list(APPEND glib_components gio-unix)
209 endif ()
210 find_package(GLIB 2.33.2 REQUIRED COMPONENTS ${glib_components})
211
212 if (ENABLE_GEOLOCATION)
213     find_package(GeoClue)
214 endif ()
215
216 # We don't use find_package for GLX because it is part of -lGL, unlike EGL.
217 find_package(OpenGL)
218 check_include_files("GL/glx.h" GLX_FOUND)
219 find_package(EGL)
220
221 if (EGL_FOUND)
222     set(WTF_USE_EGL 1)
223 endif ()
224
225 if (ENABLE_SPELLCHECK)
226     find_package(Enchant REQUIRED)
227 endif ()
228
229 if (${OPENGL_FOUND} AND (${GLX_FOUND} OR ${EGL_FOUND}))
230     set(ENABLE_WEBGL 1)
231     set(ENABLE_TEXTURE_MAPPER 1)
232     set(WTF_USE_3D_GRAPHICS 1)
233
234     add_definitions(-DWTF_USE_OPENGL=1)
235     add_definitions(-DWTF_USE_ACCELERATED_COMPOSITING=1)
236     add_definitions(-DWTF_USE_3D_GRAPHICS=1)
237     add_definitions(-DWTF_USE_TEXTURE_MAPPER=1)
238     add_definitions(-DWTF_USE_TEXTURE_MAPPER_GL=1)
239     add_definitions(-DENABLE_3D_RENDERING=1)
240
241     if (${EGL_FOUND})
242         add_definitions(-DWTF_USE_EGL=1)
243     endif ()
244
245     if (${GLX_FOUND})
246         add_definitions(-DWTF_USE_GLX=1)
247     endif ()
248 endif ()
249
250 if (ENABLE_INDEXED_DATABASE)
251     set(WTF_USE_LEVELDB 1)
252     add_definitions(-DWTF_USE_LEVELDB=1)
253 endif ()
254
255 if (ENABLE_GAMEPAD)
256     find_package(GUdev)
257 endif ()
258
259 set(CPACK_SOURCE_GENERATOR TBZ2)
260
261 set(DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR ${DERIVED_SOURCES_DIR}/webkitdom)
262 set(DERIVED_SOURCES_WEBKITGTK_DIR ${DERIVED_SOURCES_DIR}/webkitgtk)
263 set(DERIVED_SOURCES_WEBKITGTK_API_DIR ${DERIVED_SOURCES_WEBKITGTK_DIR}/webkit)
264 set(DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR ${DERIVED_SOURCES_DIR}/webkitdom)
265 set(DERIVED_SOURCES_WEBKIT2GTK_DIR ${DERIVED_SOURCES_DIR}/webkit2gtk)
266 set(DERIVED_SOURCES_WEBKIT2GTK_API_DIR ${DERIVED_SOURCES_WEBKIT2GTK_DIR}/webkit2)
267 set(FORWARDING_HEADERS_DIR ${DERIVED_SOURCES_DIR}/ForwardingHeaders)
268 set(FORWARDING_HEADERS_WEBKIT2GTK_DIR ${FORWARDING_HEADERS_DIR}/webkit2gtk)
269 set(FORWARDING_HEADERS_WEBKIT2GTK_EXTENSION_DIR ${FORWARDING_HEADERS_DIR}/webkit2gtk-webextension)
270
271 set(WebKit_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/Source/WebKit/gtk/webkitgtk-${WEBKITGTK_API_VERSION}.pc)
272 set(WebKit2_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/Source/WebKit2/webkit2gtk-${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 (CMAKE_COMPILER_IS_GNUCC AND UNIX AND NOT APPLE)
278     set(CMAKE_C_FLAGS_RELEASE "-fno-omit-frame-pointer -fno-tree-dce ${CMAKE_C_FLAGS_RELEASE}")
279     set(CMAKE_CXX_FLAGS_RELEASE "-fno-omit-frame-pointer -fno-tree-dce ${CMAKE_CXX_FLAGS_RELEASE}")
280 endif ()
281
282 # Add a typelib file to the list of all typelib dependencies. This makes it easy to
283 # expose a 'gir' target with all gobject-introspection files.
284 macro(ADD_TYPELIB typelib)
285     get_filename_component(target_name ${typelib} NAME_WE)
286     add_custom_target(${target_name}-gir ALL DEPENDS ${typelib})
287     list(APPEND GObjectIntrospectionTargets ${target_name}-gir)
288     set(GObjectIntrospectionTargets ${GObjectIntrospectionTargets} PARENT_SCOPE)
289 endmacro()