blob: 30f4ec6eeb9b01ff139ad76e2ddfb54f07dce37c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
cmake_minimum_required(VERSION 3.16...3.22)
project(ladybird
VERSION 0.0.1
LANGUAGES CXX
DESCRIPTION "Ladybird Web Browser"
)
include(GNUInstallDirs)
if (ANDROID)
set(BUILD_SHARED_LIBS OFF)
endif()
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;$ORIGIN/../${CMAKE_INSTALL_LIBDIR})
endif()
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(cmake/EnableLLD.cmake)
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)
add_link_options(-fsanitize=undefined)
endif()
# Lagom
# 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()
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()
add_compile_options(-DAK_DONT_REPLACE_STD)
add_compile_options(-Wno-expansion-to-defined)
add_compile_options(-Wno-user-defined-literals)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_package(Qt6 REQUIRED COMPONENTS Core Widgets Network)
set(BROWSER_SOURCE_DIR ${SERENITY_SOURCE_DIR}/Userland/Applications/Browser/)
set(SOURCES
${BROWSER_SOURCE_DIR}/CookieJar.cpp
${BROWSER_SOURCE_DIR}/Database.cpp
${BROWSER_SOURCE_DIR}/History.cpp
BrowserWindow.cpp
ConsoleWidget.cpp
HelperProcess.cpp
InspectorWidget.cpp
LocationEdit.cpp
ModelTranslator.cpp
Settings.cpp
SettingsDialog.cpp
Tab.cpp
Utilities.cpp
WebContentView.cpp
main.cpp
)
qt_add_executable(ladybird ${SOURCES}
MANUAL_FINALIZATION
)
target_link_libraries(ladybird PRIVATE Qt::Core Qt::Gui Qt::Network Qt::Widgets LibCore LibFileSystem LibGfx LibGUI LibIPC LibJS LibMain LibWeb LibWebView LibSQL)
target_include_directories(ladybird PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Applications/)
target_include_directories(ladybird PRIVATE ${SERENITY_SOURCE_DIR}/Userland/Services/)
qt_add_executable(headless-browser
${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})
target_link_libraries(headless-browser PRIVATE Qt::Core LibWeb LibWebView LibWebSocket LibCrypto LibFileSystem LibGemini LibHTTP LibJS LibGfx LibMain LibTLS LibIPC LibJS)
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
)
if (ANDROID)
include(cmake/AndroidExtras.cmake)
endif()
add_custom_target(run${LADYBIRD_CUSTOM_TARGET_SUFFIX}
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SERENITY_SOURCE_DIR}" "$<TARGET_FILE:ladybird>" $ENV{LAGOM_ARGS}
USES_TERMINAL
VERBATIM
)
add_custom_target(debug${LADYBIRD_CUSTOM_TARGET_SUFFIX}
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SERENITY_SOURCE_DIR}" gdb -ex "set follow-fork-mode child" "$<TARGET_FILE:ladybird>"
USES_TERMINAL
)
qt_finalize_executable(ladybird)
add_subdirectory(SQLServer)
add_subdirectory(WebContent)
add_subdirectory(WebDriver)
add_dependencies(ladybird SQLServer WebContent WebDriver headless-browser)
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
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:headless-browser>" "${app_dir}"
)
endif()
if(NOT CMAKE_SKIP_INSTALL_RULES)
include(cmake/InstallRules.cmake)
endif()
include(CTest)
if (BUILD_TESTING)
add_test(
NAME Layout
COMMAND ${SERENITY_SOURCE_DIR}/Tests/LibWeb/Layout/layout_test.sh ${CMAKE_CURRENT_BINARY_DIR}
)
set_tests_properties(Layout PROPERTIES ENVIRONMENT QT_QPA_PLATFORM=offscreen)
endif()
|