2023-08-08 07:14:22 +03:00
|
|
|
cmake_minimum_required(VERSION 3.23)
|
2022-07-04 14:45:18 +03:00
|
|
|
|
|
|
|
project(ladybird
|
|
|
|
VERSION 0.0.1
|
|
|
|
LANGUAGES CXX
|
|
|
|
DESCRIPTION "Ladybird Web Browser"
|
|
|
|
)
|
|
|
|
|
2022-09-16 13:08:24 +03:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2022-07-11 10:14:53 +03:00
|
|
|
if (ANDROID)
|
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
|
|
|
endif()
|
|
|
|
|
2022-07-04 14:45:18 +03:00
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
|
|
|
set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
|
|
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
|
|
|
# See slide 100 of the following ppt :^)
|
|
|
|
# https://crascit.com/wp-content/uploads/2019/09/Deep-CMake-For-Library-Authors-Craig-Scott-CppCon-2019.pdf
|
|
|
|
if (NOT APPLE)
|
2022-09-16 13:08:24 +03:00
|
|
|
set(CMAKE_INSTALL_RPATH $ORIGIN;$ORIGIN/../${CMAKE_INSTALL_LIBDIR})
|
2022-07-04 14:45:18 +03:00
|
|
|
endif()
|
|
|
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
|
2022-10-04 03:30:29 +03:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2022-10-19 22:12:29 +03:00
|
|
|
if (ENABLE_ADDRESS_SANITIZER)
|
|
|
|
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
|
|
|
|
add_link_options(-fsanitize=address)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (ENABLE_MEMORY_SANITIZER)
|
|
|
|
add_compile_options(-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer)
|
|
|
|
add_link_options(-fsanitize=memory -fsanitize-memory-track-origins)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (ENABLE_UNDEFINED_SANITIZER)
|
|
|
|
add_compile_options(-fsanitize=undefined -fno-omit-frame-pointer)
|
2023-08-12 16:39:22 +03:00
|
|
|
if (UNDEFINED_BEHAVIOR_IS_FATAL)
|
|
|
|
add_compile_options(-fno-sanitize-recover=undefined)
|
|
|
|
endif()
|
2023-12-20 01:41:57 +03:00
|
|
|
if (APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang$" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "17")
|
|
|
|
add_compile_options(-fno-sanitize=function)
|
|
|
|
endif()
|
2022-10-19 22:12:29 +03:00
|
|
|
add_link_options(-fsanitize=undefined)
|
|
|
|
endif()
|
|
|
|
|
2023-08-27 21:53:47 +03:00
|
|
|
if (HAIKU)
|
|
|
|
# Haiku needs some extra compile definitions to make important stuff in its headers available.
|
|
|
|
add_compile_definitions(_DEFAULT_SOURCE)
|
|
|
|
add_compile_definitions(_GNU_SOURCE)
|
|
|
|
add_compile_definitions(__USE_GNU)
|
|
|
|
endif()
|
|
|
|
|
2022-07-04 14:45:18 +03:00
|
|
|
# Lagom
|
2022-12-23 21:36:02 +03:00
|
|
|
# FIXME: PROJECT_IS_TOP_LEVEL with CMake 3.21+
|
|
|
|
set(LADYBIRD_IS_TOP_LEVEL FALSE)
|
|
|
|
set(LADYBIRD_CUSTOM_TARGET_SUFFIX "-ladybird")
|
|
|
|
if ("${CMAKE_BINARY_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
|
|
|
|
set(LADYBIRD_IS_TOP_LEVEL TRUE)
|
|
|
|
set(LADYBIRD_CUSTOM_TARGET_SUFFIX "")
|
|
|
|
endif()
|
2022-07-04 14:45:18 +03:00
|
|
|
|
2022-12-23 21:36:02 +03:00
|
|
|
if (LADYBIRD_IS_TOP_LEVEL)
|
|
|
|
get_filename_component(
|
|
|
|
SERENITY_SOURCE_DIR "${ladybird_SOURCE_DIR}/.."
|
|
|
|
ABSOLUTE
|
|
|
|
)
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${SERENITY_SOURCE_DIR}/Meta/CMake")
|
|
|
|
include(cmake/EnableLagom.cmake)
|
2023-09-05 21:57:20 +03:00
|
|
|
include(use_linker)
|
2023-08-14 04:49:21 +03:00
|
|
|
include(lagom_compile_options)
|
|
|
|
include(lagom_install_options)
|
2022-12-23 21:36:02 +03:00
|
|
|
else()
|
|
|
|
# FIXME: Use SERENITY_SOURCE_DIR in Lagom/CMakeLists.txt
|
|
|
|
set(SERENITY_SOURCE_DIR "${SERENITY_PROJECT_ROOT}")
|
|
|
|
endif()
|
2022-07-11 10:14:53 +03:00
|
|
|
|
2023-04-24 14:16:37 +03:00
|
|
|
add_compile_options(-DAK_DONT_REPLACE_STD)
|
2022-07-04 14:45:18 +03:00
|
|
|
add_compile_options(-Wno-expansion-to-defined)
|
2022-07-13 22:33:22 +03:00
|
|
|
add_compile_options(-Wno-user-defined-literals)
|
2022-07-04 14:45:18 +03:00
|
|
|
|
2023-10-24 17:35:33 +03:00
|
|
|
if (ANDROID OR APPLE)
|
|
|
|
serenity_option(ENABLE_QT OFF CACHE BOOL "Build ladybird application using Qt GUI")
|
|
|
|
else()
|
|
|
|
serenity_option(ENABLE_QT ON CACHE BOOL "Build ladybird application using Qt GUI")
|
|
|
|
endif()
|
|
|
|
|
2023-09-02 18:30:21 +03:00
|
|
|
if (ANDROID AND ENABLE_QT)
|
|
|
|
message(STATUS "Disabling Qt for Android")
|
|
|
|
set(ENABLE_QT OFF CACHE BOOL "" FORCE)
|
|
|
|
endif()
|
2023-08-08 04:42:06 +03:00
|
|
|
|
|
|
|
if (ENABLE_QT)
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
2023-11-02 20:53:38 +03:00
|
|
|
find_package(Qt6 REQUIRED COMPONENTS Core Widgets Network)
|
2023-08-08 04:42:06 +03:00
|
|
|
endif()
|
2022-07-04 14:45:18 +03:00
|
|
|
|
|
|
|
set(SOURCES
|
2023-02-02 13:00:30 +03:00
|
|
|
HelperProcess.cpp
|
2022-09-19 12:06:23 +03:00
|
|
|
Utilities.cpp
|
2022-07-04 14:45:18 +03:00
|
|
|
)
|
2023-08-08 07:14:22 +03:00
|
|
|
set(LADYBIRD_HEADERS
|
|
|
|
HelperProcess.h
|
|
|
|
Types.h
|
|
|
|
Utilities.h
|
|
|
|
)
|
2022-07-04 14:45:18 +03:00
|
|
|
|
2023-08-08 04:42:06 +03:00
|
|
|
if (ENABLE_QT)
|
|
|
|
qt_add_executable(ladybird ${SOURCES})
|
|
|
|
target_sources(ladybird PRIVATE
|
2023-05-31 04:44:16 +03:00
|
|
|
Qt/AutoComplete.cpp
|
2023-08-08 04:42:06 +03:00
|
|
|
Qt/BrowserWindow.cpp
|
|
|
|
Qt/EventLoopImplementationQt.cpp
|
|
|
|
Qt/EventLoopImplementationQtEventTarget.cpp
|
2023-11-05 15:45:43 +03:00
|
|
|
Qt/Icon.cpp
|
2023-08-08 04:42:06 +03:00
|
|
|
Qt/InspectorWidget.cpp
|
|
|
|
Qt/LocationEdit.cpp
|
|
|
|
Qt/Settings.cpp
|
|
|
|
Qt/SettingsDialog.cpp
|
|
|
|
Qt/Tab.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)
|
2023-08-20 23:14:31 +03:00
|
|
|
elseif (APPLE)
|
|
|
|
add_executable(ladybird MACOSX_BUNDLE
|
|
|
|
${SOURCES}
|
|
|
|
AppKit/main.mm
|
|
|
|
AppKit/Application/Application.mm
|
|
|
|
AppKit/Application/ApplicationDelegate.mm
|
|
|
|
AppKit/Application/EventLoopImplementation.mm
|
|
|
|
AppKit/UI/Event.mm
|
2023-09-13 21:55:34 +03:00
|
|
|
AppKit/UI/Inspector.mm
|
|
|
|
AppKit/UI/InspectorController.mm
|
2023-08-20 23:14:31 +03:00
|
|
|
AppKit/UI/LadybirdWebView.mm
|
|
|
|
AppKit/UI/LadybirdWebViewBridge.cpp
|
2023-08-27 06:12:30 +03:00
|
|
|
AppKit/UI/Palette.mm
|
2023-08-20 23:14:31 +03:00
|
|
|
AppKit/UI/Tab.mm
|
|
|
|
AppKit/UI/TabController.mm
|
|
|
|
AppKit/Utilities/Conversions.mm
|
|
|
|
)
|
|
|
|
target_include_directories(ladybird PRIVATE AppKit)
|
2024-01-15 19:36:05 +03:00
|
|
|
target_link_libraries(ladybird PRIVATE "-framework Cocoa" LibUnicode)
|
2023-08-20 23:14:31 +03:00
|
|
|
target_compile_options(ladybird PRIVATE
|
|
|
|
-fobjc-arc
|
|
|
|
-Wno-deprecated-anon-enum-enum-conversion # Required for CGImageCreate
|
|
|
|
)
|
2023-09-02 18:30:21 +03:00
|
|
|
elseif(ANDROID)
|
|
|
|
add_library(ladybird SHARED
|
|
|
|
${SOURCES}
|
|
|
|
Android/src/main/cpp/LadybirdActivity.cpp
|
|
|
|
Android/src/main/cpp/WebViewImplementationNative.cpp
|
2023-09-15 21:35:20 +03:00
|
|
|
Android/src/main/cpp/WebViewImplementationNativeJNI.cpp
|
2023-09-09 07:12:42 +03:00
|
|
|
Android/src/main/cpp/ALooperEventLoopImplementation.cpp
|
|
|
|
Android/src/main/cpp/TimerExecutorService.cpp
|
2023-09-24 08:05:15 +03:00
|
|
|
Android/src/main/cpp/JNIHelpers.cpp
|
2023-09-02 18:30:21 +03:00
|
|
|
)
|
2023-09-15 21:35:20 +03:00
|
|
|
target_link_libraries(ladybird PRIVATE LibArchive jnigraphics android)
|
2023-08-08 04:42:06 +03:00
|
|
|
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()
|
2023-08-20 23:14:31 +03:00
|
|
|
|
2023-08-08 07:14:22 +03:00
|
|
|
target_sources(ladybird PUBLIC FILE_SET ladybird TYPE HEADERS
|
|
|
|
BASE_DIRS ${SERENITY_SOURCE_DIR}
|
|
|
|
FILES ${LADYBIRD_HEADERS}
|
|
|
|
)
|
2024-01-22 02:24:43 +03:00
|
|
|
target_link_libraries(ladybird PRIVATE AK LibCore LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibWeb LibWebView LibProtocol)
|
2022-07-04 14:45:18 +03:00
|
|
|
|
2022-10-05 16:23:41 +03:00
|
|
|
target_include_directories(ladybird PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
2023-06-09 23:37:21 +03:00
|
|
|
target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/)
|
2022-10-23 00:35:55 +03:00
|
|
|
target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Applications/)
|
2022-10-05 16:23:41 +03:00
|
|
|
target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services/)
|
|
|
|
|
2023-08-05 19:42:26 +03:00
|
|
|
add_executable(headless-browser
|
2023-03-12 19:38:15 +03:00
|
|
|
${SERENITY_SOURCE_DIR}/Userland/Utilities/headless-browser.cpp
|
|
|
|
${SERENITY_SOURCE_DIR}/Userland/Services/WebContent/WebDriverConnection.cpp
|
|
|
|
HelperProcess.cpp
|
|
|
|
Utilities.cpp)
|
|
|
|
|
|
|
|
target_include_directories(headless-browser PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
2024-01-22 02:24:43 +03:00
|
|
|
target_link_libraries(headless-browser PRIVATE AK LibCore LibWeb LibWebView LibWebSocket LibCrypto LibFileSystem LibGemini LibHTTP LibImageDecoderClient LibJS LibGfx LibMain LibTLS LibIPC LibDiff LibProtocol)
|
2023-03-12 19:38:15 +03:00
|
|
|
|
2022-07-11 10:14:53 +03:00
|
|
|
if (ANDROID)
|
|
|
|
include(cmake/AndroidExtras.cmake)
|
|
|
|
endif()
|
|
|
|
|
2022-12-23 21:36:02 +03:00
|
|
|
add_custom_target(run${LADYBIRD_CUSTOM_TARGET_SUFFIX}
|
2023-01-26 14:51:48 +03:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SERENITY_SOURCE_DIR}" "$<TARGET_FILE:ladybird>" $ENV{LAGOM_ARGS}
|
2022-07-04 14:45:18 +03:00
|
|
|
USES_TERMINAL
|
2023-01-26 14:51:48 +03:00
|
|
|
VERBATIM
|
2022-07-04 14:45:18 +03:00
|
|
|
)
|
|
|
|
|
2022-12-23 21:36:02 +03:00
|
|
|
add_custom_target(debug${LADYBIRD_CUSTOM_TARGET_SUFFIX}
|
2022-10-19 22:13:53 +03:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SERENITY_SOURCE_DIR}" gdb -ex "set follow-fork-mode child" "$<TARGET_FILE:ladybird>"
|
2022-07-04 14:45:18 +03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2023-09-08 13:30:50 +03:00
|
|
|
add_subdirectory(ImageDecoder)
|
|
|
|
add_subdirectory(RequestServer)
|
2022-12-05 21:09:42 +03:00
|
|
|
add_subdirectory(SQLServer)
|
2022-10-08 02:08:29 +03:00
|
|
|
add_subdirectory(WebContent)
|
2022-11-14 20:09:14 +03:00
|
|
|
add_subdirectory(WebDriver)
|
2023-08-03 03:13:23 +03:00
|
|
|
add_subdirectory(WebSocket)
|
2023-11-08 21:47:41 +03:00
|
|
|
add_subdirectory(WebWorker)
|
|
|
|
add_dependencies(ladybird ImageDecoder RequestServer SQLServer WebContent WebDriver WebSocketServer WebWorker headless-browser)
|
2023-03-26 18:53:32 +03:00
|
|
|
|
2023-08-14 22:08:14 +03:00
|
|
|
function(create_ladybird_bundle target_name)
|
|
|
|
set_target_properties(${target_name} PROPERTIES
|
2023-09-03 17:16:49 +03:00
|
|
|
OUTPUT_NAME "Ladybird"
|
2023-08-14 22:08:14 +03:00
|
|
|
MACOSX_BUNDLE_GUI_IDENTIFIER org.SerenityOS.Ladybird
|
|
|
|
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
|
|
|
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
|
|
|
MACOSX_BUNDLE_INFO_PLIST "${SERENITY_SOURCE_DIR}/Ladybird/Info.plist"
|
|
|
|
MACOSX_BUNDLE TRUE
|
|
|
|
WIN32_EXECUTABLE TRUE
|
|
|
|
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER org.SerenityOS.Ladybird
|
2023-03-26 18:53:32 +03:00
|
|
|
)
|
2023-08-14 22:08:14 +03:00
|
|
|
|
|
|
|
if (APPLE)
|
|
|
|
# FIXME: Create a proper app bundle for each helper process
|
|
|
|
set(app_dir "$<TARGET_FILE_DIR:${target_name}>")
|
|
|
|
set(bundle_dir "$<TARGET_BUNDLE_DIR:${target_name}>")
|
|
|
|
add_custom_command(TARGET ${target_name} POST_BUILD
|
2023-10-27 16:12:10 +03:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:ImageDecoder>" "${app_dir}"
|
2023-08-14 22:08:14 +03:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:RequestServer>" "${app_dir}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:SQLServer>" "${app_dir}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:WebContent>" "${app_dir}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:WebDriver>" "${app_dir}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:WebSocketServer>" "${app_dir}"
|
2023-11-08 21:47:41 +03:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:WebWorker>" "${app_dir}"
|
2023-08-14 22:08:14 +03:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:headless-browser>" "${app_dir}"
|
|
|
|
COMMAND "mkdir" -p "${bundle_dir}/Contents/Resources"
|
|
|
|
COMMAND "iconutil" --convert icns "${SERENITY_SOURCE_DIR}/Ladybird/Icons/macos/app_icon.iconset" --output "${bundle_dir}/Contents/Resources/app_icon.icns"
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${Lagom_BINARY_DIR}/cacert.pem" "${bundle_dir}/Contents"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2023-08-20 23:14:31 +03:00
|
|
|
create_ladybird_bundle(ladybird)
|
2022-10-08 02:08:29 +03:00
|
|
|
|
2022-09-16 13:08:24 +03:00
|
|
|
if(NOT CMAKE_SKIP_INSTALL_RULES)
|
|
|
|
include(cmake/InstallRules.cmake)
|
|
|
|
endif()
|
2023-03-10 20:45:50 +03:00
|
|
|
|
|
|
|
include(CTest)
|
|
|
|
if (BUILD_TESTING)
|
|
|
|
add_test(
|
2023-05-27 20:46:17 +03:00
|
|
|
NAME LibWeb
|
2023-11-10 19:50:39 +03:00
|
|
|
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/../bin/headless-browser --resources "${SERENITY_SOURCE_DIR}/Base/res" --run-tests ${SERENITY_SOURCE_DIR}/Tests/LibWeb --dump-failed-ref-tests
|
2023-03-10 20:45:50 +03:00
|
|
|
)
|
2023-08-19 22:46:26 +03:00
|
|
|
add_test(
|
|
|
|
NAME WPT
|
|
|
|
CONFIGURATIONS Integration
|
|
|
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../Tests/LibWeb/WPT/run.sh
|
|
|
|
)
|
|
|
|
set_tests_properties(LibWeb WPT PROPERTIES
|
|
|
|
DEPENDS ladybird
|
|
|
|
ENVIRONMENT QT_QPA_PLATFORM=offscreen
|
|
|
|
ENVIRONMENT "SERENITY_SOURCE_DIR=${SERENITY_SOURCE_DIR}"
|
|
|
|
)
|
2023-03-10 20:45:50 +03:00
|
|
|
endif()
|