2023-11-10 08:09:55 +00:00
|
|
|
cmake_minimum_required (VERSION 3.21)
|
2021-07-26 01:37:27 +00:00
|
|
|
|
|
|
|
project(
|
|
|
|
Lagom
|
|
|
|
VERSION 0.0.0
|
|
|
|
DESCRIPTION "Host build of SerenityOS libraries and applications"
|
|
|
|
HOMEPAGE_URL "https://github.com/SerenityOS/serenity"
|
|
|
|
LANGUAGES C CXX
|
|
|
|
)
|
2019-07-25 09:56:08 +00:00
|
|
|
|
2022-10-31 14:08:39 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "12")
|
2021-09-07 08:21:36 +00:00
|
|
|
message(FATAL_ERROR
|
2022-10-31 14:08:39 +00:00
|
|
|
"A GCC version less than 12 was detected (${CMAKE_CXX_COMPILER_VERSION}), this is unsupported.\n"
|
2021-09-07 08:21:36 +00:00
|
|
|
"Please re-read the build instructions documentation, and upgrade your host compiler.\n")
|
2021-08-01 10:37:28 +00:00
|
|
|
endif()
|
|
|
|
|
2021-07-25 19:15:47 +00:00
|
|
|
# This is required for CMake (when invoked for a Lagom-only build) to
|
|
|
|
# ignore any files downloading during the build, e.g. UnicodeData.txt.
|
|
|
|
# https://cmake.org/cmake/help/latest/policy/CMP0058.html
|
|
|
|
cmake_policy(SET CMP0058 NEW)
|
|
|
|
|
2023-09-05 05:40:57 +00:00
|
|
|
# Make CMAKE_EXE_LINKER_FLAGS have an effect on `try_compile()` jobs.
|
|
|
|
# This is required if we want to have the `LAGOM_USE_LINKER` option
|
|
|
|
# take effect in `check_linker_flag` checks.
|
|
|
|
cmake_policy(SET CMP0056 NEW)
|
|
|
|
|
2021-07-26 01:37:27 +00:00
|
|
|
get_filename_component(
|
|
|
|
SERENITY_PROJECT_ROOT "${PROJECT_SOURCE_DIR}/../.."
|
|
|
|
ABSOLUTE CACHE
|
|
|
|
)
|
2022-07-04 16:08:01 +00:00
|
|
|
set(SerenityOS_SOURCE_DIR "${SERENITY_PROJECT_ROOT}" CACHE STRING "")
|
2021-07-26 01:37:27 +00:00
|
|
|
|
2021-09-07 07:50:09 +00:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${SERENITY_PROJECT_ROOT}/Meta/CMake")
|
|
|
|
|
2021-09-07 08:08:54 +00:00
|
|
|
if(NOT COMMAND serenity_option)
|
|
|
|
macro(serenity_option)
|
|
|
|
set(${ARGV})
|
|
|
|
endmacro()
|
|
|
|
endif()
|
|
|
|
|
2022-03-18 11:31:36 +00:00
|
|
|
include(check_for_dependencies)
|
2023-09-05 05:40:57 +00:00
|
|
|
include(use_linker)
|
2022-12-14 01:57:01 +00:00
|
|
|
include(lagom_options NO_POLICY_SCOPE)
|
2021-09-07 08:08:54 +00:00
|
|
|
|
2021-09-07 08:21:36 +00:00
|
|
|
if(ENABLE_ALL_THE_DEBUG_MACROS)
|
|
|
|
include(all_the_debug_macros)
|
|
|
|
endif()
|
|
|
|
|
2022-12-23 18:36:45 +00:00
|
|
|
# FIXME: Is it worth inventing `serenity_dependent_option` ?
|
|
|
|
if (ENABLE_LAGOM_LADYBIRD)
|
|
|
|
set(ENABLE_LAGOM_LIBWEB ON CACHE BOOL "" FORCE)
|
|
|
|
endif()
|
|
|
|
|
2021-09-07 00:06:46 +00:00
|
|
|
# FIXME: BUILD_SHARED_LIBS has a default of OFF, as it's intended to be set by the
|
2021-11-23 17:34:31 +00:00
|
|
|
# user when configuring the project. We should instead change libjs-test262
|
2021-09-07 00:06:46 +00:00
|
|
|
# and oss-fuzz to set this option on their end, and enable it by default in
|
2022-02-19 23:09:40 +00:00
|
|
|
# Meta/serenity.sh. This is #9867.
|
2021-09-07 08:21:36 +00:00
|
|
|
option(BUILD_SHARED_LIBS "Build shared libraries instead of static libraries" ON)
|
|
|
|
|
2021-07-26 01:37:27 +00:00
|
|
|
find_package(Threads REQUIRED)
|
2023-01-05 14:47:27 +00:00
|
|
|
# FIXME: This global link libraries is required to workaround linker issues (on some systems)
|
|
|
|
# from the Ladybird import. See https://github.com/SerenityOS/serenity/issues/16847
|
|
|
|
link_libraries(Threads::Threads)
|
2021-07-26 01:37:27 +00:00
|
|
|
|
2021-08-17 02:10:34 +00:00
|
|
|
if (ENABLE_LAGOM_CCACHE)
|
2022-12-06 21:57:20 +00:00
|
|
|
include(setup_ccache)
|
2021-08-17 02:10:34 +00:00
|
|
|
endif()
|
|
|
|
|
2022-03-21 10:36:41 +00:00
|
|
|
if (ENABLE_FUZZERS_LIBFUZZER OR ENABLE_FUZZERS_OSSFUZZ)
|
|
|
|
set(ENABLE_FUZZERS ON)
|
|
|
|
endif()
|
|
|
|
|
2022-10-14 02:14:36 +00:00
|
|
|
# We need to make sure not to build code generators for Fuzzer builds, as they already have their own main.cpp
|
|
|
|
# Instead, we import them from a previous install of Lagom. This mandates a two-stage build for fuzzers.
|
|
|
|
# The same concern goes for cross-compile builds, where we need the tools built for the host
|
|
|
|
set(BUILD_LAGOM_TOOLS ON)
|
|
|
|
if (ENABLE_FUZZERS OR CMAKE_CROSSCOMPILING)
|
|
|
|
find_package(LagomTools REQUIRED)
|
|
|
|
set(BUILD_LAGOM_TOOLS OFF)
|
|
|
|
endif()
|
|
|
|
|
2022-07-25 11:28:16 +00:00
|
|
|
include(flac_spec_tests)
|
2022-05-14 13:07:12 +00:00
|
|
|
include(lagom_compile_options)
|
2021-07-26 01:37:27 +00:00
|
|
|
|
2022-10-17 05:55:04 +00:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2022-11-20 03:23:14 +00:00
|
|
|
if (EMSCRIPTEN)
|
|
|
|
set(CMAKE_EXECUTABLE_SUFFIX ".js")
|
|
|
|
add_compile_options(-gsource-map)
|
|
|
|
add_link_options(--emrun "SHELL:-s ALLOW_MEMORY_GROWTH")
|
|
|
|
endif()
|
|
|
|
|
2021-05-12 11:49:19 +00:00
|
|
|
if (ENABLE_ADDRESS_SANITIZER)
|
2021-07-26 01:37:27 +00:00
|
|
|
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
|
2021-05-12 11:49:19 +00:00
|
|
|
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=address")
|
|
|
|
endif()
|
2020-04-05 10:21:03 +00:00
|
|
|
|
2021-05-12 11:49:19 +00:00
|
|
|
if (ENABLE_MEMORY_SANITIZER)
|
2021-07-26 01:37:27 +00:00
|
|
|
add_compile_options(-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer)
|
2021-05-12 11:49:19 +00:00
|
|
|
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins")
|
|
|
|
endif()
|
2020-04-05 10:21:03 +00:00
|
|
|
|
2021-05-12 11:49:19 +00:00
|
|
|
if (ENABLE_UNDEFINED_SANITIZER)
|
2022-09-14 20:33:46 +00:00
|
|
|
add_compile_options(-fsanitize=undefined -fno-omit-frame-pointer)
|
2023-08-12 13:39:22 +00:00
|
|
|
if (UNDEFINED_BEHAVIOR_IS_FATAL)
|
|
|
|
add_compile_options(-fno-sanitize-recover=undefined)
|
|
|
|
endif()
|
2023-12-19 22:41:57 +00:00
|
|
|
if (APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang$" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "17")
|
|
|
|
add_compile_options(-fno-sanitize=function)
|
|
|
|
endif()
|
2022-09-14 20:33:46 +00:00
|
|
|
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=undefined")
|
2021-05-12 11:49:19 +00:00
|
|
|
endif()
|
2020-04-05 10:21:03 +00:00
|
|
|
|
2023-07-05 19:01:56 +00:00
|
|
|
if (ENABLE_COMPILETIME_FORMAT_CHECK)
|
|
|
|
add_compile_definitions(ENABLE_COMPILETIME_FORMAT_CHECK)
|
|
|
|
endif()
|
|
|
|
|
2023-08-27 18:53:47 +00:00
|
|
|
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()
|
|
|
|
|
2022-03-21 10:36:41 +00:00
|
|
|
if (ENABLE_FUZZERS)
|
|
|
|
add_compile_options(-fno-omit-frame-pointer)
|
|
|
|
endif()
|
|
|
|
|
2022-12-23 18:36:45 +00:00
|
|
|
if (ENABLE_LAGOM_LADYBIRD AND (ENABLE_FUZZERS OR ENABLE_COMPILER_EXPLORER_BUILD))
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"Ladybird build not supported for Fuzzers or Compiler Explorer."
|
|
|
|
"Disable ENABLE_LAGOM_LADYBIRD and try again."
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2023-07-04 09:55:53 +00:00
|
|
|
CHECK_INCLUDE_FILE(pulse/pulseaudio.h HAVE_PULSEAUDIO)
|
|
|
|
|
2024-04-16 01:50:49 +00:00
|
|
|
add_library(JSClangPlugin INTERFACE)
|
|
|
|
add_library(GenericClangPlugin INTERFACE)
|
|
|
|
# These need to be installed to avoid CMake complaining about them not being in the export set
|
|
|
|
install(TARGETS GenericClangPlugin JSClangPlugin EXPORT LagomTargets)
|
|
|
|
|
2021-09-07 08:21:36 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
|
2023-04-17 23:50:53 +00:00
|
|
|
add_compile_options(-Wno-overloaded-virtual)
|
2022-04-30 18:04:30 +00:00
|
|
|
# FIXME: Re-enable this check when the warning stops triggering, or document why we can't stop it from triggering.
|
|
|
|
# For now, there is a lot of unused private fields in LibWeb that trigger this that could be removed.
|
|
|
|
# See issue #14137 for details
|
|
|
|
add_compile_options(-Wno-unused-private-field)
|
2020-04-05 10:21:03 +00:00
|
|
|
|
2022-03-29 14:31:51 +00:00
|
|
|
if (ENABLE_FUZZERS_LIBFUZZER)
|
2022-03-21 10:36:41 +00:00
|
|
|
add_compile_options(-fsanitize=fuzzer)
|
2020-11-13 20:47:32 +00:00
|
|
|
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=fuzzer")
|
2020-04-08 08:40:02 +00:00
|
|
|
endif()
|
|
|
|
|
2024-04-16 01:50:49 +00:00
|
|
|
if (ENABLE_CLANG_PLUGINS)
|
|
|
|
add_subdirectory(ClangPlugins)
|
|
|
|
depend_on_clang_plugin(JSClangPlugin LibJSGCClangPlugin)
|
|
|
|
depend_on_clang_plugin(GenericClangPlugin LambdaCaptureClangPlugin)
|
|
|
|
endif()
|
2021-09-07 08:21:36 +00:00
|
|
|
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
2022-03-29 14:31:51 +00:00
|
|
|
if (ENABLE_FUZZERS_LIBFUZZER)
|
2022-02-19 23:09:40 +00:00
|
|
|
message(FATAL_ERROR
|
|
|
|
"Fuzzer Sanitizer (-fsanitize=fuzzer) is only supported for Fuzzer targets with LLVM. "
|
2022-03-21 10:36:41 +00:00
|
|
|
"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."
|
2022-02-19 23:09:40 +00:00
|
|
|
)
|
|
|
|
endif()
|
2019-07-26 09:02:47 +00:00
|
|
|
endif()
|
2019-07-25 09:56:08 +00:00
|
|
|
|
2021-05-12 11:49:19 +00:00
|
|
|
# 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}")
|
|
|
|
|
2021-07-26 01:37:27 +00:00
|
|
|
configure_file(../../AK/Debug.h.in AK/Debug.h @ONLY)
|
|
|
|
|
2021-07-25 19:15:47 +00:00
|
|
|
include_directories(../../)
|
|
|
|
include_directories(../../Userland/)
|
|
|
|
include_directories(../../Userland/Libraries/)
|
2022-07-04 16:08:01 +00:00
|
|
|
include_directories(../../Userland/Services)
|
2021-07-25 19:15:47 +00:00
|
|
|
include_directories(${CMAKE_BINARY_DIR})
|
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
2022-10-14 02:14:36 +00:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Userland/Libraries)
|
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Userland/Services)
|
2021-07-25 19:15:47 +00:00
|
|
|
|
2021-07-28 00:22:12 +00:00
|
|
|
# install rules, think about moving to its own helper cmake file
|
2021-09-07 08:21:36 +00:00
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
|
|
|
# find_package(<package>) call for consumers to find this project
|
2022-07-11 07:07:47 +00:00
|
|
|
set(package Lagom CACHE STRING "")
|
2021-09-07 08:21:36 +00:00
|
|
|
|
|
|
|
# Allow package maintainers to freely override the path for the configs
|
|
|
|
set(Lagom_INSTALL_CMAKEDIR "${CMAKE_INSTALL_DATADIR}/${package}"
|
|
|
|
CACHE PATH "CMake package config location relative to the install prefix")
|
|
|
|
mark_as_advanced(Lagom_INSTALL_CMAKEDIR)
|
|
|
|
|
|
|
|
install(
|
2022-08-28 23:47:03 +00:00
|
|
|
FILES "${SERENITY_PROJECT_ROOT}/Meta/CMake/lagom-install-config.cmake"
|
2021-09-07 08:21:36 +00:00
|
|
|
DESTINATION "${Lagom_INSTALL_CMAKEDIR}"
|
2022-08-28 23:47:03 +00:00
|
|
|
RENAME "${package}Config.cmake"
|
2021-09-07 08:21:36 +00:00
|
|
|
COMPONENT Lagom_Development
|
|
|
|
)
|
2021-07-28 00:22:12 +00:00
|
|
|
|
2021-09-07 08:21:36 +00:00
|
|
|
install(
|
|
|
|
EXPORT LagomTargets
|
|
|
|
NAMESPACE Lagom::
|
|
|
|
DESTINATION "${Lagom_INSTALL_CMAKEDIR}"
|
|
|
|
COMPONENT Lagom_Development
|
|
|
|
)
|
2021-07-28 00:22:12 +00:00
|
|
|
|
2022-10-17 05:48:14 +00:00
|
|
|
function(lagom_lib target_name fs_name)
|
2022-10-13 20:07:09 +00:00
|
|
|
cmake_parse_arguments(LAGOM_LIBRARY "" "LIBRARY_TYPE" "SOURCES;LIBS" ${ARGN})
|
2022-10-17 05:48:14 +00:00
|
|
|
string(REPLACE "Lib" "" library ${target_name})
|
2022-10-13 20:07:09 +00:00
|
|
|
if (NOT LAGOM_LIBRARY_LIBRARY_TYPE)
|
|
|
|
set(LAGOM_LIBRARY_LIBRARY_TYPE "")
|
2022-10-01 14:08:26 +00:00
|
|
|
endif()
|
2022-10-13 20:07:09 +00:00
|
|
|
add_library(${target_name} ${LAGOM_LIBRARY_LIBRARY_TYPE} ${LAGOM_LIBRARY_SOURCES})
|
2022-02-19 23:09:40 +00:00
|
|
|
# Don't make alias when we're going to import a previous build for Tools
|
|
|
|
# FIXME: Is there a better way to write this?
|
2022-07-11 07:07:47 +00:00
|
|
|
if (NOT ENABLE_FUZZERS AND NOT CMAKE_CROSSCOMPILING)
|
2022-02-19 23:09:40 +00:00
|
|
|
# alias for parity with exports
|
|
|
|
add_library(Lagom::${library} ALIAS ${target_name})
|
|
|
|
endif()
|
2021-07-28 00:22:12 +00:00
|
|
|
|
|
|
|
set_target_properties(
|
|
|
|
${target_name} PROPERTIES
|
|
|
|
VERSION "${PROJECT_VERSION}"
|
|
|
|
SOVERSION "${PROJECT_VERSION_MAJOR}"
|
|
|
|
EXPORT_NAME ${library}
|
|
|
|
OUTPUT_NAME lagom-${fs_name}
|
|
|
|
)
|
2022-10-21 19:43:56 +00:00
|
|
|
target_link_libraries(${target_name} PRIVATE ${LAGOM_LIBRARY_LIBS})
|
2024-04-16 01:50:49 +00:00
|
|
|
target_link_libraries(${target_name} PUBLIC GenericClangPlugin)
|
2024-01-21 23:24:43 +00:00
|
|
|
|
|
|
|
if (NOT "${target_name}" STREQUAL "AK")
|
|
|
|
target_link_libraries(${target_name} PRIVATE AK)
|
2021-07-26 01:37:27 +00:00
|
|
|
endif()
|
2024-01-21 23:24:43 +00:00
|
|
|
|
2023-10-04 01:20:14 +00:00
|
|
|
# FIXME: Clean these up so that we don't need so many include dirs
|
|
|
|
target_include_directories(${target_name} INTERFACE
|
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/Services>
|
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/Userland/Libraries>
|
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/Userland/Services>
|
|
|
|
)
|
2021-09-07 08:21:36 +00:00
|
|
|
install(
|
|
|
|
TARGETS ${target_name}
|
|
|
|
EXPORT LagomTargets
|
|
|
|
RUNTIME #
|
|
|
|
COMPONENT Lagom_Runtime
|
|
|
|
LIBRARY #
|
|
|
|
COMPONENT Lagom_Runtime
|
|
|
|
NAMELINK_COMPONENT Lagom_Development
|
|
|
|
ARCHIVE #
|
2021-07-28 00:22:12 +00:00
|
|
|
COMPONENT Lagom_Development
|
2021-09-07 08:21:36 +00:00
|
|
|
INCLUDES #
|
2021-07-28 00:22:12 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
2021-09-07 08:21:36 +00:00
|
|
|
)
|
2022-10-13 20:07:09 +00:00
|
|
|
# FIXME: Move this to serenity_install_headers
|
2021-09-07 08:21:36 +00:00
|
|
|
install(
|
|
|
|
DIRECTORY "${SERENITY_PROJECT_ROOT}/Userland/Libraries/Lib${library}"
|
|
|
|
COMPONENT Lagom_Development
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
|
|
FILES_MATCHING PATTERN "*.h"
|
|
|
|
)
|
2022-10-17 05:49:52 +00:00
|
|
|
serenity_generated_sources(${target_name})
|
2021-07-26 01:37:27 +00:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(lagom_test source)
|
2023-10-27 05:59:58 +00:00
|
|
|
cmake_parse_arguments(LAGOM_TEST "" "NAME;WORKING_DIRECTORY" "LIBS" ${ARGN})
|
|
|
|
if (NOT DEFINED LAGOM_TEST_NAME)
|
|
|
|
get_filename_component(LAGOM_TEST_NAME ${source} NAME_WE)
|
|
|
|
endif()
|
|
|
|
add_executable(${LAGOM_TEST_NAME} ${source})
|
2024-01-21 23:24:43 +00:00
|
|
|
target_link_libraries(${LAGOM_TEST_NAME} PRIVATE AK LibCore LibFileSystem LibTest LibTestMain ${LAGOM_TEST_LIBS})
|
2021-07-26 01:37:27 +00:00
|
|
|
add_test(
|
2023-10-27 05:59:58 +00:00
|
|
|
NAME ${LAGOM_TEST_NAME}
|
|
|
|
COMMAND ${LAGOM_TEST_NAME}
|
2023-02-01 13:36:15 +00:00
|
|
|
WORKING_DIRECTORY ${LAGOM_TEST_WORKING_DIRECTORY}
|
2021-07-26 01:37:27 +00:00
|
|
|
)
|
2023-10-27 05:59:58 +00:00
|
|
|
set_target_properties(${LAGOM_TEST_NAME} PROPERTIES LAGOM_WORKING_DIRECTORY "${LAGOM_TEST_WORKING_DIRECTORY}")
|
2021-07-26 01:37:27 +00:00
|
|
|
endfunction()
|
|
|
|
|
2024-01-21 23:22:51 +00:00
|
|
|
function(lagom_utility name)
|
|
|
|
cmake_parse_arguments(LAGOM_UTILITY "" "" "SOURCES;LIBS" ${ARGN})
|
|
|
|
|
|
|
|
add_executable("${name}" ${LAGOM_UTILITY_SOURCES})
|
2024-01-21 23:24:43 +00:00
|
|
|
target_link_libraries("${name}" PRIVATE AK LibCore ${LAGOM_UTILITY_LIBS})
|
2024-01-21 23:22:51 +00:00
|
|
|
endfunction()
|
|
|
|
|
2023-01-16 15:35:40 +00:00
|
|
|
function(serenity_test test_src sub_dir)
|
|
|
|
cmake_parse_arguments(PARSE_ARGV 2 SERENITY_TEST "MAIN_ALREADY_DEFINED" "CUSTOM_MAIN" "LIBS")
|
|
|
|
# FIXME: Pass MAIN_ALREADY_DEFINED and CUSTOM_MAIN to support tests that use them.
|
|
|
|
lagom_test(${test_src} LIBS ${SERENITY_TEST_LIBS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
endfunction()
|
|
|
|
|
2022-07-04 16:08:01 +00:00
|
|
|
function(serenity_bin name)
|
|
|
|
add_executable(${name} ${SOURCES} ${GENERATED_SOURCES})
|
|
|
|
add_executable(Lagom::${name} ALIAS ${name})
|
2024-04-16 01:50:49 +00:00
|
|
|
target_link_libraries(${name} PUBLIC GenericClangPlugin)
|
2022-07-04 16:08:01 +00:00
|
|
|
install(
|
|
|
|
TARGETS ${target_name}
|
|
|
|
EXPORT LagomTargets
|
|
|
|
RUNTIME #
|
|
|
|
COMPONENT Lagom_Runtime
|
|
|
|
LIBRARY #
|
|
|
|
COMPONENT Lagom_Runtime
|
|
|
|
NAMELINK_COMPONENT Lagom_Development
|
|
|
|
ARCHIVE #
|
|
|
|
COMPONENT Lagom_Development
|
|
|
|
INCLUDES #
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
|
|
)
|
2022-10-17 05:49:52 +00:00
|
|
|
serenity_generated_sources(${name})
|
2022-07-04 16:08:01 +00:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(serenity_lib name fs_name)
|
2024-03-26 14:01:36 +00:00
|
|
|
cmake_parse_arguments(PARSE_ARGV 2 SERENITY_LIB "" "TYPE" "")
|
|
|
|
lagom_lib(${name} ${fs_name} LIBRARY_TYPE ${SERENITY_LIB_TYPE} SOURCES ${SOURCES} ${GENERATED_SOURCES})
|
2022-10-13 20:07:09 +00:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(serenity_install_headers dir)
|
2022-07-04 16:08:01 +00:00
|
|
|
endfunction()
|
|
|
|
|
2022-10-13 20:07:09 +00:00
|
|
|
function(serenity_install_sources dir)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
macro(add_serenity_subdirectory path)
|
|
|
|
add_subdirectory("${SERENITY_PROJECT_ROOT}/${path}" "${CMAKE_CURRENT_BINARY_DIR}/${path}")
|
|
|
|
endmacro()
|
|
|
|
|
2022-07-04 16:08:01 +00:00
|
|
|
add_custom_target(components ALL)
|
|
|
|
option(BUILD_EVERYTHING "Build all optional components" ON)
|
|
|
|
|
2021-12-22 21:33:38 +00:00
|
|
|
if (NOT TARGET all_generated)
|
|
|
|
# Meta target to run all code-gen steps in the build.
|
|
|
|
add_custom_target(all_generated)
|
|
|
|
endif()
|
|
|
|
|
2022-10-13 20:07:09 +00:00
|
|
|
# Create mostly empty targets for system libraries we don't need to build for Lagom
|
|
|
|
add_library(LibC INTERFACE)
|
|
|
|
add_library(LibCrypt INTERFACE)
|
2022-10-23 22:05:33 +00:00
|
|
|
add_library(LibSystem INTERFACE)
|
2023-08-27 18:58:53 +00:00
|
|
|
if (NOT APPLE AND NOT ANDROID AND NOT EMSCRIPTEN AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD" AND NOT HAIKU)
|
2022-10-13 20:07:09 +00:00
|
|
|
target_link_libraries(LibCrypt INTERFACE crypt) # LibCore::Account uses crypt() but it's not in libcrypt on macOS
|
2021-07-26 01:37:27 +00:00
|
|
|
endif()
|
2022-10-23 22:05:33 +00:00
|
|
|
if (SERENITYOS)
|
|
|
|
# Serenity only allows syscalls from LibSystem, so if someone asks for that on Lagom,
|
|
|
|
# we need to pass that through to the system's LibSystem.
|
|
|
|
target_link_libraries(LibSystem INTERFACE system)
|
|
|
|
endif()
|
2022-10-13 20:07:09 +00:00
|
|
|
add_library(NoCoverage INTERFACE)
|
|
|
|
# "install" these special targets to placate CMake
|
2022-10-23 22:05:33 +00:00
|
|
|
install(TARGETS LibC LibCrypt LibSystem NoCoverage EXPORT LagomTargets)
|
2022-10-13 20:07:09 +00:00
|
|
|
|
2024-01-21 23:24:43 +00:00
|
|
|
# AK
|
2022-10-13 20:07:09 +00:00
|
|
|
add_serenity_subdirectory(AK)
|
2024-01-21 23:24:43 +00:00
|
|
|
lagom_lib(AK ak SOURCES ${AK_SOURCES})
|
2024-02-26 22:50:11 +00:00
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "BSD$" OR HAIKU)
|
|
|
|
# BSD Platforms and Haiku have backtrace(3) in a separate library
|
|
|
|
target_link_libraries(AK PRIVATE execinfo)
|
|
|
|
endif()
|
2024-01-21 23:24:43 +00:00
|
|
|
|
2024-03-25 14:57:36 +00:00
|
|
|
add_serenity_subdirectory(Userland/Libraries/LibUnicode)
|
2024-03-18 03:22:27 +00:00
|
|
|
add_serenity_subdirectory(Userland/Libraries/LibURL)
|
|
|
|
|
2024-01-21 23:24:43 +00:00
|
|
|
# LibCore
|
2022-10-13 20:07:09 +00:00
|
|
|
add_serenity_subdirectory(Userland/Libraries/LibCore)
|
2022-10-21 19:43:56 +00:00
|
|
|
target_link_libraries(LibCore PRIVATE Threads::Threads)
|
2023-02-20 15:29:50 +00:00
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
|
|
|
|
# NetBSD has its shm_open and shm_unlink functions in librt so we need to link that
|
|
|
|
target_link_libraries(LibCore PRIVATE librt.so)
|
|
|
|
endif()
|
2023-02-25 18:10:57 +00:00
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
|
|
|
|
# Solaris has socket and networking related functions in two extra libraries
|
|
|
|
target_link_libraries(LibCore PRIVATE nsl socket)
|
|
|
|
endif()
|
2023-08-27 18:57:10 +00:00
|
|
|
if (HAIKU)
|
|
|
|
# Haiku has networking related functions in the network library
|
|
|
|
target_link_libraries(LibCore PRIVATE network)
|
|
|
|
endif()
|
2024-03-18 03:22:27 +00:00
|
|
|
target_link_libraries(LibCore PRIVATE LibURL)
|
2019-07-25 09:56:08 +00:00
|
|
|
|
2022-07-04 14:48:19 +00:00
|
|
|
# LibMain
|
2022-10-13 20:07:09 +00:00
|
|
|
add_serenity_subdirectory(Userland/Libraries/LibMain)
|
2021-11-23 17:34:31 +00:00
|
|
|
|
2023-03-21 15:35:30 +00:00
|
|
|
# LibFileSystem
|
|
|
|
# This is needed even if Lagom is not enabled because it is depended upon by code generators.
|
|
|
|
add_serenity_subdirectory(Userland/Libraries/LibFileSystem)
|
|
|
|
|
2022-07-04 14:48:19 +00:00
|
|
|
# LibTimeZone
|
2021-12-22 21:33:38 +00:00
|
|
|
# This is needed even if Lagom is not enabled because it is depended upon by code generators.
|
2022-10-13 21:54:06 +00:00
|
|
|
add_serenity_subdirectory(Userland/Libraries/LibTimeZone)
|
|
|
|
# We need an install rule for LibTimeZone b/c it is a manual OBJECT library instead of serenity_lib
|
|
|
|
install(TARGETS LibTimeZone EXPORT LagomTargets)
|
2021-12-22 21:33:38 +00:00
|
|
|
|
2022-08-22 13:50:06 +00:00
|
|
|
# LibIDL
|
2022-09-21 17:22:16 +00:00
|
|
|
# This is used by the BindingsGenerator so needs to always be built.
|
2022-10-14 02:14:36 +00:00
|
|
|
add_serenity_subdirectory(Userland/Libraries/LibIDL)
|
2022-08-22 13:50:06 +00:00
|
|
|
|
2023-08-11 13:16:51 +00:00
|
|
|
# LibGUI - only GML
|
|
|
|
# This is used by the GML compiler and therefore always needed.
|
|
|
|
set(LIBGUI_GML_SOURCES
|
|
|
|
GML/Lexer.cpp
|
|
|
|
GML/Parser.cpp
|
|
|
|
)
|
|
|
|
list(TRANSFORM LIBGUI_GML_SOURCES PREPEND "${SERENITY_PROJECT_ROOT}/Userland/Libraries/LibGUI/")
|
|
|
|
lagom_lib(LibGUI_GML gui_gml
|
|
|
|
SOURCES ${LIBGUI_GML_SOURCES}
|
|
|
|
)
|
|
|
|
|
2021-09-07 08:21:36 +00:00
|
|
|
# Manually install AK headers
|
|
|
|
install(
|
|
|
|
DIRECTORY "${SERENITY_PROJECT_ROOT}/AK"
|
|
|
|
COMPONENT Lagom_Development
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
|
|
FILES_MATCHING PATTERN "*.h"
|
|
|
|
)
|
2023-08-08 04:14:22 +00:00
|
|
|
install(FILES
|
|
|
|
${Lagom_BINARY_DIR}/AK/Debug.h
|
|
|
|
COMPONENT Lagom_Development
|
|
|
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/AK"
|
|
|
|
)
|
2021-09-07 08:21:36 +00:00
|
|
|
|
2021-08-08 07:31:23 +00:00
|
|
|
# Code Generators and other host tools
|
2022-10-14 02:14:36 +00:00
|
|
|
if (BUILD_LAGOM_TOOLS)
|
2021-08-08 07:31:23 +00:00
|
|
|
add_subdirectory(Tools)
|
|
|
|
endif()
|
|
|
|
|
2020-05-06 15:40:06 +00:00
|
|
|
if (BUILD_LAGOM)
|
2024-01-30 14:24:31 +00:00
|
|
|
|
|
|
|
# Create lagom equivalent of Serenity's Build/foo/Root/res (which for Serenity becomes /res in the disk image).
|
|
|
|
# FIXME: Add more files as needed.
|
|
|
|
set(LAGOM_RES "${Lagom_BINARY_DIR}/Root/res")
|
|
|
|
file(MAKE_DIRECTORY "${LAGOM_RES}/fonts")
|
|
|
|
foreach(font
|
|
|
|
LiberationMono-Bold.ttf
|
|
|
|
LiberationMono-BoldItalic.ttf
|
|
|
|
LiberationMono-Italic.ttf
|
|
|
|
LiberationMono-Regular.ttf
|
|
|
|
LiberationSans-Bold.ttf
|
|
|
|
LiberationSans-BoldItalic.ttf
|
|
|
|
LiberationSans-Italic.ttf
|
|
|
|
LiberationSans-Regular.ttf
|
|
|
|
LiberationSerif-Bold.ttf
|
|
|
|
LiberationSerif-BoldItalic.ttf
|
|
|
|
LiberationSerif-Italic.ttf
|
|
|
|
LiberationSerif-Regular.ttf
|
|
|
|
)
|
|
|
|
configure_file("${SERENITY_PROJECT_ROOT}/Base/res/fonts/${font}" "${LAGOM_RES}/fonts/${font}" COPYONLY)
|
|
|
|
endforeach()
|
|
|
|
|
2021-07-26 01:37:27 +00:00
|
|
|
# Lagom Libraries
|
2022-10-14 02:14:36 +00:00
|
|
|
set(lagom_standard_libraries
|
2023-10-27 15:14:27 +00:00
|
|
|
AccelGfx
|
2022-10-14 02:14:36 +00:00
|
|
|
Archive
|
|
|
|
Audio
|
|
|
|
Compress
|
|
|
|
Crypto
|
2023-06-17 19:11:06 +00:00
|
|
|
Cpp
|
2024-01-27 15:54:16 +00:00
|
|
|
DeviceTree
|
2022-10-14 02:14:36 +00:00
|
|
|
DNS
|
2023-05-28 18:55:32 +00:00
|
|
|
Diff
|
2022-10-14 02:14:36 +00:00
|
|
|
Gemini
|
|
|
|
Gfx
|
|
|
|
GL
|
2022-08-28 17:23:30 +00:00
|
|
|
GLSL
|
2022-10-14 02:14:36 +00:00
|
|
|
GPU
|
|
|
|
HTTP
|
|
|
|
IMAP
|
2023-09-20 13:19:25 +00:00
|
|
|
ImageDecoderClient
|
2022-10-14 02:14:36 +00:00
|
|
|
IPC
|
2023-10-26 13:18:28 +00:00
|
|
|
JIT
|
2022-10-14 02:14:36 +00:00
|
|
|
JS
|
|
|
|
Line
|
|
|
|
Locale
|
2023-07-02 11:20:23 +00:00
|
|
|
Manual
|
2022-10-14 02:14:36 +00:00
|
|
|
Markdown
|
|
|
|
PDF
|
2023-08-01 20:39:19 +00:00
|
|
|
Protocol
|
2022-10-14 02:14:36 +00:00
|
|
|
Regex
|
2023-10-12 13:02:39 +00:00
|
|
|
RIFF
|
2022-10-14 02:14:36 +00:00
|
|
|
SoftGPU
|
|
|
|
SQL
|
|
|
|
Syntax
|
|
|
|
TextCodec
|
|
|
|
Threading
|
|
|
|
TLS
|
|
|
|
Video
|
|
|
|
Wasm
|
|
|
|
WebSocket
|
|
|
|
XML
|
2021-07-26 01:37:27 +00:00
|
|
|
)
|
|
|
|
|
2023-08-12 16:01:28 +00:00
|
|
|
# These are needed for both LibWeb and LibProtocol.
|
2023-08-30 11:27:45 +00:00
|
|
|
compile_ipc(${SERENITY_PROJECT_ROOT}/Userland/Services/RequestServer/RequestClient.ipc Userland/Services/RequestServer/RequestClientEndpoint.h)
|
|
|
|
compile_ipc(${SERENITY_PROJECT_ROOT}/Userland/Services/RequestServer/RequestServer.ipc Userland/Services/RequestServer/RequestServerEndpoint.h)
|
2023-08-12 16:01:28 +00:00
|
|
|
|
2022-09-12 19:35:54 +00:00
|
|
|
if (ENABLE_LAGOM_LIBWEB)
|
2023-08-30 11:27:45 +00:00
|
|
|
list(APPEND lagom_standard_libraries Web WebView)
|
2023-08-26 17:34:59 +00:00
|
|
|
|
2023-08-30 11:27:45 +00:00
|
|
|
compile_ipc(${SERENITY_PROJECT_ROOT}/Userland/Services/WebContent/WebContentServer.ipc Userland/Services/WebContent/WebContentServerEndpoint.h)
|
|
|
|
compile_ipc(${SERENITY_PROJECT_ROOT}/Userland/Services/WebContent/WebContentClient.ipc Userland/Services/WebContent/WebContentClientEndpoint.h)
|
|
|
|
compile_ipc(${SERENITY_PROJECT_ROOT}/Userland/Services/WebContent/WebDriverClient.ipc Userland/Services/WebContent/WebDriverClientEndpoint.h)
|
|
|
|
compile_ipc(${SERENITY_PROJECT_ROOT}/Userland/Services/WebContent/WebDriverServer.ipc Userland/Services/WebContent/WebDriverServerEndpoint.h)
|
2022-10-06 12:09:45 +00:00
|
|
|
endif()
|
2022-09-25 10:10:28 +00:00
|
|
|
|
2023-02-25 04:35:31 +00:00
|
|
|
if (NOT EMSCRIPTEN)
|
2024-04-24 20:29:08 +00:00
|
|
|
list(APPEND lagom_standard_libraries ELF X86)
|
2022-01-17 23:54:36 +00:00
|
|
|
endif()
|
2020-11-29 12:49:13 +00:00
|
|
|
|
2022-10-14 02:14:36 +00:00
|
|
|
foreach(lib IN LISTS lagom_standard_libraries)
|
|
|
|
add_serenity_subdirectory("Userland/Libraries/Lib${lib}")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# GUI
|
|
|
|
set(LIBGUI_SOURCES
|
|
|
|
GML/Lexer.cpp
|
|
|
|
GML/Parser.cpp
|
|
|
|
GML/SyntaxHighlighter.cpp
|
|
|
|
Icon.cpp
|
|
|
|
Model.cpp
|
|
|
|
ModelIndex.cpp
|
|
|
|
)
|
|
|
|
list(TRANSFORM LIBGUI_SOURCES PREPEND "${SERENITY_PROJECT_ROOT}/Userland/Libraries/LibGUI/")
|
2022-10-17 05:48:14 +00:00
|
|
|
lagom_lib(LibGUI gui
|
2022-10-14 02:14:36 +00:00
|
|
|
SOURCES ${LIBGUI_SOURCES}
|
2024-01-21 23:24:43 +00:00
|
|
|
LIBS LibCore LibGfx LibSyntax)
|
2022-10-14 02:14:36 +00:00
|
|
|
|
2023-08-08 04:14:22 +00:00
|
|
|
# FIXME: How about we don't include Kernel/API from random high-level libraries?
|
|
|
|
install(FILES ${SERENITY_PROJECT_ROOT}/Kernel/API/KeyCode.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/Kernel/API")
|
|
|
|
|
2022-10-21 19:43:56 +00:00
|
|
|
target_link_libraries(LibLocale PRIVATE LibTimeZone)
|
2022-10-14 02:14:36 +00:00
|
|
|
|
|
|
|
add_serenity_subdirectory(Userland/Shell)
|
2022-03-26 17:02:57 +00:00
|
|
|
|
2024-02-27 13:32:29 +00:00
|
|
|
if (NOT ENABLE_FUZZERS AND NOT ENABLE_COMPILER_EXPLORER_BUILD AND NOT ANDROID AND NOT IOS)
|
2022-07-04 16:08:01 +00:00
|
|
|
# Lagom Services
|
2022-10-14 02:14:36 +00:00
|
|
|
add_serenity_subdirectory(Userland/Services)
|
2022-07-04 16:08:01 +00:00
|
|
|
|
2021-07-26 01:37:27 +00:00
|
|
|
# Lagom Utilities
|
2024-01-21 23:22:51 +00:00
|
|
|
lagom_utility(abench SOURCES ../../Userland/Utilities/abench.cpp LIBS LibMain LibFileSystem LibAudio)
|
|
|
|
lagom_utility(aconv SOURCES ../../Userland/Utilities/aconv.cpp LIBS LibMain LibFileSystem LibAudio)
|
2023-05-01 19:14:44 +00:00
|
|
|
|
2022-11-20 03:23:14 +00:00
|
|
|
if (NOT EMSCRIPTEN)
|
2024-01-21 23:22:51 +00:00
|
|
|
lagom_utility(adjtime SOURCES ../../Userland/Utilities/adjtime.cpp LIBS LibMain)
|
2022-11-20 03:23:14 +00:00
|
|
|
endif()
|
2021-07-26 01:37:27 +00:00
|
|
|
|
LibGfx+Utilities: Add `animation` utility, make it write animated webps
The high-level design is that we have a static method on WebPWriter that
returns an AnimationWriter object. AnimationWriter has a virtual method
for writing individual frames. This allows streaming animations to disk,
without having to buffer up the entire animation in memory first.
The semantics of this function, add_frame(), are that data is flushed
to disk every time the function is called, so that no explicit `close()`
method is needed.
For some formats that store animation length at the start of the file,
including WebP, this means that this needs to write to a SeekableStream,
so that add_frame() can seek to the start and update the size when a
frame is written.
This design should work for GIF and APNG writing as well. We can move
AnimationWriter to a new header if we add writers for these.
Currently, `animation` can read any animated image format we can read
(apng, gif, webp) and convert it to an animated webp file.
The written animated webp file is not compressed whatsoever, so this
creates large output files at the moment.
2024-05-06 21:44:57 +00:00
|
|
|
lagom_utility(animation SOURCES ../../Userland/Utilities/animation.cpp LIBS LibGfx LibMain)
|
2024-03-20 15:10:50 +00:00
|
|
|
lagom_utility(base64 SOURCES ../../Userland/Utilities/base64.cpp LIBS LibMain)
|
|
|
|
|
2023-02-25 04:36:02 +00:00
|
|
|
if (NOT EMSCRIPTEN)
|
2024-04-24 20:29:08 +00:00
|
|
|
lagom_utility(disasm SOURCES ../../Userland/Utilities/disasm.cpp LIBS LibELF LibX86 LibMain)
|
2024-01-21 23:22:51 +00:00
|
|
|
lagom_utility(file SOURCES ../../Userland/Utilities/file.cpp LIBS LibAudio LibArchive LibCompress LibELF LibGfx LibIPC LibMain)
|
2023-02-25 04:36:02 +00:00
|
|
|
endif()
|
|
|
|
|
2024-01-21 23:22:51 +00:00
|
|
|
lagom_utility(gml-format SOURCES ../../Userland/Utilities/gml-format.cpp LIBS LibGUI LibMain)
|
|
|
|
lagom_utility(gzip SOURCES ../../Userland/Utilities/gzip.cpp LIBS LibCompress LibMain)
|
2023-03-25 17:04:22 +00:00
|
|
|
|
2023-11-10 08:09:55 +00:00
|
|
|
# Work around bug in JetBrains distributed CMake 3.27.2 where this causes infinite recursion in
|
|
|
|
# export_components() when called from CLion Nova by checking if we already have Ladybird included
|
|
|
|
# This technically breaks people including Lagom as a submodule and wanting Ladybird targets, but... who? why?
|
|
|
|
if (ENABLE_LAGOM_LADYBIRD AND PROJECT_IS_TOP_LEVEL)
|
2023-02-02 10:57:06 +00:00
|
|
|
add_serenity_subdirectory(Ladybird)
|
|
|
|
endif()
|
|
|
|
|
2023-09-29 23:59:22 +00:00
|
|
|
if (APPLE)
|
|
|
|
add_serenity_subdirectory(Meta/Lagom/Contrib/MacPDF)
|
|
|
|
endif()
|
|
|
|
|
2023-11-28 03:00:43 +00:00
|
|
|
find_package(SDL2 QUIET)
|
|
|
|
if (SDL2_FOUND)
|
2023-11-20 14:05:58 +00:00
|
|
|
add_serenity_subdirectory(Meta/Lagom/Contrib/VideoPlayerSDL)
|
|
|
|
endif()
|
|
|
|
|
2024-03-18 03:22:27 +00:00
|
|
|
lagom_utility(icc SOURCES ../../Userland/Utilities/icc.cpp LIBS LibGfx LibMain LibURL)
|
2024-01-21 23:22:51 +00:00
|
|
|
lagom_utility(image SOURCES ../../Userland/Utilities/image.cpp LIBS LibGfx LibMain)
|
|
|
|
lagom_utility(isobmff SOURCES ../../Userland/Utilities/isobmff.cpp LIBS LibGfx LibMain)
|
|
|
|
lagom_utility(ttfdisasm SOURCES ../../Userland/Utilities/ttfdisasm.cpp LIBS LibGfx LibMain)
|
|
|
|
lagom_utility(js SOURCES ../../Userland/Utilities/js.cpp LIBS LibCrypto LibJS LibLine LibLocale LibMain LibTextCodec Threads::Threads)
|
2023-02-18 23:46:27 +00:00
|
|
|
|
2022-11-20 03:23:41 +00:00
|
|
|
if (EMSCRIPTEN)
|
2024-01-21 23:24:43 +00:00
|
|
|
lagom_utility(libjs SOURCES Wasm/js_repl.cpp LIBS LibJS LibLocale LibTimeZone LibUnicode)
|
2022-11-20 03:23:41 +00:00
|
|
|
target_link_options(libjs PRIVATE
|
|
|
|
-sEXPORTED_FUNCTIONS=_initialize_repl,_execute
|
|
|
|
-sEXPORTED_RUNTIME_METHODS=allocateUTF8
|
|
|
|
-sERROR_ON_UNDEFINED_SYMBOLS=0
|
|
|
|
-sENVIRONMENT=web)
|
|
|
|
endif()
|
2020-11-27 22:57:02 +00:00
|
|
|
|
2024-01-21 23:22:51 +00:00
|
|
|
lagom_utility(lzcat SOURCES ../../Userland/Utilities/lzcat.cpp LIBS LibCompress LibMain)
|
2024-03-18 03:22:27 +00:00
|
|
|
lagom_utility(markdown-check SOURCES ../../Userland/Utilities/markdown-check.cpp LIBS LibFileSystem LibMarkdown LibMain LibManual LibURL)
|
2024-01-14 09:39:30 +00:00
|
|
|
lagom_utility(mkfs.fat SOURCES ../../Userland/Utilities/mkfs.fat.cpp LIBS LibFileSystem LibMain)
|
2021-09-10 19:37:42 +00:00
|
|
|
|
2022-11-20 03:23:14 +00:00
|
|
|
if (NOT EMSCRIPTEN)
|
2024-01-21 23:22:51 +00:00
|
|
|
lagom_utility(ntpquery SOURCES ../../Userland/Utilities/ntpquery.cpp LIBS LibMain)
|
2022-11-20 03:23:14 +00:00
|
|
|
endif()
|
2021-07-26 01:37:27 +00:00
|
|
|
|
2024-01-21 23:22:51 +00:00
|
|
|
lagom_utility(pdf SOURCES ../../Userland/Utilities/pdf.cpp LIBS LibGfx LibPDF LibMain)
|
|
|
|
lagom_utility(sql SOURCES ../../Userland/Utilities/sql.cpp LIBS LibFileSystem LibIPC LibLine LibMain LibSQL)
|
|
|
|
lagom_utility(tar SOURCES ../../Userland/Utilities/tar.cpp LIBS LibArchive LibCompress LibFileSystem LibMain)
|
|
|
|
lagom_utility(test262-runner SOURCES ../../Tests/LibJS/test262-runner.cpp LIBS LibJS LibFileSystem)
|
2022-09-11 07:14:32 +00:00
|
|
|
|
2022-12-18 16:07:15 +00:00
|
|
|
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
|
|
include(CheckCSourceCompiles)
|
|
|
|
# Check for musl's declaration of __assert_fail
|
|
|
|
check_c_source_compiles(
|
|
|
|
"
|
|
|
|
#include <assert.h>
|
|
|
|
__attribute__((__noreturn__)) void __assert_fail(char const* assertion, char const* file, int line, char const* function) {}
|
|
|
|
int main() {}
|
|
|
|
"
|
|
|
|
ASSERT_FAIL_HAS_INT
|
|
|
|
)
|
|
|
|
endif()
|
2024-01-21 23:22:51 +00:00
|
|
|
|
2022-12-18 16:07:15 +00:00
|
|
|
if (ASSERT_FAIL_HAS_INT OR EMSCRIPTEN)
|
|
|
|
target_compile_definitions(test262-runner PRIVATE ASSERT_FAIL_HAS_INT)
|
|
|
|
endif()
|
|
|
|
|
2024-01-21 23:22:51 +00:00
|
|
|
lagom_utility(wasm SOURCES ../../Userland/Utilities/wasm.cpp LIBS LibFileSystem LibWasm LibLine LibMain LibJS)
|
2024-03-18 03:22:27 +00:00
|
|
|
lagom_utility(xml SOURCES ../../Userland/Utilities/xml.cpp LIBS LibFileSystem LibMain LibXML LibURL)
|
2024-01-21 23:22:51 +00:00
|
|
|
lagom_utility(xzcat SOURCES ../../Userland/Utilities/xzcat.cpp LIBS LibCompress LibMain)
|
2024-01-27 15:54:16 +00:00
|
|
|
lagom_utility(fdtdump SOURCES ../../Userland/Utilities/fdtdump.cpp LIBS LibDeviceTree LibMain)
|
2023-03-28 23:38:54 +00:00
|
|
|
|
2021-07-26 01:37:27 +00:00
|
|
|
enable_testing()
|
|
|
|
# LibTest
|
|
|
|
file(GLOB LIBTEST_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibTest/*.cpp")
|
|
|
|
list(FILTER LIBTEST_SOURCES EXCLUDE REGEX ".*Main.cpp$")
|
|
|
|
add_library(
|
2022-07-04 14:48:19 +00:00
|
|
|
LibTest
|
2021-07-26 01:37:27 +00:00
|
|
|
${LIBTEST_SOURCES}
|
|
|
|
)
|
2024-01-21 23:24:43 +00:00
|
|
|
target_link_libraries(LibTest PRIVATE AK LibCore LibFileSystem)
|
2022-07-04 14:48:19 +00:00
|
|
|
set_target_properties(LibTest PROPERTIES OUTPUT_NAME lagom-test)
|
2021-07-26 01:37:27 +00:00
|
|
|
add_library(
|
2022-07-04 14:48:19 +00:00
|
|
|
LibTestMain
|
2021-07-26 01:37:27 +00:00
|
|
|
OBJECT
|
|
|
|
"${SERENITY_PROJECT_ROOT}/Userland/Libraries/LibTest/TestMain.cpp"
|
|
|
|
)
|
2024-04-16 01:50:49 +00:00
|
|
|
target_link_libraries(LibTest PUBLIC GenericClangPlugin)
|
|
|
|
target_link_libraries(LibTestMain PUBLIC GenericClangPlugin)
|
2021-07-26 01:37:27 +00:00
|
|
|
|
|
|
|
# LibTest tests from Tests/
|
2023-01-16 15:35:40 +00:00
|
|
|
set(TEST_DIRECTORIES
|
|
|
|
AK
|
2023-10-27 06:00:08 +00:00
|
|
|
JSSpecCompiler
|
2023-01-16 15:35:40 +00:00
|
|
|
LibCrypto
|
|
|
|
LibCompress
|
|
|
|
LibGL
|
2023-01-31 19:00:43 +00:00
|
|
|
LibGfx
|
2023-07-31 16:47:17 +00:00
|
|
|
LibIMAP
|
2023-01-16 15:35:40 +00:00
|
|
|
LibLocale
|
|
|
|
LibMarkdown
|
|
|
|
LibPDF
|
|
|
|
LibSQL
|
2023-10-23 23:47:26 +00:00
|
|
|
LibTest
|
2023-01-16 15:35:40 +00:00
|
|
|
LibTextCodec
|
|
|
|
LibTTF
|
|
|
|
LibTimeZone
|
|
|
|
LibUnicode
|
|
|
|
LibVideo
|
2023-07-23 04:14:21 +00:00
|
|
|
LibXML
|
2023-01-16 15:35:40 +00:00
|
|
|
)
|
|
|
|
if (ENABLE_LAGOM_LIBWEB)
|
|
|
|
list(APPEND TEST_DIRECTORIES LibWeb)
|
2023-11-24 15:51:35 +00:00
|
|
|
list(APPEND TEST_DIRECTORIES LibWebView)
|
2023-01-16 15:35:40 +00:00
|
|
|
endif()
|
2024-04-22 03:26:15 +00:00
|
|
|
if (LINUX)
|
|
|
|
list(APPEND TEST_DIRECTORIES LibELF)
|
|
|
|
endif()
|
2024-04-16 01:50:49 +00:00
|
|
|
if (ENABLE_CLANG_PLUGINS AND CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
|
|
|
|
list(APPEND TEST_DIRECTORIES ClangPlugins)
|
|
|
|
endif()
|
2021-07-26 01:37:27 +00:00
|
|
|
|
2023-01-16 15:35:40 +00:00
|
|
|
foreach (dir IN LISTS TEST_DIRECTORIES)
|
|
|
|
add_serenity_subdirectory("Tests/${dir}")
|
2022-07-25 11:28:16 +00:00
|
|
|
endforeach()
|
|
|
|
|
2023-03-14 13:12:58 +00:00
|
|
|
# LibTLS needs a special working directory to find cacert.pem
|
|
|
|
lagom_test(../../Tests/LibTLS/TestTLSHandshake.cpp LibTLS LIBS LibTLS LibCrypto)
|
2024-03-15 03:55:47 +00:00
|
|
|
lagom_test(../../Tests/LibTLS/TestTLSCertificateParser.cpp LibTLS LIBS LibTLS LibCrypto)
|
2023-03-14 13:12:58 +00:00
|
|
|
|
2023-03-14 18:52:16 +00:00
|
|
|
# The FLAC tests need a special working directory to find the test files
|
|
|
|
lagom_test(../../Tests/LibAudio/TestFLACSpec.cpp LIBS LibAudio WORKING_DIRECTORY "${FLAC_TEST_PATH}/..")
|
|
|
|
|
2023-08-06 06:59:47 +00:00
|
|
|
lagom_test(../../Tests/LibAudio/TestPlaybackStream.cpp LIBS LibAudio)
|
|
|
|
if (HAVE_PULSEAUDIO)
|
|
|
|
target_compile_definitions(TestPlaybackStream PRIVATE HAVE_PULSEAUDIO=1)
|
|
|
|
endif()
|
|
|
|
|
2022-07-04 14:48:19 +00:00
|
|
|
# LibCore
|
2024-02-05 20:47:09 +00:00
|
|
|
lagom_test(../../Tests/LibCore/TestLibCoreArgsParser.cpp)
|
|
|
|
|
2023-01-18 19:03:14 +00:00
|
|
|
if ((LINUX OR APPLE) AND NOT EMSCRIPTEN)
|
2023-01-17 19:43:36 +00:00
|
|
|
lagom_test(../../Tests/LibCore/TestLibCoreFileWatcher.cpp)
|
2023-07-12 01:48:56 +00:00
|
|
|
lagom_test(../../Tests/LibCore/TestLibCorePromise.cpp LIBS LibThreading)
|
2023-01-17 19:43:36 +00:00
|
|
|
endif()
|
|
|
|
|
2023-11-07 01:50:11 +00:00
|
|
|
lagom_test(../../Tests/LibCore/TestLibCoreDateTime.cpp LIBS LibTimeZone)
|
|
|
|
|
2021-07-26 01:37:27 +00:00
|
|
|
# RegexLibC test POSIX <regex.h> and contains many Serenity extensions
|
2023-01-16 15:35:40 +00:00
|
|
|
# It is therefore not reasonable to run it on Lagom, and we only run the Regex test
|
|
|
|
lagom_test(../../Tests/LibRegex/Regex.cpp LIBS LibRegex WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../Tests/LibRegex)
|
2023-01-09 21:29:39 +00:00
|
|
|
|
2024-01-14 02:36:30 +00:00
|
|
|
# test-jpeg-roundtrip
|
|
|
|
add_executable(test-jpeg-roundtrip
|
|
|
|
../../Userland/Utilities/test-jpeg-roundtrip.cpp)
|
2024-01-21 23:24:43 +00:00
|
|
|
target_link_libraries(test-jpeg-roundtrip AK LibGfx LibMain)
|
2024-01-14 02:36:30 +00:00
|
|
|
|
2021-07-26 01:37:27 +00:00
|
|
|
# JavaScriptTestRunner + LibTest tests
|
|
|
|
# test-js
|
2022-10-14 02:34:34 +00:00
|
|
|
add_executable(test-js
|
2021-05-18 14:15:12 +00:00
|
|
|
../../Tests/LibJS/test-js.cpp
|
|
|
|
../../Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp)
|
2024-01-21 23:24:43 +00:00
|
|
|
target_link_libraries(test-js AK LibCore LibFileSystem LibTest LibJS)
|
2021-02-28 22:06:42 +00:00
|
|
|
add_test(
|
|
|
|
NAME JS
|
2022-10-14 02:34:34 +00:00
|
|
|
COMMAND test-js --show-progress=false
|
2020-06-25 12:45:23 +00:00
|
|
|
)
|
2021-07-26 01:37:27 +00:00
|
|
|
set_tests_properties(JS PROPERTIES ENVIRONMENT SERENITY_SOURCE_DIR=${SERENITY_PROJECT_ROOT})
|
2020-11-27 22:57:02 +00:00
|
|
|
|
2022-01-22 13:27:53 +00:00
|
|
|
# Extra tests from Tests/LibJS
|
2022-07-04 14:48:19 +00:00
|
|
|
lagom_test(../../Tests/LibJS/test-invalid-unicode-js.cpp LIBS LibJS)
|
2022-09-06 23:14:23 +00:00
|
|
|
lagom_test(../../Tests/LibJS/test-value-js.cpp LIBS LibJS)
|
2021-10-03 11:10:35 +00:00
|
|
|
|
2022-02-22 04:19:04 +00:00
|
|
|
# Spreadsheet
|
2022-10-14 02:34:34 +00:00
|
|
|
add_executable(test-spreadsheet
|
2022-02-22 04:19:04 +00:00
|
|
|
../../Tests/Spreadsheet/test-spreadsheet.cpp
|
|
|
|
../../Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp)
|
2024-01-21 23:24:43 +00:00
|
|
|
target_link_libraries(test-spreadsheet AK LibCore LibFileSystem LibTest LibJS)
|
2022-02-22 04:19:04 +00:00
|
|
|
add_test(
|
|
|
|
NAME Spreadsheet
|
2022-10-14 02:34:34 +00:00
|
|
|
COMMAND test-spreadsheet --show-progress=false
|
2022-02-22 04:19:04 +00:00
|
|
|
)
|
|
|
|
set_tests_properties(Spreadsheet PROPERTIES ENVIRONMENT SERENITY_SOURCE_DIR=${SERENITY_PROJECT_ROOT})
|
|
|
|
|
2021-07-26 01:37:27 +00:00
|
|
|
# test-wasm
|
2022-10-14 02:34:34 +00:00
|
|
|
add_executable(test-wasm
|
2021-05-04 03:06:59 +00:00
|
|
|
../../Tests/LibWasm/test-wasm.cpp
|
|
|
|
../../Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp)
|
2024-01-21 23:24:43 +00:00
|
|
|
target_link_libraries(test-wasm AK LibCore LibFileSystem LibTest LibWasm LibJS LibCrypto)
|
2021-05-04 03:06:59 +00:00
|
|
|
add_test(
|
|
|
|
NAME WasmParser
|
2023-02-23 00:31:35 +00:00
|
|
|
COMMAND test-wasm --show-progress=false ${CMAKE_CURRENT_BINARY_DIR}/Userland/Libraries/LibWasm/Tests
|
|
|
|
)
|
|
|
|
set_tests_properties(WasmParser PROPERTIES
|
|
|
|
SKIP_RETURN_CODE 1
|
|
|
|
ENVIRONMENT SERENITY_SOURCE_DIR=${SERENITY_PROJECT_ROOT}
|
2021-05-04 03:06:59 +00:00
|
|
|
)
|
|
|
|
|
2021-07-26 01:37:27 +00:00
|
|
|
# Tests that are not LibTest based
|
|
|
|
# Shell
|
|
|
|
file(GLOB SHELL_TESTS CONFIGURE_DEPENDS "../../Userland/Shell/Tests/*.sh")
|
2020-11-27 22:57:02 +00:00
|
|
|
foreach(TEST_PATH ${SHELL_TESTS})
|
|
|
|
get_filename_component(TEST_NAME ${TEST_PATH} NAME_WE)
|
|
|
|
add_test(
|
|
|
|
NAME "Shell-${TEST_NAME}"
|
2022-10-14 02:14:36 +00:00
|
|
|
COMMAND Shell --skip-shellrc "${TEST_PATH}"
|
2021-07-26 01:37:27 +00:00
|
|
|
WORKING_DIRECTORY ${SERENITY_PROJECT_ROOT}/Userland/Shell/Tests
|
2020-11-27 22:57:02 +00:00
|
|
|
)
|
2021-01-18 06:38:30 +00:00
|
|
|
set_tests_properties("Shell-${TEST_NAME}" PROPERTIES
|
|
|
|
TIMEOUT 10
|
|
|
|
FAIL_REGULAR_EXPRESSION "FAIL"
|
2021-02-27 11:36:11 +00:00
|
|
|
PASS_REGULAR_EXPRESSION "PASS"
|
|
|
|
)
|
2020-11-27 22:57:02 +00:00
|
|
|
endforeach()
|
2022-02-08 16:11:03 +00:00
|
|
|
|
|
|
|
# FIXME: When we are using CMake >= 3.21, the library installations can be replaced with RUNTIME_DEPENDENCIES.
|
|
|
|
# https://cmake.org/cmake/help/latest/command/install.html
|
|
|
|
include(get_linked_lagom_libraries.cmake)
|
2022-10-14 02:34:34 +00:00
|
|
|
get_linked_lagom_libraries(js js_libraries)
|
2022-02-08 16:11:03 +00:00
|
|
|
|
2022-10-14 02:34:34 +00:00
|
|
|
install(TARGETS js ${js_libraries} COMPONENT js)
|
2022-02-08 16:11:03 +00:00
|
|
|
|
|
|
|
set(CPACK_GENERATOR "TGZ")
|
|
|
|
set(CPACK_STRIP_FILES TRUE)
|
|
|
|
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
|
|
|
|
set(CPACK_COMPONENTS_ALL js)
|
2022-12-01 09:08:12 +00:00
|
|
|
if (APPLE)
|
|
|
|
if("arm64" IN_LIST CMAKE_OSX_ARCHITECTURES AND "x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES)
|
|
|
|
set(CPACK_SYSTEM_NAME "macOS-universal2")
|
2022-12-05 21:49:32 +00:00
|
|
|
else()
|
2022-12-01 09:08:12 +00:00
|
|
|
set(CPACK_SYSTEM_NAME "macOS-${CMAKE_SYSTEM_PROCESSOR}")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CPACK_ARCHIVE_JS_FILE_NAME "serenity-js-${CPACK_SYSTEM_NAME}")
|
|
|
|
set(CPACK_PACKAGE_FILE_NAME "serenity-js-${CPACK_SYSTEM_NAME}")
|
2022-02-08 16:11:03 +00:00
|
|
|
include(CPack)
|
2020-11-27 22:57:02 +00:00
|
|
|
endif()
|
2020-05-06 15:40:06 +00:00
|
|
|
endif()
|
2020-04-11 11:16:17 +00:00
|
|
|
|
2022-03-21 10:36:41 +00:00
|
|
|
if (ENABLE_FUZZERS)
|
2020-04-08 08:40:02 +00:00
|
|
|
add_subdirectory(Fuzzers)
|
2022-07-04 16:08:01 +00:00
|
|
|
else()
|
|
|
|
export_components("${CMAKE_BINARY_DIR}/components.ini")
|
2020-04-08 08:40:02 +00:00
|
|
|
endif()
|
2023-01-25 19:46:44 +00:00
|
|
|
|
|
|
|
if (NOT "$ENV{LAGOM_TARGET}" STREQUAL "")
|
|
|
|
add_custom_target(run-lagom-target
|
2023-02-01 13:42:31 +00:00
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
2023-03-18 15:23:35 +00:00
|
|
|
-E env "SERENITY_SOURCE_DIR=${SERENITY_PROJECT_ROOT}" "$<TARGET_FILE:$ENV{LAGOM_TARGET}>"
|
|
|
|
$ENV{LAGOM_ARGS}
|
2023-02-01 13:42:31 +00:00
|
|
|
|
2023-02-01 13:36:15 +00:00
|
|
|
WORKING_DIRECTORY "$<TARGET_PROPERTY:$ENV{LAGOM_TARGET},LAGOM_WORKING_DIRECTORY>"
|
2023-01-25 19:46:44 +00:00
|
|
|
DEPENDS "$<TARGET_FILE:$ENV{LAGOM_TARGET}>"
|
|
|
|
USES_TERMINAL
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
endif()
|
2023-03-14 13:12:58 +00:00
|
|
|
|
|
|
|
include(ca_certificates_data)
|