From 62c5f4b822d62d6be8905dafc84341370491cd1e Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sun, 6 Jul 2025 10:55:16 -0600 Subject: [PATCH] CMake: Remove unconditional Qt linkage from WebContent and WebWorker WebContent only needs it when using QtMultimedia for audio playback, and WebWorker never needs it. --- Libraries/LibWebView/CMakeLists.txt | 39 ++++++++++++++--------------- Services/WebContent/CMakeLists.txt | 21 +++++++--------- Services/WebContent/main.cpp | 9 +++---- Services/WebWorker/CMakeLists.txt | 8 +----- Services/WebWorker/main.cpp | 12 --------- UI/CMakeLists.txt | 2 +- 6 files changed, 33 insertions(+), 58 deletions(-) diff --git a/Libraries/LibWebView/CMakeLists.txt b/Libraries/LibWebView/CMakeLists.txt index 8743df7fbbd..e6382b86f75 100644 --- a/Libraries/LibWebView/CMakeLists.txt +++ b/Libraries/LibWebView/CMakeLists.txt @@ -36,20 +36,6 @@ if (APPLE) list(APPEND SOURCES MachPortServer.cpp) endif() -if (ENABLE_QT) - list(APPEND SOURCES - EventLoop/EventLoopImplementationQt.cpp - EventLoop/EventLoopImplementationQtEventTarget.cpp - ) - - set(CMAKE_AUTOMOC ON) - find_package(Qt6 REQUIRED COMPONENTS Core) -elseif (APPLE) - list(APPEND SOURCES - EventLoop/EventLoopImplementationMacOS.mm - ) -endif() - set(GENERATED_SOURCES ${CURRENT_LIB_GENERATED}) embed_as_string( @@ -93,16 +79,29 @@ endif() find_package(SQLite3 REQUIRED) target_link_libraries(LibWebView PRIVATE SQLite::SQLite3) -if (ENABLE_QT) - target_link_libraries(LibWebView PRIVATE Qt::Core) -elseif (APPLE) - target_link_libraries(LibWebView PRIVATE "-framework Cocoa") -endif() - if (HAS_FONTCONFIG) target_link_libraries(LibWebView PRIVATE Fontconfig::Fontconfig) endif() +add_library(LibWebViewPlatform INTERFACE) +if (ENABLE_QT) + add_library(LibWebViewQt STATIC + EventLoop/EventLoopImplementationQt.cpp + EventLoop/EventLoopImplementationQtEventTarget.cpp + ) + + set_target_properties(LibWebViewQt PROPERTIES AUTOMOC ON AUTORCC OFF AUTOUIC OFF) + find_package(Qt6 REQUIRED COMPONENTS Core) + target_link_libraries(LibWebViewQt PUBLIC Qt::Core) + target_link_libraries(LibWebViewPlatform INTERFACE LibWebViewQt) +elseif (APPLE) + add_library(LibWebViewCocoa STATIC + EventLoop/EventLoopImplementationMacOS.mm + ) + target_link_libraries(LibWebViewCocoa PUBLIC "-framework Cocoa") + target_link_libraries(LibWebViewPlatform INTERFACE LibWebViewCocoa) +endif() + if (ENABLE_INSTALL_HEADERS) foreach(header ${GENERATED_SOURCES}) get_filename_component(extension ${header} EXT) diff --git a/Services/WebContent/CMakeLists.txt b/Services/WebContent/CMakeLists.txt index 8fe08c0ec21..25567e6d46e 100644 --- a/Services/WebContent/CMakeLists.txt +++ b/Services/WebContent/CMakeLists.txt @@ -32,22 +32,19 @@ target_include_directories(webcontentservice PUBLIC $ #include -#if defined(HAVE_QT) +#if defined(HAVE_QT_MULTIMEDIA) # include # include - -# if defined(HAVE_QT_MULTIMEDIA) -# include -# endif +# include #endif #if defined(AK_OS_MACOS) @@ -76,7 +73,7 @@ ErrorOr serenity_main(Main::Arguments arguments) { AK::set_rich_debug_enabled(true); -#if defined(HAVE_QT) +#if defined(HAVE_QT_MULTIMEDIA) QCoreApplication app(arguments.argc, arguments.argv); Core::EventLoopManager::install(*new WebView::EventLoopManagerQt); diff --git a/Services/WebWorker/CMakeLists.txt b/Services/WebWorker/CMakeLists.txt index c8473be708f..54feef0df3f 100644 --- a/Services/WebWorker/CMakeLists.txt +++ b/Services/WebWorker/CMakeLists.txt @@ -16,13 +16,7 @@ target_include_directories(webworkerservice PRIVATE ${LADYBIRD_SOURCE_DIR}/Servi target_link_libraries(webworkerservice PUBLIC LibCore LibFileSystem LibGfx LibIPC LibJS LibRequests LibWeb LibWebView LibUnicode LibImageDecoderClient LibMain LibURL LibGC) target_link_libraries(webworkerservice PRIVATE OpenSSL::Crypto OpenSSL::SSL) -if (ENABLE_QT) - qt_add_executable(WebWorker main.cpp) - target_link_libraries(WebWorker PRIVATE webworkerservice LibWebSocket) - target_compile_definitions(WebWorker PRIVATE HAVE_QT=1) -else() - add_executable(WebWorker main.cpp) -endif() +add_executable(WebWorker main.cpp) target_include_directories(WebWorker PRIVATE ${LADYBIRD_SOURCE_DIR}) target_link_libraries(WebWorker PRIVATE webworkerservice) diff --git a/Services/WebWorker/main.cpp b/Services/WebWorker/main.cpp index 871adb4ff23..150c0c7a9a3 100644 --- a/Services/WebWorker/main.cpp +++ b/Services/WebWorker/main.cpp @@ -6,9 +6,7 @@ #include #include -#include #include -#include #include #include #include @@ -18,18 +16,12 @@ #include #include #include -#include #include #include #include #include #include -#if defined(HAVE_QT) -# include -# include -#endif - static ErrorOr initialize_image_decoder(int image_decoder_socket); static ErrorOr initialize_resource_loader(GC::Heap&, int request_server_socket); @@ -71,10 +63,6 @@ ErrorOr serenity_main(Main::Arguments arguments) auto worker_type = TRY(agent_type_from_string(worker_type_string)); -#if defined(HAVE_QT) - QCoreApplication app(arguments.argc, arguments.argv); - Core::EventLoopManager::install(*new WebView::EventLoopManagerQt); -#endif Core::EventLoop event_loop; WebView::platform_init(); diff --git a/UI/CMakeLists.txt b/UI/CMakeLists.txt index 506af35bd9f..63eda386289 100644 --- a/UI/CMakeLists.txt +++ b/UI/CMakeLists.txt @@ -68,7 +68,7 @@ else() set(LADYBIRD_TARGET ladybird PRIVATE) endif() -set(LADYBIRD_LIBS AK LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibWeb LibWebView LibRequests LibURL) +set(LADYBIRD_LIBS AK LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibWeb LibWebView LibWebViewPlatform LibRequests LibURL) target_link_libraries(${LADYBIRD_TARGET} PRIVATE ${LADYBIRD_LIBS}) target_link_libraries(${LADYBIRD_TARGET} PRIVATE OpenSSL::Crypto OpenSSL::SSL)