[WPE][GTK] Make building WebVR (w/OpenVR) not depend on ENABLE_EXPERIMENTAL_FEATURES
[WebKit-https.git] / Source / cmake / OptionsWPE.cmake
1 include(GNUInstallDirs)
2 include(VersioningUtils)
3
4 SET_PROJECT_VERSION(2 25 0)
5 set(WPE_API_VERSION 1.0)
6
7 CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(WEBKIT 6 0 3)
8
9 # These are shared variables, but we special case their definition so that we can use the
10 # CMAKE_INSTALL_* variables that are populated by the GNUInstallDirs macro.
11 set(LIB_INSTALL_DIR "${CMAKE_INSTALL_FULL_LIBDIR}" CACHE PATH "Absolute path to library installation directory")
12 set(EXEC_INSTALL_DIR "${CMAKE_INSTALL_FULL_BINDIR}" CACHE PATH "Absolute path to executable installation directory")
13 set(LIBEXEC_INSTALL_DIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}/wpe-webkit-${WPE_API_VERSION}" CACHE PATH "Absolute path to install executables executed by the library")
14
15 find_package(Cairo 1.10.2 REQUIRED)
16 find_package(Fontconfig 2.8.0 REQUIRED)
17 find_package(Freetype 2.4.2 REQUIRED)
18 find_package(GLIB 2.40.0 REQUIRED COMPONENTS gio gio-unix gobject gthread gmodule)
19 find_package(HarfBuzz 0.9.18 REQUIRED)
20 find_package(ICU REQUIRED)
21 find_package(JPEG REQUIRED)
22 find_package(LibEpoxy 1.4.0 REQUIRED)
23 find_package(LibGcrypt 1.6.0 REQUIRED)
24 find_package(LibSoup 2.42.0 REQUIRED)
25 find_package(LibXml2 2.8.0 REQUIRED)
26 find_package(PNG REQUIRED)
27 find_package(Sqlite REQUIRED)
28 find_package(Threads REQUIRED)
29 find_package(WebP REQUIRED)
30 find_package(WPE REQUIRED)
31 find_package(ZLIB REQUIRED)
32
33 WEBKIT_OPTION_BEGIN()
34
35 include(GStreamerDefinitions)
36
37 # Public options shared with other WebKit ports. Do not add any options here
38 # without approval from a WPE reviewer. There must be strong reason to support
39 # changing the value of the option.
40 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS PUBLIC OFF)
41 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ENCRYPTED_MEDIA PUBLIC ${ENABLE_EXPERIMENTAL_FEATURES})
42 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBDRIVER PUBLIC ON)
43 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_CRYPTO PUBLIC ON)
44 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_XSLT PUBLIC ON)
45
46 # Private options shared with other WebKit ports. Add options here only if
47 # we need a value different from the default defined in WebKitFeatures.cmake.
48 # Changing these options is completely unsupported.
49 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ASYNC_SCROLLING PRIVATE ON)
50 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CONTENT_EXTENSIONS PRIVATE ON)
51 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MHTML PRIVATE ON)
52 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETSCAPE_PLUGIN_API PRIVATE OFF)
53 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NOTIFICATIONS PRIVATE OFF)
54 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SERVICE_WORKER PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
55 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SMOOTH_SCROLLING PRIVATE OFF)
56 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TOUCH_EVENTS PRIVATE ON)
57 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL2 PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
58 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_STREAM PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
59 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_RTC PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
60
61 # Public options specific to the WPE port. Do not add any options here unless
62 # there is a strong reason we should support changing the value of the option,
63 # and the option is not relevant to any other WebKit ports.
64 WEBKIT_OPTION_DEFINE(ENABLE_GTKDOC "Whether or not to use generate gtkdoc." PUBLIC OFF)
65 WEBKIT_OPTION_DEFINE(USE_OPENJPEG "Whether to enable support for JPEG2000 images." PUBLIC ON)
66 WEBKIT_OPTION_DEFINE(USE_WOFF2 "Whether to enable support for WOFF2 Web Fonts." PUBLIC ON)
67 WEBKIT_OPTION_DEFINE(ENABLE_WPE_QT_API "Whether to enable support for the Qt5/QML plugin" PUBLIC OFF)
68
69 # Private options specific to the WPE port.
70 WEBKIT_OPTION_DEFINE(USE_OPENVR "Whether to use OpenVR as WebVR backend." PRIVATE OFF)
71 WEBKIT_OPTION_DEFINE(USE_GSTREAMER_HOLEPUNCH "Whether to enable GStreamer holepunch" PRIVATE OFF)
72 WEBKIT_OPTION_DEFINE(USE_EXTERNAL_HOLEPUNCH "Whether to enable external holepunch" PRIVATE OFF)
73
74 if (CMAKE_SYSTEM_NAME MATCHES "Linux")
75     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEMORY_SAMPLER PRIVATE ON)
76     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_RESOURCE_USAGE PRIVATE ON)
77 else ()
78     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEMORY_SAMPLER PRIVATE OFF)
79     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_RESOURCE_USAGE PRIVATE OFF)
80 endif ()
81
82 SET_AND_EXPOSE_TO_BUILD(ENABLE_DEVELOPER_MODE ${DEVELOPER_MODE})
83 if (DEVELOPER_MODE)
84     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS PRIVATE ON)
85     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MINIBROWSER PUBLIC ON)
86 endif ()
87
88 if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT EXISTS "/.flatpak-info")
89     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BUBBLEWRAP_SANDBOX PUBLIC ON)
90 else ()
91     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BUBBLEWRAP_SANDBOX PUBLIC OFF)
92 endif ()
93
94 # Enable variation fonts when cairo >= 1.16, fontconfig >= 2.13.0, freetype >= 2.9.0 and harfbuzz >= 1.4.2.
95 if (("${PC_CAIRO_VERSION}" VERSION_GREATER "1.16.0" OR "${PC_CAIRO_VERSION}" STREQUAL "1.16.0")
96     AND ("${PC_FONTCONFIG_VERSION}" VERSION_GREATER "2.13.0" OR "${PC_FONTCONFIG_VERSION}" STREQUAL "2.13.0")
97     AND ("${FREETYPE_VERSION_STRING}" VERSION_GREATER "2.9.0" OR "${FREETYPE_VERSION_STRING}" STREQUAL "2.9.0")
98     AND ("${PC_HARFBUZZ_VERSION}" VERSION_GREATER "1.4.2" OR "${PC_HARFBUZZ_VERSION}" STREQUAL "1.4.2"))
99     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VARIATION_FONTS PRIVATE ON)
100 endif ()
101
102 WEBKIT_OPTION_DEPEND(USE_GSTREAMER_HOLEPUNCH ENABLE_VIDEO)
103 WEBKIT_OPTION_DEPEND(USE_EXTERNAL_HOLEPUNCH ENABLE_VIDEO)
104
105 include(GStreamerDependencies)
106
107 WEBKIT_OPTION_END()
108
109 if (USE_OPENJPEG)
110     find_package(OpenJPEG)
111     if (NOT OpenJPEG_FOUND)
112         message(FATAL_ERROR "libopenjpeg is needed for USE_OPENJPEG.")
113     endif ()
114     if ("${OPENJPEG_MAJOR_VERSION}.${OPENJPEG_MINOR_VERSION}.${OPENJPEG_BUILD_VERSION}" VERSION_LESS "2.2.0")
115         message(FATAL_ERROR "libopenjpeg 2.2.0 is required for USE_OPENJPEG.")
116     endif ()
117 endif ()
118
119 if (USE_WOFF2)
120     find_package(WOFF2Dec 1.0.2)
121     if (NOT WOFF2DEC_FOUND)
122         message(FATAL_ERROR "liwoff2dec is needed for USE_WOFF2.")
123     endif ()
124 endif ()
125
126 if (ENABLE_ACCELERATED_2D_CANVAS)
127     find_package(CairoGL 1.10.2 REQUIRED COMPONENTS cairo-egl)
128 endif ()
129
130 if (ENABLE_WEB_CRYPTO)
131     find_package(Libtasn1 REQUIRED)
132     if (NOT LIBTASN1_FOUND)
133         message(FATAL_ERROR "libtasn1 is required to enable Web Crypto API support.")
134     endif ()
135     if (LIBGCRYPT_VERSION VERSION_LESS 1.7.0)
136         message(FATAL_ERROR "libgcrypt 1.7.0 is required to enable Web Crypto API support.")
137     endif ()
138 endif ()
139
140 if (ENABLE_XSLT)
141     find_package(LibXslt 1.1.7 REQUIRED)
142 endif ()
143
144 if (ENABLE_WPE_QT_API)
145     find_package(Qt5 REQUIRED COMPONENTS Core Quick Gui)
146     find_package(Qt5Test REQUIRED)
147     find_package(PkgConfig)
148     pkg_check_modules(WPE_BACKEND_FDO REQUIRED wpebackend-fdo-1.0)
149 endif ()
150
151 add_definitions(-DBUILDING_WPE__=1)
152 add_definitions(-DGETTEXT_PACKAGE="WPE")
153 add_definitions(-DJSC_GLIB_API_ENABLED)
154
155 SET_AND_EXPOSE_TO_BUILD(USE_CAIRO TRUE)
156 SET_AND_EXPOSE_TO_BUILD(USE_EGL TRUE)
157 SET_AND_EXPOSE_TO_BUILD(USE_GCRYPT TRUE)
158 SET_AND_EXPOSE_TO_BUILD(USE_LIBEPOXY TRUE)
159 SET_AND_EXPOSE_TO_BUILD(USE_LIBWPE TRUE)
160 SET_AND_EXPOSE_TO_BUILD(USE_OPENGL_ES TRUE)
161 SET_AND_EXPOSE_TO_BUILD(USE_XDGMIME TRUE)
162
163 if (WTF_CPU_ARM OR WTF_CPU_MIPS)
164     SET_AND_EXPOSE_TO_BUILD(USE_CAPSTONE ${DEVELOPER_MODE})
165 endif ()
166
167 SET_AND_EXPOSE_TO_BUILD(ENABLE_GRAPHICS_CONTEXT_3D TRUE)
168
169 SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER TRUE)
170 SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER_GL TRUE)
171 SET_AND_EXPOSE_TO_BUILD(USE_TILED_BACKING_STORE TRUE)
172 SET_AND_EXPOSE_TO_BUILD(USE_COORDINATED_GRAPHICS TRUE)
173 SET_AND_EXPOSE_TO_BUILD(USE_NICOSIA TRUE)
174
175 # Override the cached variable, gtk-doc does not really work when cross-building or building on Mac.
176 if (CMAKE_CROSSCOMPILING OR APPLE)
177     set(ENABLE_GTKDOC OFF)
178 endif ()
179
180 set(FORWARDING_HEADERS_DIR ${DERIVED_SOURCES_DIR}/ForwardingHeaders)
181 set(FORWARDING_HEADERS_WPE_DIR ${FORWARDING_HEADERS_DIR}/wpe)
182 set(FORWARDING_HEADERS_WPE_EXTENSION_DIR ${FORWARDING_HEADERS_DIR}/wpe-webextension)
183 set(FORWARDING_HEADERS_WPE_DOM_DIR ${FORWARDING_HEADERS_DIR}/wpe-dom)
184 set(DERIVED_SOURCES_JAVASCRIPCOREWPE_DIR ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/javascriptcorewpe)
185 set(DERIVED_SOURCES_JAVASCRIPCORE_GLIB_API_DIR ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/javascriptcorewpe/jsc)
186 set(DERIVED_SOURCES_WPE_API_DIR ${DERIVED_SOURCES_WEBKIT_DIR}/wpe)
187
188 set(WPE_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/wpe-webkit-${WPE_API_VERSION}.pc)
189 set(WPEWebExtension_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/wpe-web-extension-${WPE_API_VERSION}.pc)
190
191 include(BubblewrapSandboxChecks)
192 include(GStreamerChecks)