2024-06-03 16:24:20 -03:00
|
|
|
cmake_minimum_required(VERSION 3.25)
|
|
|
|
|
|
2024-07-03 16:17:16 -03:00
|
|
|
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.)
|
2024-11-09 14:50:33 -03:00
|
|
|
include("UI/Android/vcpkg_android.cmake")
|
2024-07-03 16:17:16 -03:00
|
|
|
endif()
|
|
|
|
|
|
2024-12-05 19:46:02 -03:00
|
|
|
# vcpkg flags depend on what linker we are using
|
|
|
|
|
include("Meta/CMake/use_linker.cmake")
|
|
|
|
|
|
2025-05-29 23:20:06 -03:00
|
|
|
if (APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET)
|
2026-02-17 10:23:39 -03:00
|
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET 14.0)
|
2025-05-29 23:20:06 -03:00
|
|
|
endif()
|
|
|
|
|
|
2026-04-09 02:29:46 -03:00
|
|
|
include("Meta/CMake/gui_framework.cmake")
|
|
|
|
|
|
|
|
|
|
# Pass additional information to vcpkg if we are using it.
|
2024-07-17 14:17:48 -03:00
|
|
|
if (CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg.cmake$")
|
|
|
|
|
set(CMAKE_PROJECT_ladybird_INCLUDE_BEFORE "Meta/CMake/vcpkg/generate_vcpkg_toolchain_variables.cmake")
|
2026-04-09 02:29:46 -03:00
|
|
|
if (LADYBIRD_GUI_FRAMEWORK STREQUAL "Qt" OR LADYBIRD_GUI_FRAMEWORK STREQUAL "Gtk")
|
|
|
|
|
string(TOLOWER "${LADYBIRD_GUI_FRAMEWORK}" framework_feature)
|
2026-04-19 22:16:42 -03:00
|
|
|
set(VCPKG_MANIFEST_FEATURES "${framework_feature}" CACHE STRING "" FORCE)
|
2026-04-09 02:29:46 -03:00
|
|
|
endif()
|
2024-07-17 14:17:48 -03:00
|
|
|
endif()
|
|
|
|
|
|
2025-04-21 17:57:06 -03:00
|
|
|
if (APPLE AND NOT CMAKE_OSX_SYSROOT)
|
|
|
|
|
set(CMAKE_OSX_SYSROOT macosx)
|
|
|
|
|
endif()
|
|
|
|
|
|
2024-06-03 16:24:20 -03:00
|
|
|
project(ladybird
|
|
|
|
|
VERSION 0.1.0
|
|
|
|
|
LANGUAGES C CXX
|
|
|
|
|
DESCRIPTION "Ladybird Web Browser"
|
2024-09-23 19:21:38 -03:00
|
|
|
HOMEPAGE_URL "https://ladybird.org"
|
2024-06-03 16:24:20 -03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if (ANDROID OR IOS)
|
|
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
|
2026-03-27 19:04:23 -03:00
|
|
|
# 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()
|
|
|
|
|
|
2024-06-03 16:24:20 -03:00
|
|
|
set(LADYBIRD_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${LADYBIRD_SOURCE_DIR}/Meta/CMake")
|
|
|
|
|
|
2026-03-27 17:22:02 -03:00
|
|
|
include(compile_options)
|
2026-04-21 09:59:41 -03:00
|
|
|
include(check_for_dependencies)
|
|
|
|
|
include(cmake_options)
|
2026-05-28 06:47:26 -03:00
|
|
|
include(ladybird_helper_processes)
|
2024-06-03 16:24:20 -03:00
|
|
|
|
2026-03-27 19:04:23 -03:00
|
|
|
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)
|
2026-06-12 13:29:35 -03:00
|
|
|
add_subdirectory(Meta/ClangPlugins)
|
2026-03-27 19:04:23 -03:00
|
|
|
depend_on_clang_plugin(JSClangPlugin LibJSGCClangPlugin)
|
|
|
|
|
depend_on_clang_plugin(GenericClangPlugin LambdaCaptureClangPlugin)
|
|
|
|
|
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)
|
|
|
|
|
|
2026-03-27 19:31:07 -03:00
|
|
|
include(lagom_install)
|
2026-03-27 19:04:23 -03:00
|
|
|
|
|
|
|
|
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)
|
2026-03-27 19:19:12 -03:00
|
|
|
add_subdirectory(Libraries)
|
2026-03-27 19:04:23 -03:00
|
|
|
|
|
|
|
|
if (ENABLE_FUZZERS)
|
|
|
|
|
add_subdirectory(Meta/Lagom/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()
|
2024-06-03 16:24:20 -03:00
|
|
|
|
2025-06-26 05:35:37 -03:00
|
|
|
if (ENABLE_GUI_TARGETS)
|
2024-11-09 14:13:18 -03:00
|
|
|
add_subdirectory(Services)
|
2024-11-09 14:50:33 -03:00
|
|
|
add_subdirectory(UI)
|
2024-07-07 12:24:34 -03:00
|
|
|
endif()
|
2024-06-04 18:03:02 -03:00
|
|
|
|
|
|
|
|
add_custom_target(lint-shell-scripts
|
2026-04-22 19:04:11 -03:00
|
|
|
COMMAND "${ladybird_SOURCE_DIR}/Meta/Linters/lint_shell_scripts.sh"
|
2024-07-07 09:39:49 -03:00
|
|
|
USES_TERMINAL
|
2024-06-04 18:03:02 -03:00
|
|
|
)
|
|
|
|
|
|
2026-03-29 12:44:56 -03:00
|
|
|
add_custom_target(check-style
|
2026-04-22 19:04:11 -03:00
|
|
|
COMMAND ${Python3_EXECUTABLE} "${ladybird_SOURCE_DIR}/Meta/Linters/check_style.py"
|
2026-03-29 12:44:56 -03:00
|
|
|
USES_TERMINAL
|
|
|
|
|
)
|