CMake: Use a helper file to find GL and EGL in a platform agnostic way

Also add a flag to turn off accelerated graphics entirely.
This commit is contained in:
Andrew Kaster 2023-10-29 16:31:36 -06:00 committed by Andrew Kaster
parent bec1c1fff7
commit 49d21619d4
Notes: sideshowbarker 2024-07-17 23:07:41 +09:00
5 changed files with 23 additions and 7 deletions

View file

@ -70,6 +70,7 @@ There are some optional features that can be enabled during compilation that are
- `BUILD_EVERYTHING`: builds all optional components, overrides other `BUILD_<component>` flags when enabled - `BUILD_EVERYTHING`: builds all optional components, overrides other `BUILD_<component>` flags when enabled
- `SERENITY_CACHE_DIR`: sets the location of a shared cache of downloaded files. Should not need to be set unless managing a distribution package. - `SERENITY_CACHE_DIR`: sets the location of a shared cache of downloaded files. Should not need to be set unless managing a distribution package.
- `ENABLE_NETWORK_DOWNLOADS`: allows downloading files from the internet during the build. Default on, turning off enables offline builds. For offline builds, the structure of the SERENITY_CACHE_DIR must be set up the way that the build expects. - `ENABLE_NETWORK_DOWNLOADS`: allows downloading files from the internet during the build. Default on, turning off enables offline builds. For offline builds, the structure of the SERENITY_CACHE_DIR must be set up the way that the build expects.
- `ENABLE_ACCELERATED_GRAPHICS`: builds features that use accelerated graphics APIs to speed up painting and drawing using native graphics libraries.
Many parts of the SerenityOS codebase have debug functionality, mostly consisting of additional messages printed to the debug console. This is done via the `<component_name>_DEBUG` macros, which can be enabled individually at build time. They are listed in [this file](../Meta/CMake/all_the_debug_macros.cmake). Many parts of the SerenityOS codebase have debug functionality, mostly consisting of additional messages printed to the debug console. This is done via the `<component_name>_DEBUG` macros, which can be enabled individually at build time. They are listed in [this file](../Meta/CMake/all_the_debug_macros.cmake).

View file

@ -0,0 +1,14 @@
if (NOT ENABLE_ACCELERATED_GRAPHICS OR EMSCRIPTEN)
# FIXME: Enable GL emulation in emscripten: https://emscripten.org/docs/porting/multimedia_and_graphics/OpenGL-support.html
set(HAS_ACCELERATED_GRAPHICS OFF CACHE BOOL "" FORCE)
return()
endif()
find_package(OpenGL COMPONENTS OpenGL EGL)
if (OPENGL_FOUND)
set(HAS_ACCELERATED_GRAPHICS ON CACHE BOOL "" FORCE)
set(ACCEL_GFX_LIBS OpenGL::OpenGL OpenGL::EGL CACHE STRING "" FORCE)
else()
set(HAS_ACCELERATED_GRAPHICS OFF CACHE BOOL "" FORCE)
endif()

View file

@ -21,6 +21,7 @@ serenity_option(ENABLE_PUBLIC_SUFFIX_DOWNLOAD ON CACHE BOOL "Enable download of
serenity_option(INCLUDE_WASM_SPEC_TESTS OFF CACHE BOOL "Download and include the WebAssembly spec testsuite") serenity_option(INCLUDE_WASM_SPEC_TESTS OFF CACHE BOOL "Download and include the WebAssembly spec testsuite")
serenity_option(INCLUDE_FLAC_SPEC_TESTS OFF CACHE BOOL "Download and include the FLAC spec testsuite") serenity_option(INCLUDE_FLAC_SPEC_TESTS OFF CACHE BOOL "Download and include the FLAC spec testsuite")
serenity_option(ENABLE_CACERT_DOWNLOAD ON CACHE BOOL "Enable download of cacert.pem at build time") serenity_option(ENABLE_CACERT_DOWNLOAD ON CACHE BOOL "Enable download of cacert.pem at build time")
serenity_option(ENABLE_ACCELERATED_GRAPHICS ON CACHE BOOL "Enable use of accelerated graphics APIs")
serenity_option(HACKSTUDIO_BUILD OFF CACHE BOOL "Automatically enabled when building from HackStudio") serenity_option(HACKSTUDIO_BUILD OFF CACHE BOOL "Automatically enabled when building from HackStudio")

View file

@ -1,4 +1,6 @@
if (LINUX) include(accelerated_graphics)
if (HAS_ACCELERATED_GRAPHICS)
set(SOURCES set(SOURCES
Canvas.cpp Canvas.cpp
Context.cpp Context.cpp
@ -6,5 +8,5 @@ if (LINUX)
) )
serenity_lib(LibAccelGfx accelgfx) serenity_lib(LibAccelGfx accelgfx)
target_link_libraries(LibAccelGfx PRIVATE LibGfx GL EGL) target_link_libraries(LibAccelGfx PRIVATE LibGfx ${ACCEL_GFX_LIBS})
endif() endif()

View file

@ -1,4 +1,5 @@
include(libweb_generators) include(libweb_generators)
include(accelerated_graphics)
set(SOURCES set(SOURCES
ARIA/AriaData.cpp ARIA/AriaData.cpp
@ -626,10 +627,6 @@ set(SOURCES
XML/XMLDocumentBuilder.cpp XML/XMLDocumentBuilder.cpp
) )
if (LINUX)
list(APPEND SOURCES Painting/PaintingCommandExecutorGPU.cpp)
endif()
invoke_generator( invoke_generator(
"AriaRoles.cpp" "AriaRoles.cpp"
Lagom::GenerateAriaRoles Lagom::GenerateAriaRoles
@ -663,7 +660,8 @@ serenity_lib(LibWeb web)
target_link_libraries(LibWeb PRIVATE LibCore LibCrypto LibJS LibMarkdown LibHTTP LibGemini LibGL LibGUI LibGfx LibIPC LibLocale LibRegex LibSoftGPU LibSyntax LibTextCodec LibUnicode LibAudio LibVideo LibWasm LibXML LibIDL) target_link_libraries(LibWeb PRIVATE LibCore LibCrypto LibJS LibMarkdown LibHTTP LibGemini LibGL LibGUI LibGfx LibIPC LibLocale LibRegex LibSoftGPU LibSyntax LibTextCodec LibUnicode LibAudio LibVideo LibWasm LibXML LibIDL)
link_with_locale_data(LibWeb) link_with_locale_data(LibWeb)
if (LINUX) if (HAS_ACCELERATED_GRAPHICS)
target_sources(LibWeb PRIVATE Painting/PaintingCommandExecutorGPU.cpp)
target_link_libraries(LibWeb PRIVATE LibAccelGfx) target_link_libraries(LibWeb PRIVATE LibAccelGfx)
endif() endif()