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