mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
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:
Notes:
github-actions[bot]
2026-03-29 20:01:42 +00:00
Author: https://github.com/cqundefine Commit: https://github.com/LadybirdBrowser/ladybird/commit/fbbcc73feaa Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8650 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/spholz
2
.github/workflows/lagom-template.yml
vendored
2
.github/workflows/lagom-template.yml
vendored
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
17
Meta/CMake/gui_framework.cmake
Normal file
17
Meta/CMake/gui_framework.cmake
Normal 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()
|
||||
@@ -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()
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user