CMake: Move ladybird target creation to UI-specific CMakeLists

This commit is contained in:
Andrew Kaster 2024-06-04 14:00:26 -06:00 committed by Tim Flynn
parent f0aa378dab
commit 47d6a263d8
Notes: sideshowbarker 2024-07-17 04:32:07 +09:00
4 changed files with 147 additions and 139 deletions

View file

@ -0,0 +1,13 @@
add_library(ladybird SHARED
${LADYBIRD_SOURCES}
src/main/cpp/LadybirdActivity.cpp
src/main/cpp/WebViewImplementationNative.cpp
src/main/cpp/WebViewImplementationNativeJNI.cpp
src/main/cpp/ALooperEventLoopImplementation.cpp
src/main/cpp/TimerExecutorService.cpp
src/main/cpp/JNIHelpers.cpp
)
target_link_libraries(ladybird PRIVATE LibArchive jnigraphics android)
include(Ladybird/cmake/AndroidExtras.cmake)
create_ladybird_bundle(ladybird)

View file

@ -0,0 +1,27 @@
add_executable(ladybird MACOSX_BUNDLE
${LADYBIRD_SOURCES}
main.mm
Application/Application.mm
Application/ApplicationBridge.cpp
Application/ApplicationDelegate.mm
Application/EventLoopImplementation.mm
UI/Event.mm
UI/Inspector.mm
UI/InspectorController.mm
UI/LadybirdWebView.mm
UI/LadybirdWebViewBridge.cpp
UI/Palette.mm
UI/SearchPanel.mm
UI/Tab.mm
UI/TabController.mm
UI/TaskManager.mm
UI/TaskManagerController.mm
Utilities/Conversions.mm
)
target_include_directories(ladybird PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(ladybird PRIVATE "-framework Cocoa -framework UniformTypeIdentifiers" LibUnicode)
target_compile_options(ladybird PRIVATE
-fobjc-arc
-Wno-deprecated-anon-enum-enum-conversion # Required for CGImageCreate
)
create_ladybird_bundle(ladybird)

View file

@ -1,7 +1,7 @@
set(SOURCES
HelperProcess.cpp
Utilities.cpp
set(LADYBIRD_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/HelperProcess.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Utilities.cpp
)
set(LADYBIRD_HEADERS
HelperProcess.h
@ -9,141 +9,6 @@ set(LADYBIRD_HEADERS
Utilities.h
)
if (ENABLE_QT)
qt_add_executable(ladybird ${SOURCES})
target_sources(ladybird PRIVATE
Qt/Application.cpp
Qt/AutoComplete.cpp
Qt/BrowserWindow.cpp
Qt/EventLoopImplementationQt.cpp
Qt/EventLoopImplementationQtEventTarget.cpp
Qt/FindInPageWidget.cpp
Qt/Icon.cpp
Qt/InspectorWidget.cpp
Qt/LocationEdit.cpp
Qt/Settings.cpp
Qt/SettingsDialog.cpp
Qt/Tab.cpp
Qt/TabBar.cpp
Qt/TaskManagerWindow.cpp
Qt/TVGIconEngine.cpp
Qt/StringUtils.cpp
Qt/WebContentView.cpp
Qt/ladybird.qrc
Qt/main.cpp
)
target_link_libraries(ladybird PRIVATE Qt::Core Qt::Gui Qt::Network Qt::Widgets)
elseif (APPLE)
add_executable(ladybird MACOSX_BUNDLE
${SOURCES}
AppKit/main.mm
AppKit/Application/Application.mm
AppKit/Application/ApplicationBridge.cpp
AppKit/Application/ApplicationDelegate.mm
AppKit/Application/EventLoopImplementation.mm
AppKit/UI/Event.mm
AppKit/UI/Inspector.mm
AppKit/UI/InspectorController.mm
AppKit/UI/LadybirdWebView.mm
AppKit/UI/LadybirdWebViewBridge.cpp
AppKit/UI/Palette.mm
AppKit/UI/SearchPanel.mm
AppKit/UI/Tab.mm
AppKit/UI/TabController.mm
AppKit/UI/TaskManager.mm
AppKit/UI/TaskManagerController.mm
AppKit/Utilities/Conversions.mm
)
target_include_directories(ladybird PRIVATE AppKit)
target_link_libraries(ladybird PRIVATE "-framework Cocoa -framework UniformTypeIdentifiers" LibUnicode)
target_compile_options(ladybird PRIVATE
-fobjc-arc
-Wno-deprecated-anon-enum-enum-conversion # Required for CGImageCreate
)
elseif(ANDROID)
add_library(ladybird SHARED
${SOURCES}
Android/src/main/cpp/LadybirdActivity.cpp
Android/src/main/cpp/WebViewImplementationNative.cpp
Android/src/main/cpp/WebViewImplementationNativeJNI.cpp
Android/src/main/cpp/ALooperEventLoopImplementation.cpp
Android/src/main/cpp/TimerExecutorService.cpp
Android/src/main/cpp/JNIHelpers.cpp
)
target_link_libraries(ladybird PRIVATE LibArchive jnigraphics android)
else()
# TODO: Check for other GUI frameworks here when we move them in-tree
# For now, we can export a static library of common files for chromes to link to
add_library(ladybird STATIC ${SOURCES})
endif()
if (APPLE)
target_sources(ladybird PRIVATE MachPortServer.cpp)
target_link_libraries(ladybird PRIVATE LibThreading)
endif()
target_sources(ladybird PUBLIC FILE_SET ladybird TYPE HEADERS
BASE_DIRS ${LADYBIRD_SOURCE_DIR}
FILES ${LADYBIRD_HEADERS}
)
target_link_libraries(ladybird PRIVATE AK LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibSQL LibWeb LibWebView LibProtocol LibURL)
target_include_directories(ladybird PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(ladybird PRIVATE ${LADYBIRD_SOURCE_DIR}/Userland/)
target_include_directories(ladybird PRIVATE ${LADYBIRD_SOURCE_DIR}/Userland/Services/)
function(set_helper_process_properties)
set(targets ${ARGV})
if (APPLE)
# Store helper processes in the same bundle directory as the main application
set_target_properties(${targets} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$<TARGET_FILE_DIR:ladybird>")
else()
set_target_properties(${targets} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${IN_BUILD_PREFIX}${CMAKE_INSTALL_LIBEXECDIR}")
if (NOT CMAKE_INSTALL_LIBEXECDIR STREQUAL "libexec")
set_source_files_properties(Utilities.cpp PROPERTIES COMPILE_DEFINITIONS LADYBIRD_LIBEXECDIR="${CMAKE_INSTALL_LIBEXECDIR}")
set_source_files_properties(Utilities.cpp TARGET_DIRECTORY ${targets} PROPERTIES COMPILE_DEFINITIONS LADYBIRD_LIBEXECDIR="${CMAKE_INSTALL_LIBEXECDIR}")
endif()
endif()
endfunction()
add_executable(headless-browser
${LADYBIRD_SOURCE_DIR}/Userland/Utilities/headless-browser.cpp
HelperProcess.cpp
Utilities.cpp)
target_include_directories(headless-browser PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(headless-browser PRIVATE ${LADYBIRD_SOURCE_DIR}/Userland/)
target_link_libraries(headless-browser PRIVATE AK LibCore LibWeb LibWebView LibWebSocket LibCrypto LibFileSystem LibHTTP LibImageDecoderClient LibJS LibGfx LibMain LibSQL LibTLS LibIPC LibDiff LibProtocol LibURL)
if (ANDROID)
include(cmake/AndroidExtras.cmake)
endif()
add_custom_target(run
COMMAND "${CMAKE_COMMAND}" -E env "LADYBIRD_SOURCE_DIR=${LADYBIRD_SOURCE_DIR}" "$<TARGET_FILE:ladybird>" $ENV{LAGOM_ARGS}
USES_TERMINAL
VERBATIM
)
add_custom_target(debug-ladybird
COMMAND "${CMAKE_COMMAND}" -E env "LADYBIRD_SOURCE_DIR=${LADYBIRD_SOURCE_DIR}" gdb -ex "set follow-fork-mode child" "$<TARGET_FILE:ladybird>"
USES_TERMINAL
)
add_subdirectory(ImageDecoder)
add_subdirectory(RequestServer)
add_subdirectory(SQLServer)
add_subdirectory(WebContent)
add_subdirectory(WebDriver)
add_subdirectory(WebWorker)
set(ladybird_helper_processes ImageDecoder RequestServer SQLServer WebContent WebWorker)
add_dependencies(ladybird ${ladybird_helper_processes})
add_dependencies(headless-browser ${ladybird_helper_processes})
add_dependencies(WebDriver ladybird headless-browser)
function(create_ladybird_bundle target_name)
set_target_properties(${target_name} PROPERTIES
OUTPUT_NAME "Ladybird"
@ -171,7 +36,86 @@ function(create_ladybird_bundle target_name)
endif()
endfunction()
create_ladybird_bundle(ladybird)
# 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
# For now, we can export a static library of common files for chromes to link to
add_library(ladybird STATIC ${LADYBIRD_SOURCES})
endif()
if (NOT TARGET ladybird)
message(FATAL_ERROR "UI Framework selection must declare a ladybird target")
endif()
if (APPLE)
target_sources(ladybird PRIVATE MachPortServer.cpp)
target_link_libraries(ladybird PRIVATE LibThreading)
endif()
target_sources(ladybird PUBLIC FILE_SET ladybird TYPE HEADERS
BASE_DIRS ${LADYBIRD_SOURCE_DIR}
FILES ${LADYBIRD_HEADERS}
)
target_link_libraries(ladybird PRIVATE AK LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibSQL LibWeb LibWebView LibProtocol LibURL)
target_include_directories(ladybird PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(ladybird PRIVATE ${LADYBIRD_SOURCE_DIR}/Userland/)
target_include_directories(ladybird PRIVATE ${LADYBIRD_SOURCE_DIR}/Userland/Services/)
function(set_helper_process_properties)
set(targets ${ARGV})
if (APPLE)
# Store helper processes in the same bundle directory as the main application
set_target_properties(${targets} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$<TARGET_FILE_DIR:ladybird>")
else()
set_target_properties(${targets} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${IN_BUILD_PREFIX}${CMAKE_INSTALL_LIBEXECDIR}")
if (NOT CMAKE_INSTALL_LIBEXECDIR STREQUAL "libexec")
set_source_files_properties(Utilities.cpp PROPERTIES COMPILE_DEFINITIONS LADYBIRD_LIBEXECDIR="${CMAKE_INSTALL_LIBEXECDIR}")
set_source_files_properties(Utilities.cpp TARGET_DIRECTORY ladybird PROPERTIES COMPILE_DEFINITIONS LADYBIRD_LIBEXECDIR="${CMAKE_INSTALL_LIBEXECDIR}")
set_source_files_properties(Utilities.cpp TARGET_DIRECTORY ${targets} PROPERTIES COMPILE_DEFINITIONS LADYBIRD_LIBEXECDIR="${CMAKE_INSTALL_LIBEXECDIR}")
endif()
endif()
endfunction()
add_executable(headless-browser
${LADYBIRD_SOURCE_DIR}/Userland/Utilities/headless-browser.cpp
${LADYBIRD_SOURCES})
target_include_directories(headless-browser PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(headless-browser PRIVATE ${LADYBIRD_SOURCE_DIR}/Userland/)
target_link_libraries(headless-browser PRIVATE AK LibCore LibWeb LibWebView LibWebSocket LibCrypto LibFileSystem LibHTTP LibImageDecoderClient LibJS LibGfx LibMain LibSQL LibTLS LibIPC LibDiff LibProtocol LibURL)
add_custom_target(run
COMMAND "${CMAKE_COMMAND}" -E env "LADYBIRD_SOURCE_DIR=${LADYBIRD_SOURCE_DIR}" "$<TARGET_FILE:ladybird>" $ENV{LAGOM_ARGS}
USES_TERMINAL
VERBATIM
)
add_custom_target(debug-ladybird
COMMAND "${CMAKE_COMMAND}" -E env "LADYBIRD_SOURCE_DIR=${LADYBIRD_SOURCE_DIR}" gdb -ex "set follow-fork-mode child" "$<TARGET_FILE:ladybird>"
USES_TERMINAL
)
add_subdirectory(ImageDecoder)
add_subdirectory(RequestServer)
add_subdirectory(SQLServer)
add_subdirectory(WebContent)
add_subdirectory(WebDriver)
add_subdirectory(WebWorker)
set(ladybird_helper_processes ImageDecoder RequestServer SQLServer WebContent WebWorker)
add_dependencies(ladybird ${ladybird_helper_processes})
add_dependencies(headless-browser ${ladybird_helper_processes})
add_dependencies(WebDriver ladybird headless-browser)
set_helper_process_properties(${ladybird_helper_processes})
if (APPLE)
set_helper_process_properties(headless-browser WebDriver)

View file

@ -0,0 +1,24 @@
qt_add_executable(ladybird ${LADYBIRD_SOURCES})
target_sources(ladybird PRIVATE
Application.cpp
AutoComplete.cpp
BrowserWindow.cpp
EventLoopImplementationQt.cpp
EventLoopImplementationQtEventTarget.cpp
FindInPageWidget.cpp
Icon.cpp
InspectorWidget.cpp
LocationEdit.cpp
Settings.cpp
SettingsDialog.cpp
Tab.cpp
TabBar.cpp
TaskManagerWindow.cpp
TVGIconEngine.cpp
StringUtils.cpp
WebContentView.cpp
ladybird.qrc
main.cpp
)
target_link_libraries(ladybird PRIVATE Qt::Core Qt::Gui Qt::Network Qt::Widgets)
create_ladybird_bundle(ladybird)