Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
164 lines (130 loc) · 5.23 KB
/
Copy pathCMakeLists.txt
File metadata and controls
164 lines (130 loc) · 5.23 KB
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
cmake_minimum_required(VERSION 3.25)
include("Meta/CMake/environment.cmake")
if (VCPKG_TARGET_ANDROID)
# If we are building for Android, we must load vcpkg_android.cmake before the project() declaration.
# This ensures that the CMAKE_TOOLCHAIN_FILE is set correctly.
# (we cannot set CMAKE_TOOLCHAIN_FILE from Gradle, unfortunately, so this is the only place we can do it.)
include("UI/Android/vcpkg_android.cmake")
endif()
# vcpkg flags depend on what linker we are using
include("Meta/CMake/use_linker.cmake")
if (APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET 14.4)
endif()
# Pass additional information to vcpkg if we are using it.
if (CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg.cmake$")
set(CMAKE_PROJECT_ladybird_INCLUDE_BEFORE "Meta/CMake/vcpkg/generate_vcpkg_toolchain_variables.cmake")
endif()
if (APPLE AND NOT CMAKE_OSX_SYSROOT)
set(CMAKE_OSX_SYSROOT macosx)
endif()
project(ladybird
VERSION 0.1.0
LANGUAGES C CXX
DESCRIPTION "Ladybird Web Browser"
HOMEPAGE_URL "https://ladybird.org"
)
if (ANDROID OR IOS)
set(BUILD_SHARED_LIBS OFF)
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Ensure that when single-value arguments are passed to `cmake_parse_arguments()`
# with no or empty string arguments, they are still defined.
if (POLICY CMP0174)
cmake_policy(SET CMP0174 NEW)
endif()
set(LADYBIRD_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LADYBIRD_SOURCE_DIR}/Meta/CMake")
include(cmake_options)
include(compile_options)
include(check_for_dependencies)
include(ladybird_helper_processes)
include(revision)
if(ENABLE_ALL_THE_DEBUG_MACROS)
include(all_the_debug_macros)
endif()
if (ENABLE_LAGOM_CCACHE)
include(setup_ccache)
endif()
if (ENABLE_FUZZERS_LIBFUZZER OR ENABLE_FUZZERS_OSSFUZZ)
set(ENABLE_FUZZERS ON)
endif()
if (ENABLE_COMPILETIME_FORMAT_CHECK)
add_compile_definitions(ENABLE_COMPILETIME_FORMAT_CHECK)
endif()
add_library(JSClangPlugin INTERFACE)
add_library(GenericClangPlugin INTERFACE)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
if (ENABLE_FUZZERS_LIBFUZZER)
add_cxx_compile_options(-fsanitize=fuzzer)
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=fuzzer")
endif()
# Vanilla host builds only for building the clang plugins
if (ENABLE_CLANG_PLUGINS AND NOT CROSS_COMPILING AND NOT ENABLE_FUZZERS AND NOT ENABLE_COMPILER_EXPLORER_BUILD)
add_subdirectory(Meta/ClangPlugins)
depend_on_clang_plugin(JSClangPlugin LibJSGCClangPlugin)
depend_on_clang_plugin(GenericClangPlugin LambdaCaptureClangPlugin)
depend_on_clang_plugin(GenericClangPlugin KmallocAllocationClangPlugin)
depend_on_clang_plugin(GenericClangPlugin MathFunctionsClangPlugin)
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (ENABLE_FUZZERS_LIBFUZZER)
message(FATAL_ERROR
"Fuzzer Sanitizer (-fsanitize=fuzzer) is only supported for Fuzzer targets with LLVM. "
"Reconfigure CMake with -DCMAKE_C_COMPILER and -DCMAKE_CXX_COMPILER pointing to a clang-based toolchain "
"or build binaries without built-in fuzzing support by setting -DENABLE_FUZZERS instead."
)
endif()
endif()
# These are here to support Fuzzili builds further down the directory stack
set(ORIGINAL_CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
set(ORIGINAL_CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
set(ORIGINAL_CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${LINKER_FLAGS}")
include_directories(${LADYBIRD_SOURCE_DIR})
include_directories(Libraries)
include_directories(Services)
include_directories(${CMAKE_BINARY_DIR})
include_directories(${CMAKE_BINARY_DIR}/Libraries)
include_directories(${CMAKE_BINARY_DIR}/Services)
include(lagom_install)
include(rust_crate)
include(targets)
# Plugins need to be installed in order to be used by non-lagom builds
add_lagom_library_install_rules(GenericClangPlugin)
add_lagom_library_install_rules(JSClangPlugin)
add_subdirectory(AK)
add_subdirectory(Libraries)
if (ENABLE_FUZZERS)
add_subdirectory(Meta/Fuzzers)
endif()
# No utilities or tests in these configs
if (NOT (ENABLE_FUZZERS OR ENABLE_COMPILER_EXPLORER_BUILD OR ANDROID OR IOS))
add_subdirectory(Utilities)
include(CTest)
if (BUILD_TESTING)
add_subdirectory(Tests)
endif()
endif()
if (ENABLE_GUI_TARGETS)
add_subdirectory(Services)
add_subdirectory(UI)
# Android has no Compositor process yet, so it keeps Skia elsewhere.
if (NOT ANDROID AND NOT VCPKG_TARGET_ANDROID)
include(check_skia_confinement)
set(processes_without_skia ${ladybird_helper_processes} ladybird WebDriver)
list(REMOVE_ITEM processes_without_skia Compositor)
ladybird_check_skia_confinement(${processes_without_skia})
endif()
endif()
include(packaging)
add_custom_target(lint-shell-scripts
COMMAND "${ladybird_SOURCE_DIR}/Meta/Linters/lint_shell_scripts.sh"
USES_TERMINAL
)
add_custom_target(check-style
COMMAND ${Python3_EXECUTABLE} "${ladybird_SOURCE_DIR}/Meta/Linters/check_style.py"
USES_TERMINAL
)