Rename backend feature flags to accomodate more renderers

Split backend-gl-* into eventloop-winit-* and renderer-femtovg.

The old feature names are still available.

For consistency eventloop-qt and renderer-qt are aliases for backend-qt.
This commit is contained in:
Simon Hausmann 2022-07-26 16:10:08 +02:00 committed by Simon Hausmann
parent 27bf9348e6
commit 3619989fcc
9 changed files with 106 additions and 39 deletions

View file

@ -80,18 +80,48 @@ endfunction()
# defaults need to be kept in sync with the Rust bit.
define_cargo_feature(interpreter "Enable support for the Slint interpeter to load .slint files at run-time" ON)
define_cargo_feature(backend-gl-all "Enable OpenGL ES 2.0 based rendering backend with support for all windowing systems." ON)
define_cargo_feature(backend-gl-x11 "Enable the OpenGL ES 2.0 backend with only X11 support on Unix. Enable this option and turn off SLINT_FEATURE_BACKEND_GL_ALL for a smaller build with just X11 support on Unix." OFF)
define_cargo_feature(backend-gl-wayland "Enable the OpenGL ES 2.0 backend with wayland support on Unix. Enable this option and turn off SLINT_FEATURE_BACKEND_GL_ALL for a smaller build with just wayland support." OFF)
define_cargo_feature(eventloop-winit "Enable support for the winit crate to interaction with all windowing systems." ON)
define_cargo_feature(eventloop-winit-x11 "Enable support for the winit create to interact only with the X11 windowing system on Unix. Enable this option and turn off SLINT_FEATURE_EVENTLOOP_WINIT_ALL for a smaller build with just X11 support on Unix." OFF)
define_cargo_feature(eventloop-winit-wayland "Enable support for the winit create to interact only with the wayland windowing system on Unix. Enable this option and turn off SLINT_FEATURE_EVENTLOOP_WINIT_ALL for a smaller build with just wayland support." OFF)
define_cargo_feature(renderer-femtovg "Enable support for the OpenGL ES 2.0 based FemtoVG rendering engine." ON)
define_cargo_feature(backend-qt "Enable Qt based rendering backend" ON)
# Compat options
define_cargo_feature(backend-gl-all "This feature is an alias for SLINT_FEATURE_EVENTLOOP_WINIT_ALL and SLINT_FEATURE_RENDERER_FEMTOVG." OFF)
define_cargo_feature(backend-gl-x11 "This feature is an alias for SLINT_FEATURE_EVENTLOOP_WINIT_X11 and SLINT_FEATURE_RENDERER_FEMTOVG." OFF)
define_cargo_feature(backend-gl-wayland "This feature is an alias for SLINT_FEATURE_EVENTLOOP_WINIT_WAYLAND and SLINT_FEATURE_RENDERER_FEMTOVG." OFF)
if(SLINT_FEATURE_BACKEND_GL_ALL)
set(SLINT_FEATURE_EVENTLOOP_WINIT_ALL ON)
set(SLINT_FEATURE_RENDERER_FEMTOVG ON)
endif()
if(SLINT_FEATURE_BACKEND_GL_X11)
set(SLINT_FEATURE_EVENTLOOP_WINIT_X11 ON)
set(SLINT_FEATURE_RENDERER_FEMTOVG ON)
endif()
if(SLINT_FEATURE_BACKEND_GL_WAYLAND)
set(SLINT_FEATURE_EVENTLOOP_WINIT_WAYLAND ON)
set(SLINT_FEATURE_RENDERER_FEMTOVG ON)
endif()
# Alias
define_cargo_feature(renderer-qt "This feature is an alias for SLINT_FEATURE_BACKEND_QT" OFF)
define_cargo_feature(eventloop-qt "This feature is an alias for SLINT_FEATURE_BACKEND_QT" OFF)
if(SLINT_FEATURE_RENDERER_QT OR SLINT_FEATURE_EVENTLOOP_QT)
set(SLINT_FEATURE_BACKEND_QT ON)
endif()
if(SLINT_FEATURE_INTERPRETER)
if(SLINT_FEATURE_BACKEND_QT)
list(APPEND features rtti-qt)
endif()
if(SLINT_FEATURE_BACKEND_GL_ALL OR SLINT_FEATURE_BACKEND_GL_X11 OR SLINT_FEATURE_BACKEND_GL_WAYLAND)
if(SLINT_FEATURE_EVENTLOOP_WINIT_ALL OR SLINT_FEATURE_EVENTLOOP_WINIT_X11 OR SLINT_FEATURE_EVENTLOOP_WINIT_WAYLAND)
list(APPEND features rtti-winit)
endif()
endif()

View file

@ -23,17 +23,19 @@ crate-type = ["lib", "cdylib"]
# Note, these features need to be kept in sync (along with their defaults) in
# the C++ crate's CMakeLists.txt
[features]
backend-qt = ["i-slint-backend-selector/i-slint-backend-qt"]
interpreter = ["slint-interpreter"]
testing = ["i-slint-backend-testing"] # Enable some function used by the integration tests
backend-gl-all = ["i-slint-backend-selector/backend-gl-all"]
backend-gl-wayland = ["i-slint-backend-selector/backend-gl-wayland"]
backend-gl-x11 = ["i-slint-backend-selector/backend-gl-x11"]
backend-qt = ["i-slint-backend-selector/i-slint-backend-qt"]
eventloop-winit = ["i-slint-backend-selector/eventloop-winit"]
eventloop-winit-x11 = ["i-slint-backend-selector/eventloop-winit-x11"]
eventloop-winit-wayland = ["i-slint-backend-selector/eventloop-winit-wayland"]
renderer-femtovg = ["i-slint-backend-selector/renderer-femtovg"]
rtti-qt = ["i-slint-backend-selector/rtti-qt"]
rtti-winit = ["i-slint-backend-selector/rtti-winit"]
default = ["backend-gl-all", "backend-qt"]
default = ["eventloop-winit", "renderer-femtovg", "backend-qt"]
[dependencies]
i-slint-backend-selector = { version = "=0.2.6", path="../../internal/backends/selector" }

View file

@ -59,10 +59,10 @@ not enabled by default but that is revelant for you, or you may want to disable
therefore reduce the size of the resulting library.
The CMake configure step offers CMake options for various feature that are all prefixed with `SLINT_FEATURE_`. For example
you can make a build that exclusively supports Wayland on Linux by enabling the `SLINT_FEATURE_BACKEND_GL_WAYLAND` feature and turning
off `SLINT_FEATURE_BACKEND_GL_ALL`. There are different ways of toggling CMake options. For example on the command line using the `-D` parameter:
you can make a build that exclusively supports Wayland on Linux by enabling the `SLINT_FEATURE_EVENTLOOP_WINIT_WAYLAND` feature and turning
off `SLINT_FEATURE_EVENTLOOP_WINIT_ALL`. There are different ways of toggling CMake options. For example on the command line using the `-D` parameter:
`cmake -DSLINT_FEATURE_BACKEND_GL_ALL=OFF -DSLINT_FEATURE_BACKEND_GL_WAYLAND=ON ...`
`cmake -DSLINT_FEATURE_EVENTLOOP_WINIT_ALL=OFF -DSLINT_FEATURE_EVENTLOOP_WINIT_WAYLAND=ON ...`
Alternatively, after the configure step you can use `cmake-gui` or `ccmake` on the build directory for a list of all features
and their description.