Meta: Refactor the way the GUI framework is picked

This is largely based of off the work done by Andrew Kaster in #5918.
Having this toggle makes much more sense, especially if there will be
more UIs in the future.

Co-authored-by: Andrew Kaster <andrew@ladybird.org>
This commit is contained in:
Undefine
2026-03-27 21:03:22 +01:00
committed by Andrew Kaster
parent 4eda70a4f1
commit fbbcc73fea
Notes: github-actions[bot] 2026-03-29 20:01:42 +00:00
8 changed files with 23 additions and 28 deletions

View File

@@ -173,7 +173,7 @@ jobs:
if: ${{ inputs.os_name == 'macOS' && inputs.build_preset == 'Sanitizer' }}
working-directory: ${{ github.workspace }}
run: |
cmake --preset ${{ inputs.build_preset }} -B Build -DENABLE_QT=ON
cmake --preset ${{ inputs.build_preset }} -B Build -DLADYBIRD_GUI_FRAMEWORK=Qt
cmake --build Build
- name: Save Caches

View File

@@ -53,11 +53,6 @@ endif()
add_cxx_compile_options(-Wno-expansion-to-defined)
add_cxx_compile_options(-Wno-user-defined-literals)
if (ANDROID AND ENABLE_QT)
message(STATUS "Disabling Qt for Android")
set(ENABLE_QT OFF CACHE BOOL "" FORCE)
endif()
# We need to find OpenSSL in order to link it explicitly with all targets.
find_package(OpenSSL REQUIRED)

View File

@@ -254,16 +254,14 @@ Ladybird will be built with one of the following browser frontends, depending on
* [Qt](https://doc.qt.io/qt-6/) - The UI used on all other platforms.
* [Android UI](https://developer.android.com/develop/ui) - The native UI on Android.
The Qt UI is available on platforms where it is not the default as well (except on Android). To build the
Qt UI, install the Qt dependencies for your platform, and enable the Qt UI via CMake:
The Qt UI is available on platforms where it is not the default as well (except on Android).
You can pick the UI using the `LADYBIRD_GUI_FRAMEWORK` option, for example to enable the Qt UI:
```bash
# From /path/to/ladybird
cmake --preset default -DENABLE_QT=ON
cmake --preset default -DLADYBIRD_GUI_FRAMEWORK=Qt
```
To re-disable the Qt UI, run the above command with `-DENABLE_QT=OFF`.
### Build error messages you may encounter
The section lists out some particular error messages you may run into, and explains how to deal with them.

View File

@@ -0,0 +1,17 @@
if (ANDROID OR VCPKG_TARGET_ANDROID)
set(_possible_guis "Android")
set(_default_gui "Android")
elseif (APPLE)
set(_possible_guis "AppKit" "Qt")
set(_default_gui "AppKit")
else()
set(_possible_guis "Qt")
set(_default_gui "Qt")
endif()
# Note: ladybird_option() doesn't play nicely with this variable, so we use set() directly.
set(LADYBIRD_GUI_FRAMEWORK ${_default_gui} CACHE STRING "The GUI framework to use for the ladybird application. Possible values: ${_possible_guis}")
if (NOT "${LADYBIRD_GUI_FRAMEWORK}" IN_LIST _possible_guis)
message(FATAL_ERROR "Invalid value for LADYBIRD_GUI_FRAMEWORK: ${LADYBIRD_GUI_FRAMEWORK}. Possible values: ${_possible_guis}")
endif()

View File

@@ -24,9 +24,3 @@ ladybird_option(LAGOM_USE_LINKER "" CACHE STRING "The linker to use (e.g. lld, m
ladybird_option(LAGOM_LINK_POOL_SIZE "" CACHE STRING "The maximum number of parallel jobs to use for linking")
ladybird_option(ENABLE_LTO_FOR_RELEASE ${RELEASE_LTO_DEFAULT} CACHE BOOL "Enable link-time optimization for release builds")
ladybird_option(ENABLE_LAGOM_COVERAGE_COLLECTION OFF CACHE STRING "Enable code coverage instrumentation for lagom binaries in clang")
if (ANDROID OR APPLE)
ladybird_option(ENABLE_QT OFF CACHE BOOL "Build ladybird application using Qt GUI")
else()
ladybird_option(ENABLE_QT ON CACHE BOOL "Build ladybird application using Qt GUI")
endif()

View File

@@ -91,7 +91,6 @@
"cacheVariables": {
"BUILD_SHARED_LIBS": "OFF",
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"ENABLE_QT": "OFF",
"VCPKG_OVERLAY_TRIPLETS": "$env{LADYBIRD_SOURCE_DIR}/Meta/CMake/vcpkg/distribution-triplets",
"ENABLE_FUZZERS_LIBFUZZER": "ON",
"ENABLE_ADDRESS_SANITIZER": "ON"

View File

@@ -50,6 +50,7 @@ endif()
include(check_for_dependencies)
include(use_linker)
include(gui_framework)
include(lagom_options NO_POLICY_SCOPE)
if(ENABLE_ALL_THE_DEBUG_MACROS)

View File

@@ -47,16 +47,7 @@ function(create_ladybird_bundle target_name)
endfunction()
# Select UI Framework
if (ENABLE_QT)
add_subdirectory(Qt)
elseif (APPLE)
add_subdirectory(AppKit)
elseif(ANDROID)
add_subdirectory(Android)
else()
# TODO: Check for other GUI frameworks here when we move them in-tree
return()
endif()
add_subdirectory(${LADYBIRD_GUI_FRAMEWORK})
if (NOT TARGET ladybird)
message(FATAL_ERROR "UI Framework selection must declare a ladybird target")