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