forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ladybird/Meta: Convert to CMake build
- Loading branch information
Showing
7 changed files
with
177 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ Makefile | |
ladybird | ||
*.o | ||
moc_* | ||
Build | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
cmake_minimum_required(VERSION 3.16...3.22) | ||
|
||
project(ladybird | ||
VERSION 0.0.1 | ||
LANGUAGES CXX | ||
DESCRIPTION "Ladybird Web Browser" | ||
) | ||
|
||
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) | ||
set(CMAKE_INSTALL_RPATH $ORIGIN) | ||
endif() | ||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) | ||
|
||
include(cmake/EnableLLD.cmake) | ||
|
||
# Lagom | ||
include(FetchContent) | ||
include(cmake/FetchLagom.cmake) | ||
|
||
# Lagom warnings | ||
include(${Lagom_SOURCE_DIR}/../CMake/lagom_compile_options.cmake) | ||
add_compile_options(-Wno-expansion-to-defined) | ||
|
||
set(CMAKE_AUTOMOC ON) | ||
find_package(Qt6 REQUIRED COMPONENTS Core Widgets) | ||
|
||
# FIXME: Stop using deprecated declarations from QT :^) | ||
add_compile_options(-Wno-deprecated-declarations) | ||
|
||
set(SOURCES | ||
BrowserWindow.cpp | ||
main.cpp | ||
WebView.cpp | ||
) | ||
|
||
add_executable(ladybird ${SOURCES}) | ||
target_link_libraries(ladybird PRIVATE Qt6::Widgets Lagom::Web Lagom::HTTP Lagom::WebSocket Lagom::Main) | ||
|
||
get_filename_component( | ||
SERENITY_SOURCE_DIR "${Lagom_SOURCE_DIR}/../.." | ||
ABSOLUTE | ||
) | ||
|
||
add_custom_target(run | ||
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SERENITY_SOURCE_DIR}" "$<TARGET_FILE:ladybird>" | ||
USES_TERMINAL | ||
) | ||
|
||
add_custom_target(debug | ||
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SERENITY_SOURCE_DIR}" gdb "$<TARGET_FILE:ladybird>" | ||
USES_TERMINAL | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Ladybird Web Browser | ||
|
||
The Ladybird Web Browser is a browser using the SerenityOS LibWeb engine with a QT GUI. | ||
|
||
## Build Prerequisites | ||
|
||
QT6 development packages and a c++20-enabled compiler are required. On Debian/Ubuntu required packages include, but are not limited to: | ||
|
||
``` | ||
sudo apt install build-essential cmake ninja-build qt6-base-dev qt6-tools-dev-tools | ||
``` | ||
|
||
For the c++ compiler, gcc-11 or clang-13 are required at a minimum for c++20 support. | ||
|
||
For Ubuntu 20.04 and above, ensure that the QT6 Wayland packages are available: | ||
|
||
``` | ||
sudo apt install qt6-wayland | ||
``` | ||
|
||
|
||
## Build steps | ||
|
||
Basic workflow, using serenity source dir cloned from github: | ||
|
||
``` | ||
cmake -GNinja -B Build | ||
cmake --build Build | ||
ninja -C Build run | ||
``` | ||
|
||
Advanced workflow, using pre-existing serenity checkout. | ||
|
||
If you previously didn't set SERENITY_SOURCE_DIR, probably want to blast the Build directory before doing this: | ||
|
||
``` | ||
cmake -GNinja -B Build -DSERENITY_SOURCE_DIR=/path/to/serenity | ||
ninja -C Build run | ||
``` | ||
|
||
To automatically run in gdb: | ||
``` | ||
ninja -C Build debug | ||
``` | ||
|
||
To run without ninja rule: | ||
``` | ||
# or your existing serenity checkout /path/to/serenity | ||
export SERENITY_SOURCE_DIR=${PWD}/Build/serenity | ||
./Build/ladybird | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
option(LADYBIRD_USE_LLD "Use llvm lld to link application" ON) | ||
if (LADYBIRD_USE_LLD AND NOT APPLE) | ||
find_program(LLD_LINKER NAMES "ld.lld") | ||
if (NOT LLD_LINKER) | ||
message(INFO "LLD not found, cannot use to link. Disabling option...") | ||
set(LADYBIRD_USE_LLD OFF CACHE BOOL "" FORCE) | ||
endif() | ||
endif() | ||
if (LADYBIRD_USE_LLD AND NOT APPLE) | ||
add_link_options(-fuse-ld=lld) | ||
add_compile_options(-ggnu-pubnames) | ||
add_link_options(LINKER:--gdb-index) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright (c) 2021, Andrew Kaster <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
# Fetch serenity, so that we can build Lagom from it | ||
FetchContent_Declare(lagom | ||
GIT_REPOSITORY https://github.com/SerenityOS/serenity.git | ||
GIT_TAG origin/master | ||
GIT_SHALLOW TRUE | ||
SOURCE_DIR serenity | ||
) | ||
|
||
# Allow developers to skip download/update steps with local checkout | ||
if (SERENITY_SOURCE_DIR) | ||
set(FETCHCONTENT_SOURCE_DIR_LAGOM ${SERENITY_SOURCE_DIR} CACHE PATH "Developer's pre-existing serenity source directory" FORCE) | ||
message(STATUS "Using pre-existing SERENITY_SOURCE_DIR: ${SERENITY_SOURCE_DIR}") | ||
endif() | ||
|
||
# Can't use FetchContent_MakeAvailable b/c we want to use the Lagom build, not the main build | ||
# Populate source directory for lagom | ||
FetchContent_GetProperties(lagom) | ||
if (NOT lagom_POPULATED) | ||
FetchContent_Populate(lagom) | ||
set(BUILD_LAGOM ON CACHE INTERNAL "Build all Lagom targets") | ||
|
||
# FIXME: Setting target_include_directories on Lagom libraries might make this unecessary? | ||
include_directories(${lagom_SOURCE_DIR}/Userland/Libraries) | ||
include_directories(${lagom_SOURCE_DIR}) | ||
include_directories(${lagom_BINARY_DIR}) | ||
|
||
# We set EXCLUDE_FROM_ALL to make sure that only required Lagom libraries are built | ||
add_subdirectory(${lagom_SOURCE_DIR}/Meta/Lagom ${lagom_BINARY_DIR} EXCLUDE_FROM_ALL) | ||
endif() |
This file was deleted.
Oops, something went wrong.