2024-06-03 19:24:20 +00:00
|
|
|
cmake_minimum_required(VERSION 3.25)
|
|
|
|
|
2024-07-03 19:17:16 +00: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.)
|
|
|
|
include("Ladybird/Android/vcpkg_android.cmake")
|
|
|
|
endif()
|
|
|
|
|
2024-07-17 17:17:48 +00:00
|
|
|
# Pass additional information to vcpkg toolchain files if we are using vcpkg.
|
|
|
|
if (CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg.cmake$")
|
|
|
|
set(CMAKE_PROJECT_ladybird_INCLUDE_BEFORE "Meta/CMake/vcpkg/generate_vcpkg_toolchain_variables.cmake")
|
|
|
|
endif()
|
|
|
|
|
2024-06-03 19:24:20 +00:00
|
|
|
project(ladybird
|
|
|
|
VERSION 0.1.0
|
|
|
|
LANGUAGES C CXX
|
|
|
|
DESCRIPTION "Ladybird Web Browser"
|
2024-09-23 22:21:38 +00:00
|
|
|
HOMEPAGE_URL "https://ladybird.org"
|
2024-06-03 19:24:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
if (ANDROID OR IOS)
|
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
|
|
|
set(LADYBIRD_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${LADYBIRD_SOURCE_DIR}/Meta/CMake")
|
|
|
|
|
|
|
|
include(Ladybird/cmake/EnableLagom.cmake)
|
|
|
|
include(use_linker)
|
2024-07-20 14:14:39 +00:00
|
|
|
include(lagom_options NO_POLICY_SCOPE)
|
2024-06-03 19:24:20 +00:00
|
|
|
include(lagom_compile_options)
|
|
|
|
|
|
|
|
if (ENABLE_ADDRESS_SANITIZER)
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_compile_options(-fsanitize=address -fno-omit-frame-pointer)
|
|
|
|
add_cxx_link_options(-fsanitize=address)
|
2024-07-16 11:33:39 +00:00
|
|
|
add_swift_compile_options(-sanitize=address)
|
|
|
|
add_swift_link_options(-sanitize=address)
|
2024-06-03 19:24:20 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (ENABLE_MEMORY_SANITIZER)
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_compile_options(-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer)
|
|
|
|
add_cxx_link_options(-fsanitize=memory -fsanitize-memory-track-origins)
|
2024-06-03 19:24:20 +00:00
|
|
|
endif()
|
|
|
|
|
2024-07-25 02:09:05 +00:00
|
|
|
if (ENABLE_UNDEFINED_SANITIZER AND (APPLE OR NOT ENABLE_SWIFT))
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_compile_options(-fsanitize=undefined -fno-omit-frame-pointer)
|
2024-06-03 19:24:20 +00:00
|
|
|
if (UNDEFINED_BEHAVIOR_IS_FATAL)
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_compile_options(-fno-sanitize-recover=undefined)
|
2024-06-03 19:24:20 +00:00
|
|
|
endif()
|
|
|
|
if (APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang$" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "17")
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_compile_options(-fno-sanitize=function)
|
2024-06-03 19:24:20 +00:00
|
|
|
endif()
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_link_options(-fsanitize=undefined)
|
2024-07-25 02:09:05 +00:00
|
|
|
add_swift_compile_options(-sanitize=undefined)
|
|
|
|
add_swift_link_options(-sanitize=undefined)
|
2024-06-03 19:24:20 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (HAIKU)
|
|
|
|
# Haiku needs some extra compile definitions to make important stuff in its headers available.
|
|
|
|
add_compile_definitions(_DEFAULT_SOURCE)
|
|
|
|
add_compile_definitions(_GNU_SOURCE)
|
|
|
|
add_compile_definitions(__USE_GNU)
|
|
|
|
endif()
|
|
|
|
|
2024-07-19 21:54:52 +00:00
|
|
|
add_cxx_compile_options(-Wno-expansion-to-defined)
|
|
|
|
add_cxx_compile_options(-Wno-user-defined-literals)
|
2024-06-03 19:24:20 +00:00
|
|
|
|
|
|
|
if (ANDROID OR APPLE)
|
|
|
|
serenity_option(ENABLE_QT OFF CACHE BOOL "Build ladybird application using Qt GUI")
|
|
|
|
else()
|
|
|
|
serenity_option(ENABLE_QT ON CACHE BOOL "Build ladybird application using Qt GUI")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (ANDROID AND ENABLE_QT)
|
|
|
|
message(STATUS "Disabling Qt for Android")
|
|
|
|
set(ENABLE_QT OFF CACHE BOOL "" FORCE)
|
|
|
|
endif()
|
|
|
|
|
2024-07-07 15:24:34 +00:00
|
|
|
if (ENABLE_QT AND ENABLE_GUI_TARGETS)
|
2024-06-03 19:24:20 +00:00
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
|
|
|
find_package(Qt6 REQUIRED COMPONENTS Core Widgets Network)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include(CTest) # for BUILD_TESTING option, default ON
|
|
|
|
|
2024-07-07 15:24:34 +00:00
|
|
|
if (ENABLE_GUI_TARGETS)
|
2024-11-09 17:13:18 +00:00
|
|
|
add_subdirectory(Services)
|
2024-07-07 15:24:34 +00:00
|
|
|
add_subdirectory(Ladybird)
|
|
|
|
endif()
|
2024-06-04 21:03:02 +00:00
|
|
|
|
|
|
|
add_custom_target(lint-shell-scripts
|
2024-07-07 12:39:49 +00:00
|
|
|
COMMAND "${ladybird_SOURCE_DIR}/Meta/lint-shell-scripts.sh"
|
|
|
|
USES_TERMINAL
|
2024-06-04 21:03:02 +00:00
|
|
|
)
|
|
|
|
|
2024-07-07 12:39:49 +00:00
|
|
|
find_package(Python3 COMPONENTS Interpreter)
|
|
|
|
if (Python3_FOUND)
|
|
|
|
add_custom_target(check-style
|
|
|
|
COMMAND ${Python3_EXECUTABLE} "${ladybird_SOURCE_DIR}/Meta/check-style.py"
|
2024-06-04 21:03:02 +00:00
|
|
|
USES_TERMINAL
|
2024-07-07 12:39:49 +00:00
|
|
|
)
|
|
|
|
endif()
|