2dc9f411a53bccf5966c76b6298444926c7048b6
[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_FAST_MOBILE_SCROLLING ON)
48 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FILTERS ON)
49 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FULLSCREEN_API ON)
50 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GAMEPAD OFF)
51 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INDEXED_DATABASE ON)
52 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INPUT_TYPE_COLOR OFF)
53 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LINK_PREFETCH ON)
54 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LLINT ON)
55 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_CAPTURE ON)
56 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_CONTROLS_SCRIPT ON)
57 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEMORY_SAMPLER ON)
58 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MHTML ON)
59 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NAVIGATOR_CONTENT_UTILS ON)
60 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETSCAPE_PLUGIN_API ON)
61 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETWORK_INFO ON)
62 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_PAGE_VISIBILITY_API ON)
63 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_QUOTA OFF)
64 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_RESOLUTION_MEDIA_QUERY OFF)
65 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REQUEST_ANIMATION_FRAME ON)
66 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SECCOMP_FILTERS OFF)
67 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SHARED_WORKERS ON)
68 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SPELLCHECK ON)
69 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TEMPLATE_ELEMENT ON)
70 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TOUCH_EVENTS ON)
71 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_USERSELECT_ALL ON)
72 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIBRATION OFF)
73 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO ON)
74 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO_TRACK ON)
75 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIEW_MODE_CSS_MEDIA ON)
76 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_AUDIO ON)
77 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_TIMING ON)
78 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL OFF)
79 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_XHR_TIMEOUT ON)
80 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETWORK_PROCESS ON)
81 WEBKIT_OPTION_DEFAULT_PORT_VALUE(WTF_USE_TILED_BACKING_STORE OFF)
82
83 # FIXME: Perhaps we need a more generic way of defining dependencies between features.
84 # VIDEO_TRACK depends on VIDEO.
85 if (NOT ENABLE_VIDEO AND ENABLE_VIDEO_TRACK)
86     message(STATUS "Disabling VIDEO_TRACK since VIDEO support is disabled.")
87     set(ENABLE_VIDEO_TRACK OFF)
88 endif ()
89
90 if (PRODUCTION_MODE)
91     set(ENABLE_TOOLS OFF)
92     set(ENABLE_API_TESTS OFF)
93     set(VERSION_SCRIPT "-Wl,--version-script,${CMAKE_SOURCE_DIR}/Source/autotools/symbols.filter")
94 else ()
95     set(ENABLE_TOOLS ON)
96     set(ENABLE_API_TESTS ON)
97 endif ()
98
99 WEBKIT_OPTION_END()
100
101 set(ENABLE_WEBCORE ON)
102 set(ENABLE_INSPECTOR ON)
103 set(ENABLE_WEBKIT ON)
104 if (NOT USE_GTK2)
105     set(WEBKITGTK_API_VERSION 3.0)
106     set(GTK_API_VERSION 3.0)
107     set(ENABLE_PLUGIN_PROCESS ON)
108     set(ENABLE_WEBKIT2 ON)
109 else ()
110     set(WEBKITGTK_API_VERSION 2.0)
111     set(GTK_API_VERSION 2.0)
112     set(ENABLE_PLUGIN_PROCESS OFF)
113     set(ENABLE_WEBKIT2 OFF)
114 endif ()
115
116 # These are used to generate the pkg-config files.
117 set(prefix ${CMAKE_INSTALL_PREFIX})
118 set(exec_prefix ${CMAKE_INSTALL_PREFIX})
119 set(libdir "${prefix}/${CMAKE_INSTALL_LIBDIR}")
120 set(includedir "${prefix}/include")
121 set(VERSION ${PROJECT_VERSION})
122
123 set(WTF_USE_SOUP 1)
124
125 set(WTF_OUTPUT_NAME WTFGTK)
126 set(JavaScriptCore_OUTPUT_NAME javascriptcoregtk-${WEBKITGTK_API_VERSION})
127 set(WebCore_OUTPUT_NAME WebCoreGTK)
128 set(WebKit_OUTPUT_NAME webkitgtk-${WEBKITGTK_API_VERSION})
129 set(WebKit2_OUTPUT_NAME webkit2gtk-${WEBKITGTK_API_VERSION})
130 set(WebKit2_WebProcess_OUTPUT_NAME WebKitWebProcess)
131 set(WebKit2_NetworkProcess_OUTPUT_NAME WebKitNetworkProcess)
132
133 set(DATA_BUILD_DIR "${CMAKE_BINARY_DIR}/share/${WebKit_OUTPUT_NAME}")
134 set(DATA_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/webkitgtk-${WEBKITGTK_API_VERSION}")
135 set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Where to install libraries")
136 set(EXEC_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "Where to install executables")
137 set(LIBEXEC_INSTALL_DIR "${CMAKE_INSTALL_LIBEXECDIR}" CACHE PATH "Where to install executables executed by the library")
138 set(WEBKITGTK_HEADER_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/webkitgtk-${WEBKITGTK_API_VERSION}")
139
140 add_definitions(-DBUILDING_GTK__=1)
141 add_definitions(-DGETTEXT_PACKAGE="WebKitGTK-${WEBKITGTK_API_VERSION}")
142 add_definitions(-DDATA_DIR="${CMAKE_INSTALL_DATADIR}")
143 add_definitions(-DUSER_AGENT_GTK_MAJOR_VERSION=537)
144 add_definitions(-DUSER_AGENT_GTK_MINOR_VERSION=30)
145 add_definitions(-DWEBKITGTK_API_VERSION_STRING="${WEBKITGTK_API_VERSION}")
146
147 if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO)
148     add_definitions(-DWTF_USE_GSTREAMER)
149 endif ()
150
151 if (ENABLE_WEB_AUDIO)
152     add_definitions(-DWTF_USE_WEBAUDIO_GSTREAMER)
153 endif ()
154
155 # FIXME: These need to be configurable.
156 add_definitions(-DWTF_PLATFORM_X11=1)
157 add_definitions(-DMOZ_X11)
158
159 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
160     set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> cruT <TARGET> <LINK_FLAGS> <OBJECTS>")
161     set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cruT <TARGET> <LINK_FLAGS> <OBJECTS>")
162     set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> ruT <TARGET> <LINK_FLAGS> <OBJECTS>")
163     set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> ruT <TARGET> <LINK_FLAGS> <OBJECTS>")
164 endif ()
165
166 find_package(Cairo 1.10.2 REQUIRED)
167 find_package(Fontconfig 2.8.0 REQUIRED)
168 find_package(Freetype 2.4.2 REQUIRED)
169 find_package(GTK2 2.24.10 REQUIRED)
170 find_package(GDK2 2.24.10 REQUIRED)
171 find_package(HarfBuzz 0.9.2 REQUIRED)
172 find_package(ICU REQUIRED)
173 find_package(JPEG REQUIRED)
174 find_package(LibSoup 2.40.3 REQUIRED)
175 find_package(LibXml2 2.8.0 REQUIRED)
176 find_package(LibXslt 1.1.7 REQUIRED)
177 find_package(PNG REQUIRED)
178 find_package(Sqlite REQUIRED)
179 find_package(Threads REQUIRED)
180 find_package(ZLIB REQUIRED)
181 find_package(Xt REQUIRED)
182 find_package(ATK REQUIRED)
183 find_package(WebP REQUIRED)
184 find_package(GStreamer 1.0.3 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS})
185 find_package(ATSPI 2.5.3)
186 find_package(GObjectIntrospection)
187
188 if (NOT USE_GTK2)
189     find_package(GTK3 3.6.0 REQUIRED)
190     find_package(GDK3 3.6.0 REQUIRED)
191     set(GTK_LIBRARIES ${GTK3_LIBRARIES})
192     set(GTK_INCLUDE_DIRS ${GTK3_INCLUDE_DIRS})
193     set(GDK_LIBRARIES ${GDK3_LIBRARIES})
194     set(GDK_INCLUDE_DIRS ${GDK3_INCLUDE_DIRS})
195 else ()
196     set(GTK_LIBRARIES ${GTK2_LIBRARIES})
197     set(GTK_INCLUDE_DIRS ${GTK2_INCLUDE_DIRS})
198     set(GDK_LIBRARIES ${GDK2_LIBRARIES})
199     set(GDK_INCLUDE_DIRS ${GDK2_INCLUDE_DIRS})
200     add_definitions(-DGTK_API_VERSION_2)
201     add_definitions(-DWEBKITGTK_API_VERSION_STRING="2.0")
202 endif ()
203
204 set(glib_components gio gobject gthread gmodule)
205 if (ENABLE_GAMEPAD)
206     list(APPEND glib_components gio-unix)
207 endif ()
208 find_package(GLIB 2.33.2 REQUIRED COMPONENTS ${glib_components})
209
210 if (ENABLE_GEOLOCATION)
211     find_package(GeoClue)
212 endif ()
213
214 # We don't use find_package for GLX because it is part of -lGL, unlike EGL.
215 find_package(OpenGL)
216 check_include_files("GL/glx.h" GLX_FOUND)
217 find_package(EGL)
218
219 if (EGL_FOUND)
220     set(WTF_USE_EGL 1)
221 endif ()
222
223 if (ENABLE_SPELLCHECK)
224     find_package(Enchant REQUIRED)
225 endif ()
226
227 if (${OPENGL_FOUND} AND (${GLX_FOUND} OR ${EGL_FOUND}))
228     set(ENABLE_WEBGL 1)
229     set(ENABLE_TEXTURE_MAPPER 1)
230     set(WTF_USE_3D_GRAPHICS 1)
231
232     add_definitions(-DWTF_USE_OPENGL=1)
233     add_definitions(-DWTF_USE_ACCELERATED_COMPOSITING=1)
234     add_definitions(-DWTF_USE_3D_GRAPHICS=1)
235     add_definitions(-DWTF_USE_TEXTURE_MAPPER=1)
236     add_definitions(-DWTF_USE_TEXTURE_MAPPER_GL=1)
237     add_definitions(-DENABLE_3D_RENDERING=1)
238
239     if (${EGL_FOUND})
240         add_definitions(-DWTF_USE_EGL=1)
241     endif ()
242
243     if (${GLX_FOUND})
244         add_definitions(-DWTF_USE_GLX=1)
245     endif ()
246 endif ()
247
248 if (ENABLE_INDEXED_DATABASE)
249     set(WTF_USE_LEVELDB 1)
250     add_definitions(-DWTF_USE_LEVELDB=1)
251 endif ()
252
253 if (ENABLE_GAMEPAD)
254     find_package(GUdev)
255 endif ()
256
257 set(CPACK_SOURCE_GENERATOR TBZ2)
258
259 set(DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR ${DERIVED_SOURCES_DIR}/webkitdom)
260 set(DERIVED_SOURCES_WEBKITGTK_DIR ${DERIVED_SOURCES_DIR}/webkitgtk)
261 set(DERIVED_SOURCES_WEBKITGTK_API_DIR ${DERIVED_SOURCES_WEBKITGTK_DIR}/webkit)
262 set(DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR ${DERIVED_SOURCES_DIR}/webkitdom)
263 set(DERIVED_SOURCES_WEBKIT2GTK_DIR ${DERIVED_SOURCES_DIR}/webkit2gtk)
264 set(DERIVED_SOURCES_WEBKIT2GTK_API_DIR ${DERIVED_SOURCES_WEBKIT2GTK_DIR}/webkit2)
265 set(FORWARDING_HEADERS_DIR ${DERIVED_SOURCES_DIR}/ForwardingHeaders)
266 set(FORWARDING_HEADERS_WEBKIT2GTK_DIR ${FORWARDING_HEADERS_DIR}/webkit2gtk)
267 set(FORWARDING_HEADERS_WEBKIT2GTK_EXTENSION_DIR ${FORWARDING_HEADERS_DIR}/webkit2gtk-webextension)
268
269 set(WebKit_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/Source/WebKit/gtk/webkitgtk-${WEBKITGTK_API_VERSION}.pc)
270 set(WebKit2_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/Source/WebKit2/webkit2gtk-${WEBKITGTK_API_VERSION}.pc)
271
272 set(SHOULD_INSTALL_JS_SHELL ON)
273
274 # Push of rbp is needed after JSC JIT uses CStack. See http://wkbug.com/127777.
275 if (CMAKE_COMPILER_IS_GNUCC AND UNIX AND NOT APPLE)
276     set(CMAKE_C_FLAGS_RELEASE "-fno-omit-frame-pointer -fno-tree-dce ${CMAKE_C_FLAGS_RELEASE}")
277     set(CMAKE_CXX_FLAGS_RELEASE "-fno-omit-frame-pointer -fno-tree-dce ${CMAKE_CXX_FLAGS_RELEASE}")
278 endif ()
279
280 # Add a typelib file to the list of all typelib dependencies. This makes it easy to
281 # expose a 'gir' target with all gobject-introspection files.
282 macro(ADD_TYPELIB typelib)
283     get_filename_component(target_name ${typelib} NAME_WE)
284     add_custom_target(${target_name}-gir ALL DEPENDS ${typelib})
285     list(APPEND GObjectIntrospectionTargets ${target_name}-gir)
286     set(GObjectIntrospectionTargets ${GObjectIntrospectionTargets} PARENT_SCOPE)
287 endmacro()