[WPE] Enable web process sandbox
[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 0.1)
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_GEOLOCATION PRIVATE OFF)
52 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MHTML PRIVATE ON)
53 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETSCAPE_PLUGIN_API PRIVATE OFF)
54 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NOTIFICATIONS PRIVATE OFF)
55 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SERVICE_WORKER PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
56 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SMOOTH_SCROLLING PRIVATE OFF)
57 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TOUCH_EVENTS PRIVATE ON)
58 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL2 PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
59 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_STREAM PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
60 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_RTC PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
61
62 # Public options specific to the WPE port. Do not add any options here unless
63 # there is a strong reason we should support changing the value of the option,
64 # and the option is not relevant to any other WebKit ports.
65 WEBKIT_OPTION_DEFINE(ENABLE_GTKDOC "Whether or not to use generate gtkdoc." PUBLIC OFF)
66 WEBKIT_OPTION_DEFINE(USE_OPENJPEG "Whether to enable support for JPEG2000 images." PUBLIC ON)
67 WEBKIT_OPTION_DEFINE(USE_WOFF2 "Whether to enable support for WOFF2 Web Fonts." PUBLIC ON)
68 WEBKIT_OPTION_DEFINE(ENABLE_WPE_QT_API "Whether to enable support for the Qt5/QML plugin" PUBLIC OFF)
69
70 # Private options specific to the WPE port.
71 WEBKIT_OPTION_DEFINE(USE_OPENVR "Whether to use OpenVR as WebVR backend." PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
72 WEBKIT_OPTION_DEFINE(USE_GSTREAMER_HOLEPUNCH "Whether to enable GStreamer holepunch" PRIVATE OFF)
73 WEBKIT_OPTION_DEFINE(USE_EXTERNAL_HOLEPUNCH "Whether to enable external holepunch" PRIVATE OFF)
74
75 if (CMAKE_SYSTEM_NAME MATCHES "Linux")
76     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEMORY_SAMPLER PRIVATE ON)
77     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_RESOURCE_USAGE PRIVATE ON)
78 else ()
79     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEMORY_SAMPLER PRIVATE OFF)
80     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_RESOURCE_USAGE PRIVATE OFF)
81 endif ()
82
83 SET_AND_EXPOSE_TO_BUILD(ENABLE_DEVELOPER_MODE ${DEVELOPER_MODE})
84 if (DEVELOPER_MODE)
85     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS PRIVATE ON)
86     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MINIBROWSER PUBLIC ON)
87 endif ()
88
89 if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT EXISTS "/.flatpak-info")
90     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BUBBLEWRAP_SANDBOX PUBLIC ON)
91 else ()
92     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BUBBLEWRAP_SANDBOX PUBLIC OFF)
93 endif ()
94
95 # Enable variation fonts when cairo >= 1.16, fontconfig >= 2.13.0, freetype >= 2.9.0 and harfbuzz >= 1.4.2.
96 if (("${PC_CAIRO_VERSION}" VERSION_GREATER "1.16.0" OR "${PC_CAIRO_VERSION}" STREQUAL "1.16.0")
97     AND ("${PC_FONTCONFIG_VERSION}" VERSION_GREATER "2.13.0" OR "${PC_FONTCONFIG_VERSION}" STREQUAL "2.13.0")
98     AND ("${FREETYPE_VERSION_STRING}" VERSION_GREATER "2.9.0" OR "${FREETYPE_VERSION_STRING}" STREQUAL "2.9.0")
99     AND ("${PC_HARFBUZZ_VERSION}" VERSION_GREATER "1.4.2" OR "${PC_HARFBUZZ_VERSION}" STREQUAL "1.4.2"))
100     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VARIATION_FONTS PRIVATE ON)
101 endif ()
102
103 WEBKIT_OPTION_DEPEND(USE_GSTREAMER_HOLEPUNCH ENABLE_VIDEO)
104 WEBKIT_OPTION_DEPEND(USE_EXTERNAL_HOLEPUNCH ENABLE_VIDEO)
105
106 include(GStreamerDependencies)
107
108 WEBKIT_OPTION_END()
109
110 if (USE_OPENJPEG)
111     find_package(OpenJPEG)
112     if (NOT OpenJPEG_FOUND)
113         message(FATAL_ERROR "libopenjpeg is needed for USE_OPENJPEG.")
114     endif ()
115     if ("${OPENJPEG_MAJOR_VERSION}.${OPENJPEG_MINOR_VERSION}.${OPENJPEG_BUILD_VERSION}" VERSION_LESS "2.2.0")
116         message(FATAL_ERROR "libopenjpeg 2.2.0 is required for USE_OPENJPEG.")
117     endif ()
118 endif ()
119
120 if (USE_WOFF2)
121     find_package(WOFF2Dec 1.0.2)
122     if (NOT WOFF2DEC_FOUND)
123         message(FATAL_ERROR "liwoff2dec is needed for USE_WOFF2.")
124     endif ()
125 endif ()
126
127 if (ENABLE_ACCELERATED_2D_CANVAS)
128     find_package(CairoGL 1.10.2 REQUIRED COMPONENTS cairo-egl)
129 endif ()
130
131 if (ENABLE_WEB_CRYPTO)
132     find_package(Libtasn1 REQUIRED)
133     if (NOT LIBTASN1_FOUND)
134         message(FATAL_ERROR "libtasn1 is required to enable Web Crypto API support.")
135     endif ()
136     if (LIBGCRYPT_VERSION VERSION_LESS 1.7.0)
137         message(FATAL_ERROR "libgcrypt 1.7.0 is required to enable Web Crypto API support.")
138     endif ()
139 endif ()
140
141 if (ENABLE_XSLT)
142     find_package(LibXslt 1.1.7 REQUIRED)
143 endif ()
144
145 if (ENABLE_WPE_QT_API)
146     find_package(Qt5 REQUIRED COMPONENTS Core Quick Gui)
147     find_package(Qt5Test REQUIRED)
148     find_package(PkgConfig)
149     pkg_check_modules(WPE_BACKEND_FDO REQUIRED wpebackend-fdo-1.0)
150 endif ()
151
152 add_definitions(-DBUILDING_WPE__=1)
153 add_definitions(-DGETTEXT_PACKAGE="WPE")
154 add_definitions(-DJSC_GLIB_API_ENABLED)
155
156 SET_AND_EXPOSE_TO_BUILD(USE_CAIRO TRUE)
157 SET_AND_EXPOSE_TO_BUILD(USE_EGL TRUE)
158 SET_AND_EXPOSE_TO_BUILD(USE_GCRYPT TRUE)
159 SET_AND_EXPOSE_TO_BUILD(USE_LIBEPOXY TRUE)
160 SET_AND_EXPOSE_TO_BUILD(USE_LIBWPE TRUE)
161 SET_AND_EXPOSE_TO_BUILD(USE_OPENGL_ES TRUE)
162 SET_AND_EXPOSE_TO_BUILD(USE_XDGMIME TRUE)
163
164 if (WTF_CPU_ARM OR WTF_CPU_MIPS)
165     SET_AND_EXPOSE_TO_BUILD(USE_CAPSTONE ${DEVELOPER_MODE})
166 endif ()
167
168 SET_AND_EXPOSE_TO_BUILD(ENABLE_GRAPHICS_CONTEXT_3D TRUE)
169
170 SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER TRUE)
171 SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER_GL TRUE)
172 SET_AND_EXPOSE_TO_BUILD(USE_TILED_BACKING_STORE TRUE)
173 SET_AND_EXPOSE_TO_BUILD(USE_COORDINATED_GRAPHICS TRUE)
174 SET_AND_EXPOSE_TO_BUILD(USE_NICOSIA TRUE)
175
176 # Override the cached variable, gtk-doc does not really work when cross-building or building on Mac.
177 if (CMAKE_CROSSCOMPILING OR APPLE)
178     set(ENABLE_GTKDOC OFF)
179 endif ()
180
181 set(FORWARDING_HEADERS_DIR ${DERIVED_SOURCES_DIR}/ForwardingHeaders)
182 set(FORWARDING_HEADERS_WPE_DIR ${FORWARDING_HEADERS_DIR}/wpe)
183 set(FORWARDING_HEADERS_WPE_EXTENSION_DIR ${FORWARDING_HEADERS_DIR}/wpe-webextension)
184 set(FORWARDING_HEADERS_WPE_DOM_DIR ${FORWARDING_HEADERS_DIR}/wpe-dom)
185 set(DERIVED_SOURCES_JAVASCRIPCOREWPE_DIR ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/javascriptcorewpe)
186 set(DERIVED_SOURCES_JAVASCRIPCORE_GLIB_API_DIR ${DERIVED_SOURCES_JAVASCRIPTCORE_DIR}/javascriptcorewpe/jsc)
187 set(DERIVED_SOURCES_WPE_API_DIR ${DERIVED_SOURCES_WEBKIT_DIR}/wpe)
188
189 set(WPE_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/wpe-webkit-${WPE_API_VERSION}.pc)
190 set(WPEWebExtension_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/wpe-web-extension-${WPE_API_VERSION}.pc)
191
192 include(BubblewrapSandboxChecks)
193 include(GStreamerChecks)