diff --git a/.github/workflows/lagom-template.yml b/.github/workflows/lagom-template.yml index deeff1fe4e2..f109e067a2f 100644 --- a/.github/workflows/lagom-template.yml +++ b/.github/workflows/lagom-template.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 32920e9905e..9f552751aed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/Documentation/BuildInstructionsLadybird.md b/Documentation/BuildInstructionsLadybird.md index 223b4f992e5..c2fec223d5d 100644 --- a/Documentation/BuildInstructionsLadybird.md +++ b/Documentation/BuildInstructionsLadybird.md @@ -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. diff --git a/Meta/CMake/gui_framework.cmake b/Meta/CMake/gui_framework.cmake new file mode 100644 index 00000000000..ce2c46f827f --- /dev/null +++ b/Meta/CMake/gui_framework.cmake @@ -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() diff --git a/Meta/CMake/lagom_options.cmake b/Meta/CMake/lagom_options.cmake index cd4a0e15bf5..25112f62d42 100644 --- a/Meta/CMake/lagom_options.cmake +++ b/Meta/CMake/lagom_options.cmake @@ -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() diff --git a/Meta/CMake/presets/CMakeBasePresets.json b/Meta/CMake/presets/CMakeBasePresets.json index f3885e45324..616c275c708 100644 --- a/Meta/CMake/presets/CMakeBasePresets.json +++ b/Meta/CMake/presets/CMakeBasePresets.json @@ -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" diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index 0c2530ca030..b88deb08326 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -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) diff --git a/UI/CMakeLists.txt b/UI/CMakeLists.txt index ad7a0b3a6e9..16a0d8310f7 100644 --- a/UI/CMakeLists.txt +++ b/UI/CMakeLists.txt @@ -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")