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