2023-08-08 04:14:22 +00:00
|
|
|
cmake_minimum_required(VERSION 3.23)
|
2022-07-04 11:45:18 +00:00
|
|
|
|
|
|
|
project(ladybird
|
|
|
|
VERSION 0.0.1
|
|
|
|
LANGUAGES CXX
|
|
|
|
DESCRIPTION "Ladybird Web Browser"
|
|
|
|
)
|
|
|
|
|
2022-09-16 10:08:24 +00:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2022-07-11 07:14:53 +00:00
|
|
|
if (ANDROID)
|
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
|
|
|
endif()
|
|
|
|
|
2022-07-04 11:45:18 +00: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 10:08:24 +00:00
|
|
|
set(CMAKE_INSTALL_RPATH $ORIGIN;$ORIGIN/../${CMAKE_INSTALL_LIBDIR})
|
2022-07-04 11:45:18 +00:00
|
|
|
endif()
|
|
|
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
|
2022-10-04 00:30:29 +00:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2022-07-04 11:45:18 +00:00
|
|
|
include(cmake/EnableLLD.cmake)
|
|
|
|
|
2022-10-19 19:12:29 +00: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 13:39:22 +00:00
|
|
|
if (UNDEFINED_BEHAVIOR_IS_FATAL)
|
|
|
|
add_compile_options(-fno-sanitize-recover=undefined)
|
|
|
|
endif()
|
2022-10-19 19:12:29 +00:00
|
|
|
add_link_options(-fsanitize=undefined)
|
|
|
|
endif()
|
|
|
|
|
2022-07-04 11:45:18 +00:00
|
|
|
# Lagom
|
2022-12-23 18:36:02 +00: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 11:45:18 +00:00
|
|
|
|
2022-12-23 18:36:02 +00: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)
|
|
|
|
include(lagom_compile_options NO_POLICY_SCOPE)
|
|
|
|
else()
|
|
|
|
# FIXME: Use SERENITY_SOURCE_DIR in Lagom/CMakeLists.txt
|
|
|
|
set(SERENITY_SOURCE_DIR "${SERENITY_PROJECT_ROOT}")
|
|
|
|
endif()
|
2022-07-11 07:14:53 +00:00
|
|
|
|
2023-04-24 11:16:37 +00:00
|
|
|
add_compile_options(-DAK_DONT_REPLACE_STD)
|
2022-07-04 11:45:18 +00:00
|
|
|
add_compile_options(-Wno-expansion-to-defined)
|
2022-07-13 19:33:22 +00:00
|
|
|
add_compile_options(-Wno-user-defined-literals)
|
2022-07-04 11:45:18 +00:00
|
|
|
|
2023-08-08 01:42:06 +00:00
|
|
|
serenity_option(ENABLE_QT ON CACHE BOOL "Build ladybird application using Qt GUI")
|
|
|
|
|
|
|
|
if (APPLE AND NOT ENABLE_QT)
|
|
|
|
message(FATAL_ERROR "Non-Qt builds not supported on macOS yet!")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (ENABLE_QT)
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
|
|
|
find_package(Qt6 REQUIRED COMPONENTS Core Widgets Network Multimedia)
|
|
|
|
endif()
|
2022-07-04 11:45:18 +00:00
|
|
|
|
2022-10-22 21:35:55 +00:00
|
|
|
set(BROWSER_SOURCE_DIR ${SERENITY_SOURCE_DIR}/Userland/Applications/Browser/)
|
|
|
|
|
2022-07-04 11:45:18 +00:00
|
|
|
set(SOURCES
|
2022-10-22 21:35:55 +00:00
|
|
|
${BROWSER_SOURCE_DIR}/CookieJar.cpp
|
2022-12-05 18:09:42 +00:00
|
|
|
${BROWSER_SOURCE_DIR}/Database.cpp
|
2022-10-22 21:42:00 +00:00
|
|
|
${BROWSER_SOURCE_DIR}/History.cpp
|
2023-02-02 10:00:30 +00:00
|
|
|
HelperProcess.cpp
|
2022-09-19 09:06:23 +00:00
|
|
|
Utilities.cpp
|
2022-07-04 11:45:18 +00:00
|
|
|
)
|
2023-08-08 04:14:22 +00:00
|
|
|
set(BROWSER_HEADERS
|
|
|
|
${BROWSER_SOURCE_DIR}/CookieJar.h
|
|
|
|
${BROWSER_SOURCE_DIR}/Database.h
|
|
|
|
${BROWSER_SOURCE_DIR}/History.h
|
|
|
|
)
|
|
|
|
set(LADYBIRD_HEADERS
|
|
|
|
HelperProcess.h
|
|
|
|
Types.h
|
|
|
|
Utilities.h
|
|
|
|
)
|
2022-07-04 11:45:18 +00:00
|
|
|
|
2023-08-08 01:42:06 +00:00
|
|
|
if (ENABLE_QT)
|
|
|
|
qt_add_executable(ladybird ${SOURCES})
|
|
|
|
target_sources(ladybird PRIVATE
|
|
|
|
Qt/BrowserWindow.cpp
|
|
|
|
Qt/ConsoleWidget.cpp
|
|
|
|
Qt/EventLoopImplementationQt.cpp
|
|
|
|
Qt/EventLoopImplementationQtEventTarget.cpp
|
|
|
|
Qt/InspectorWidget.cpp
|
|
|
|
Qt/LocationEdit.cpp
|
|
|
|
Qt/ModelTranslator.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)
|
|
|
|
|
|
|
|
# FIXME: Set these for non-qt executables as well, when those exist
|
|
|
|
set_target_properties(ladybird PROPERTIES
|
|
|
|
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 "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist"
|
|
|
|
MACOSX_BUNDLE TRUE
|
|
|
|
WIN32_EXECUTABLE TRUE
|
|
|
|
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER org.SerenityOS.Ladybird
|
|
|
|
)
|
|
|
|
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-08 04:14:22 +00:00
|
|
|
target_sources(ladybird PUBLIC FILE_SET browser TYPE HEADERS
|
|
|
|
BASE_DIRS ${SERENITY_SOURCE_DIR}/Userland/Applications
|
|
|
|
FILES ${BROWSER_HEADERS}
|
|
|
|
)
|
|
|
|
target_sources(ladybird PUBLIC FILE_SET ladybird TYPE HEADERS
|
|
|
|
BASE_DIRS ${SERENITY_SOURCE_DIR}
|
|
|
|
FILES ${LADYBIRD_HEADERS}
|
|
|
|
)
|
2023-08-08 01:42:06 +00:00
|
|
|
target_link_libraries(ladybird PRIVATE LibCore LibFileSystem LibGfx LibGUI LibIPC LibJS LibMain LibWeb LibWebView LibSQL LibProtocol)
|
2022-07-04 11:45:18 +00:00
|
|
|
|
2022-10-05 13:23:41 +00:00
|
|
|
target_include_directories(ladybird PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
2023-06-09 20:37:21 +00:00
|
|
|
target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/)
|
2022-10-22 21:35:55 +00:00
|
|
|
target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Applications/)
|
2022-10-05 13:23:41 +00:00
|
|
|
target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services/)
|
|
|
|
|
2023-08-05 16:42:26 +00:00
|
|
|
add_executable(headless-browser
|
2023-03-12 16:38:15 +00: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})
|
2023-08-05 16:42:26 +00:00
|
|
|
target_link_libraries(headless-browser PRIVATE LibWeb LibWebView LibWebSocket LibCrypto LibFileSystem LibGemini LibHTTP LibJS LibGfx LibMain LibTLS LibIPC LibDiff LibProtocol)
|
2023-03-12 16:38:15 +00:00
|
|
|
|
2022-07-11 07:14:53 +00:00
|
|
|
if (ANDROID)
|
|
|
|
include(cmake/AndroidExtras.cmake)
|
2023-07-19 16:27:16 +00:00
|
|
|
link_android_libs(headless-browser)
|
2022-07-11 07:14:53 +00:00
|
|
|
endif()
|
|
|
|
|
2022-12-23 18:36:02 +00:00
|
|
|
add_custom_target(run${LADYBIRD_CUSTOM_TARGET_SUFFIX}
|
2023-01-26 11:51:48 +00:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SERENITY_SOURCE_DIR}" "$<TARGET_FILE:ladybird>" $ENV{LAGOM_ARGS}
|
2022-07-04 11:45:18 +00:00
|
|
|
USES_TERMINAL
|
2023-01-26 11:51:48 +00:00
|
|
|
VERBATIM
|
2022-07-04 11:45:18 +00:00
|
|
|
)
|
|
|
|
|
2022-12-23 18:36:02 +00:00
|
|
|
add_custom_target(debug${LADYBIRD_CUSTOM_TARGET_SUFFIX}
|
2022-10-19 19:13:53 +00: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 11:45:18 +00:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2022-12-05 18:09:42 +00:00
|
|
|
add_subdirectory(SQLServer)
|
2022-10-07 23:08:29 +00:00
|
|
|
add_subdirectory(WebContent)
|
2022-11-14 17:09:14 +00:00
|
|
|
add_subdirectory(WebDriver)
|
2023-08-03 00:13:23 +00:00
|
|
|
add_subdirectory(WebSocket)
|
2023-08-01 20:39:19 +00:00
|
|
|
add_subdirectory(RequestServer)
|
2023-08-03 00:13:23 +00:00
|
|
|
add_dependencies(ladybird SQLServer WebContent WebDriver WebSocketServer RequestServer headless-browser)
|
2023-03-26 15:53:32 +00:00
|
|
|
|
|
|
|
if (APPLE)
|
|
|
|
# FIXME: Create a proper app bundle for each helper process
|
|
|
|
set(app_dir "$<TARGET_FILE_DIR:ladybird>")
|
|
|
|
set(bundle_dir "$<TARGET_BUNDLE_DIR:ladybird>")
|
|
|
|
add_custom_command(TARGET ladybird POST_BUILD
|
2023-08-01 20:39:19 +00:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:RequestServer>" "${app_dir}"
|
2023-03-26 15:53:32 +00:00
|
|
|
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}"
|
2023-08-03 00:13:23 +00:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:WebSocketServer>" "${app_dir}"
|
2023-03-26 15:53:32 +00:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:headless-browser>" "${app_dir}"
|
2023-08-02 20:09:32 +00:00
|
|
|
COMMAND "mkdir" -p "${bundle_dir}/Contents/Resources"
|
|
|
|
COMMAND "iconutil" --convert icns "${CMAKE_CURRENT_SOURCE_DIR}/Icons/macos/app_icon.iconset" --output "${bundle_dir}/Contents/Resources/app_icon.icns"
|
2023-08-06 19:41:06 +00:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${Lagom_BINARY_DIR}/cacert.pem" "${bundle_dir}/Contents"
|
2023-03-26 15:53:32 +00:00
|
|
|
)
|
|
|
|
endif()
|
2022-10-07 23:08:29 +00:00
|
|
|
|
2022-09-16 10:08:24 +00:00
|
|
|
if(NOT CMAKE_SKIP_INSTALL_RULES)
|
|
|
|
include(cmake/InstallRules.cmake)
|
|
|
|
endif()
|
2023-03-10 17:45:50 +00:00
|
|
|
|
|
|
|
include(CTest)
|
|
|
|
if (BUILD_TESTING)
|
|
|
|
add_test(
|
2023-05-27 17:46:17 +00:00
|
|
|
NAME LibWeb
|
2023-03-18 15:23:35 +00:00
|
|
|
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/../bin/headless-browser --run-tests ${SERENITY_SOURCE_DIR}/Tests/LibWeb
|
2023-03-10 17:45:50 +00:00
|
|
|
)
|
2023-05-27 17:46:17 +00:00
|
|
|
set_tests_properties(LibWeb PROPERTIES ENVIRONMENT QT_QPA_PLATFORM=offscreen)
|
2023-03-10 17:45:50 +00:00
|
|
|
endif()
|