2020-05-15 07:52:37 +00:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
|
|
|
project(SerenityOS C CXX ASM)
|
2020-05-06 15:40:06 +00:00
|
|
|
|
2020-06-06 01:23:31 +00:00
|
|
|
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "")
|
2021-05-13 11:15:35 +00:00
|
|
|
message(FATAL_ERROR
|
2020-06-06 01:23:31 +00:00
|
|
|
": Don't use CMAKE_BUILD_TYPE when building serenity.\n"
|
|
|
|
"The default build type is optimized with debug info and asserts enabled,\n"
|
|
|
|
"and that's all there is.")
|
|
|
|
endif()
|
|
|
|
|
2021-05-31 08:18:22 +00:00
|
|
|
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.2)
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"A GCC version less than 10.2 was detected (${CMAKE_CXX_COMPILER_VERSION}), this is unsupported.\n"
|
|
|
|
"Please re-read the build instructions documentation, and upgrade your host compiler.\n")
|
|
|
|
endif()
|
|
|
|
|
2020-06-19 14:52:39 +00:00
|
|
|
set(CMAKE_INSTALL_MESSAGE NEVER)
|
|
|
|
|
2020-05-06 15:40:06 +00:00
|
|
|
enable_testing()
|
|
|
|
|
2020-11-11 22:59:06 +00:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2020-12-29 03:38:52 +00:00
|
|
|
set(SERENITY_ARCH "i686" CACHE STRING "Target architecture for SerenityOS.")
|
|
|
|
|
2021-01-01 10:26:52 +00:00
|
|
|
# Central location for all custom options used in the Serenity build.
|
2021-02-23 17:14:04 +00:00
|
|
|
option(ENABLE_ADDRESS_SANITIZER "Enable address sanitizer testing in gcc/clang" OFF)
|
|
|
|
option(ENABLE_KERNEL_ADDRESS_SANITIZER "Enable kernel address sanitizer testing in gcc/clang" OFF)
|
|
|
|
option(ENABLE_MEMORY_SANITIZER "Enable memory sanitizer testing in gcc/clang" OFF)
|
|
|
|
option(ENABLE_UNDEFINED_SANITIZER "Enable undefined behavior sanitizer testing in gcc/clang" OFF)
|
|
|
|
option(ENABLE_FUZZER_SANITIZER "Enable fuzzer sanitizer testing in clang" OFF)
|
2021-05-23 20:20:22 +00:00
|
|
|
option(ENABLE_EXTRA_KERNEL_DEBUG_SYMBOLS "Enable -Og and -ggdb3 options for Kernel code for easier debugging" OFF)
|
2021-02-23 17:14:04 +00:00
|
|
|
option(ENABLE_ALL_THE_DEBUG_MACROS "Enable all debug macros to validate they still compile" OFF)
|
2021-05-23 21:33:52 +00:00
|
|
|
option(ENABLE_ALL_DEBUG_FACILITIES "Enable all noisy debug symbols and options. Not recommended for normal developer use" OFF)
|
2021-03-03 22:29:37 +00:00
|
|
|
option(ENABLE_COMPILETIME_FORMAT_CHECK "Enable compiletime format string checks" ON)
|
|
|
|
option(ENABLE_PCI_IDS_DOWNLOAD "Enable download of the pci.ids database at build time" ON)
|
2021-06-09 14:24:04 +00:00
|
|
|
option(ENABLE_USB_IDS_DOWNLOAD "Enable download of the usb.ids database at build time" ON)
|
2021-02-23 17:14:04 +00:00
|
|
|
option(BUILD_LAGOM "Build parts of the system targeting the host OS for fuzzing/testing" OFF)
|
2021-04-29 13:25:31 +00:00
|
|
|
option(ENABLE_KERNEL_LTO "Build the kernel with link-time optimization" OFF)
|
2021-05-26 18:34:52 +00:00
|
|
|
|
|
|
|
include(Meta/CMake/wasm_spec_tests.cmake)
|
2021-01-01 10:19:48 +00:00
|
|
|
|
2020-05-06 15:40:06 +00:00
|
|
|
add_custom_target(run
|
2021-06-24 10:52:27 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_ARCH=${SERENITY_ARCH}" ${CMAKE_SOURCE_DIR}/Meta/run.sh
|
2020-05-06 15:40:06 +00:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2021-02-14 23:59:20 +00:00
|
|
|
# This can currently only be implemented by ordered commands
|
|
|
|
# as cmake doesn't support inter dependency ordering, and we
|
|
|
|
# would like to avoid inject dependencies on the existing
|
|
|
|
# custom commands to allow people to run commands adhoc with
|
|
|
|
# out forcing re-builds when they might not want them.
|
|
|
|
add_custom_target(setup-and-run
|
|
|
|
COMMAND ${CMAKE_MAKE_PROGRAM} install
|
|
|
|
COMMAND ${CMAKE_MAKE_PROGRAM} image
|
|
|
|
COMMAND ${CMAKE_MAKE_PROGRAM} run
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2020-06-20 01:04:42 +00:00
|
|
|
add_custom_target(image
|
|
|
|
DEPENDS qemu-image
|
|
|
|
)
|
|
|
|
add_custom_target(qemu-image
|
2021-04-20 00:51:04 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_SOURCE_DIR=${CMAKE_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" ${CMAKE_SOURCE_DIR}/Meta/build-image-qemu.sh
|
2020-06-20 01:04:42 +00:00
|
|
|
BYPRODUCTS ${CMAKE_BINARY_DIR}/_disk_image
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
2020-05-26 21:51:18 +00:00
|
|
|
add_custom_target(grub-image
|
2021-04-20 00:51:04 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_SOURCE_DIR=${CMAKE_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" ${CMAKE_SOURCE_DIR}/Meta/build-image-grub.sh
|
2020-05-28 08:08:38 +00:00
|
|
|
BYPRODUCTS ${CMAKE_BINARY_DIR}/grub_disk_image
|
2020-05-26 21:51:18 +00:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
2021-05-08 11:02:36 +00:00
|
|
|
add_custom_target(extlinux-image
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_SOURCE_DIR=${CMAKE_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" ${CMAKE_SOURCE_DIR}/Meta/build-image-extlinux.sh
|
|
|
|
BYPRODUCTS ${CMAKE_BINARY_DIR}/extlinux_disk_image
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
2020-05-26 21:51:18 +00:00
|
|
|
|
2020-05-28 19:06:44 +00:00
|
|
|
add_custom_target(lint-shell-scripts
|
|
|
|
COMMAND ${CMAKE_SOURCE_DIR}/Meta/lint-shell-scripts.sh
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
add_custom_target(check-style
|
|
|
|
COMMAND ${CMAKE_SOURCE_DIR}/Meta/check-style.sh
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2021-04-03 03:53:41 +00:00
|
|
|
add_custom_target(install-ports
|
2021-04-20 00:51:04 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_SOURCE_DIR=${CMAKE_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" ${CMAKE_SOURCE_DIR}/Meta/install-ports-tree.sh
|
2021-04-03 03:53:41 +00:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2021-06-20 12:54:45 +00:00
|
|
|
add_custom_target(configure-components
|
|
|
|
COMMAND ConfigureComponents
|
|
|
|
DEPENDS ConfigureComponents
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2020-12-22 00:47:47 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
2021-04-18 21:35:58 +00:00
|
|
|
add_compile_options(-Wno-literal-suffix)
|
2021-03-28 19:32:28 +00:00
|
|
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
2021-04-18 16:50:53 +00:00
|
|
|
add_compile_options(-fconcepts)
|
2021-04-30 03:04:59 +00:00
|
|
|
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang$")
|
2021-03-28 19:32:28 +00:00
|
|
|
add_compile_options(-Wno-overloaded-virtual -Wno-user-defined-literals)
|
|
|
|
endif()
|
|
|
|
|
2021-05-23 21:33:52 +00:00
|
|
|
if (ENABLE_ALL_DEBUG_FACILITIES)
|
|
|
|
set(ENABLE_ALL_THE_DEBUG_MACROS ON)
|
|
|
|
set(ENABLE_EXTRA_KERNEL_DEBUG_SYMBOLS ON)
|
2021-05-31 09:38:50 +00:00
|
|
|
|
|
|
|
# Immediately finds violations during boot, shouldn't be discoverable
|
|
|
|
# by people who aren't working on fixing issues. Use this check to make
|
|
|
|
# sure this code continues to build instead of all_debug_macros to avoid
|
|
|
|
# people filing bugs.
|
|
|
|
set(KMALLOC_VERIFY_NO_SPINLOCK_HELD ON)
|
2021-05-23 21:33:52 +00:00
|
|
|
endif()
|
|
|
|
|
2021-01-01 10:26:52 +00:00
|
|
|
if (ENABLE_ALL_THE_DEBUG_MACROS)
|
2020-12-23 17:07:22 +00:00
|
|
|
include(${CMAKE_SOURCE_DIR}/Meta/CMake/all_the_debug_macros.cmake)
|
2021-01-01 10:26:52 +00:00
|
|
|
endif(ENABLE_ALL_THE_DEBUG_MACROS)
|
2020-08-26 22:59:36 +00:00
|
|
|
|
2021-01-23 22:29:11 +00:00
|
|
|
configure_file(AK/Debug.h.in AK/Debug.h @ONLY)
|
2021-01-25 15:07:10 +00:00
|
|
|
configure_file(Kernel/Debug.h.in Kernel/Debug.h @ONLY)
|
2021-01-23 22:29:11 +00:00
|
|
|
|
2021-01-12 11:17:30 +00:00
|
|
|
include_directories(Userland/Libraries)
|
2020-05-06 15:40:06 +00:00
|
|
|
include_directories(.)
|
2021-01-23 22:29:11 +00:00
|
|
|
include_directories(${CMAKE_BINARY_DIR})
|
2020-05-06 15:40:06 +00:00
|
|
|
|
|
|
|
add_subdirectory(Meta/Lagom)
|
2021-05-24 01:40:22 +00:00
|
|
|
|
|
|
|
if (ENABLE_UNDEFINED_SANITIZER)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
|
|
|
|
endif()
|
|
|
|
|
2021-01-12 11:18:55 +00:00
|
|
|
add_subdirectory(Userland/DevTools/IPCCompiler)
|
DevTools: Add StateMachineGenerator utility
This program turns a description of a state machine that takes its input
byte-by-byte into C++ code. The state machine is described in a custom
format as specified below:
```
// Comments are started by two slashes, and cause the rest of the line
// to be ignored
@name ExampleStateMachine // sets the name of the generated class
@namespace Test // sets the namespace (optional)
@begin Begin // sets the state the parser will start in
// The rest of the file contains one or more states and an optional
// @anywhere directive. Each of these is a curly bracket delimited set
// of state transitions. State transitions contain a selector, the
// literal "=>" and a (new_state, action) tuple. Examples:
// 0x0a => (Begin, PrintLine)
// [0x00..0x1f] => (_, Warn) // '_' means no change
// [0x41..0x5a] => (BeginWord, _) // '_' means no action
// Rules common to all states. These take precedence over rules in the
// specific states.
@anywhere {
0x0a => (Begin, PrintLine)
[0x00..0x1f] => (_, Warn)
}
Begin {
[0x41..0x5a] => (Word, _)
[0x61..0x7a] => (Word, _)
// For missing values, the transition (_, _) is implied
}
Word {
// The entry action is run when we transition to this state from a
// *different* state. @anywhere can't have this
@entry IncreaseWordCount
0x09 => (Begin, _)
0x20 => (Begin, _)
// The exit action is run before we transition to any *other* state
// from here. @anywhere can't have this
@exit EndOfWord
}
```
The generated code consists of a single class which takes a
`Function<Action, u8>` as a parameter in its constructor. This gets
called whenever an action is to be done. This is because some input
might not produce an action, but others might produce up to 3 (exit,
state transition, entry). The actions allow us to build a more
advanced parser over the simple state machine.
The sole public method, `void advance(u8)`, handles the input
byte-by-byte, managing the state changes and requesting the appropriate
Action from the handler.
Internally, the state transitions are resolved via a lookup table. This
is a bit wasteful for more complex state machines, therefore the
generator is designed to be easily extendable with a switch-based
resolver; only the private `lookup_state_transition` method needs to be
re-implemented.
My goal for this tool is to use it for implementing a standard-compliant
ANSI escape sequence parser for LibVT, as described on
<https://vt100.net/emu/dec_ansi_parser>
2021-05-08 07:53:49 +00:00
|
|
|
add_subdirectory(Userland/DevTools/StateMachineGenerator)
|
2021-01-12 11:17:30 +00:00
|
|
|
add_subdirectory(Userland/Libraries/LibWeb/CodeGenerators)
|
2021-06-20 12:54:45 +00:00
|
|
|
add_subdirectory(Meta/CMake/ConfigureComponents)
|
2020-05-06 15:40:06 +00:00
|
|
|
|
2020-08-02 13:54:06 +00:00
|
|
|
set(write_if_different ${CMAKE_SOURCE_DIR}/Meta/write-only-on-difference.sh)
|
|
|
|
|
2020-05-06 15:40:06 +00:00
|
|
|
find_program(CCACHE_PROGRAM ccache)
|
|
|
|
if(CCACHE_PROGRAM)
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
unset(CMAKE_SYSROOT)
|
|
|
|
set(CMAKE_STAGING_PREFIX ${CMAKE_BINARY_DIR}/Root)
|
|
|
|
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/Root)
|
|
|
|
set(CMAKE_INSTALL_DATAROOTDIR ${CMAKE_BINARY_DIR}/Root/res)
|
|
|
|
|
2021-04-22 14:38:20 +00:00
|
|
|
set(GCC_VERSION 11.1.0)
|
|
|
|
|
2021-02-14 21:49:25 +00:00
|
|
|
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES SerenityOS)
|
|
|
|
message("Good job on building cmake!")
|
|
|
|
else()
|
2021-04-27 07:25:02 +00:00
|
|
|
set(TOOLCHAIN_ROOT ${CMAKE_SOURCE_DIR}/Toolchain/Local/${SERENITY_ARCH}/)
|
|
|
|
set(TOOLCHAIN_PATH ${TOOLCHAIN_ROOT}/bin)
|
2021-02-14 21:49:25 +00:00
|
|
|
set(TOOLCHAIN_PREFIX ${TOOLCHAIN_PATH}/${SERENITY_ARCH}-pc-serenity-)
|
|
|
|
|
|
|
|
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
|
|
|
|
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
|
|
|
|
set(CMAKE_ASM_COMPILER ${TOOLCHAIN_PREFIX}gcc)
|
|
|
|
set(CMAKE_LINKER ${TOOLCHAIN_PREFIX}ld)
|
2021-04-29 13:25:31 +00:00
|
|
|
set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}gcc-ranlib)
|
2021-02-14 21:49:25 +00:00
|
|
|
set(CMAKE_STRIP ${TOOLCHAIN_PREFIX}strip)
|
2021-04-29 13:25:31 +00:00
|
|
|
set(CMAKE_AR ${TOOLCHAIN_PREFIX}gcc-ar)
|
2021-02-14 21:49:25 +00:00
|
|
|
endif()
|
2020-05-06 15:40:06 +00:00
|
|
|
|
2020-07-08 21:57:51 +00:00
|
|
|
foreach(lang ASM C CXX OBJC OBJCXX)
|
|
|
|
unset(CMAKE_${lang}_OSX_COMPATIBILITY_VERSION_FLAG)
|
|
|
|
unset(CMAKE_${lang}_OSX_CURRENT_VERSION_FLAG)
|
|
|
|
unset(CMAKE_${lang}_LINK_FLAGS)
|
|
|
|
unset(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS)
|
|
|
|
unset(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS)
|
|
|
|
unset(CMAKE_SHARED_MODULE_LOADER_${lang}_FLAG )
|
|
|
|
unset(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG)
|
|
|
|
unset(CMAKE_${lang}_SYSROOT_FLAG)
|
2021-01-07 10:39:24 +00:00
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES Darwin)
|
2021-04-29 20:58:05 +00:00
|
|
|
## macOS workaround. Use GNU ld flags for SONAMEs.
|
2021-01-07 10:39:24 +00:00
|
|
|
set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
|
2021-04-29 20:58:05 +00:00
|
|
|
"<CMAKE_${lang}_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <LINK_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
|
|
|
set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-soname,")
|
2021-01-07 10:39:24 +00:00
|
|
|
endif()
|
2020-07-08 21:57:51 +00:00
|
|
|
endforeach()
|
|
|
|
|
2020-12-27 23:04:29 +00:00
|
|
|
set(CMAKE_INSTALL_NAME_TOOL "")
|
2020-07-08 21:57:51 +00:00
|
|
|
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
|
2021-03-19 05:47:23 +00:00
|
|
|
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-shared -Wl,--hash-style=gnu,-z,relro,-z,now,-z,noexecstack")
|
2021-06-28 15:19:18 +00:00
|
|
|
set(CMAKE_CXX_LINK_FLAGS "-Wl,--hash-style=gnu,-z,relro,-z,now,-z,noexecstack,-z,max-page-size=0x1000")
|
2020-07-08 21:57:51 +00:00
|
|
|
|
2021-01-06 23:55:01 +00:00
|
|
|
# We disable it completely because it makes cmake very spammy.
|
2020-12-27 23:04:29 +00:00
|
|
|
# This will need to be revisited when the Loader supports RPATH/RUN_PATH.
|
2021-01-06 23:55:01 +00:00
|
|
|
set(CMAKE_SKIP_RPATH TRUE)
|
2020-12-27 23:04:29 +00:00
|
|
|
|
2021-03-28 14:48:37 +00:00
|
|
|
add_compile_options(-Wformat=2)
|
|
|
|
add_compile_options(-fdiagnostics-color=always)
|
|
|
|
|
|
|
|
if (NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES SerenityOS)
|
2021-03-28 14:43:05 +00:00
|
|
|
# FIXME: Something makes this go crazy and flag unused variables that aren't flagged as such when building with the toolchain.
|
|
|
|
# Disable -Werror for now.
|
2021-03-28 14:48:37 +00:00
|
|
|
add_compile_options(-Werror)
|
2021-03-28 14:43:05 +00:00
|
|
|
endif()
|
|
|
|
|
2021-03-28 14:48:37 +00:00
|
|
|
add_compile_options(-Wall)
|
|
|
|
add_compile_options(-Wextra)
|
|
|
|
|
2021-04-15 07:07:44 +00:00
|
|
|
# The following warnings are sorted by the "base" name (the part excluding the initial Wno or W).
|
2021-03-28 14:48:37 +00:00
|
|
|
add_compile_options(-Wno-address-of-packed-member)
|
2021-04-15 07:07:44 +00:00
|
|
|
add_compile_options(-Wcast-align)
|
2021-03-28 14:48:37 +00:00
|
|
|
add_compile_options(-Wcast-qual)
|
|
|
|
add_compile_options(-Wno-deprecated-copy)
|
2021-04-15 07:07:44 +00:00
|
|
|
add_compile_options(-Wduplicated-cond)
|
2021-04-15 07:36:14 +00:00
|
|
|
add_compile_options(-Wdouble-promotion)
|
2021-03-28 14:48:37 +00:00
|
|
|
add_compile_options(-Wno-expansion-to-defined)
|
2021-04-15 07:07:44 +00:00
|
|
|
add_compile_options(-Wformat=2)
|
2021-03-28 14:48:37 +00:00
|
|
|
add_compile_options(-Wimplicit-fallthrough)
|
2021-04-15 07:07:44 +00:00
|
|
|
add_compile_options(-Wlogical-op)
|
|
|
|
add_compile_options(-Wmisleading-indentation)
|
2021-03-28 14:48:37 +00:00
|
|
|
add_compile_options(-Wmissing-declarations)
|
|
|
|
add_compile_options(-Wno-nonnull-compare)
|
2021-04-15 17:43:29 +00:00
|
|
|
add_compile_options(-Wnon-virtual-dtor)
|
2021-03-28 14:48:37 +00:00
|
|
|
add_compile_options(-Wno-unknown-warning-option)
|
|
|
|
add_compile_options(-Wundef)
|
2021-04-15 07:07:44 +00:00
|
|
|
add_compile_options(-Wunused)
|
2021-03-28 14:48:37 +00:00
|
|
|
add_compile_options(-Wwrite-strings)
|
2021-06-09 15:51:17 +00:00
|
|
|
add_compile_options(-Wno-maybe-uninitialized)
|
2021-03-28 14:48:37 +00:00
|
|
|
|
2020-12-22 01:04:46 +00:00
|
|
|
add_compile_options(-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.)
|
2021-03-28 14:48:37 +00:00
|
|
|
add_compile_options(-fno-exceptions)
|
|
|
|
add_compile_options(-fstack-protector-strong)
|
|
|
|
add_compile_options(-g1)
|
2020-05-06 15:40:06 +00:00
|
|
|
|
2021-02-23 13:15:26 +00:00
|
|
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
|
|
add_compile_options(-fstack-clash-protection)
|
|
|
|
endif()
|
|
|
|
|
2021-07-12 07:31:47 +00:00
|
|
|
add_compile_definitions(SANITIZE_PTRS)
|
2020-12-11 13:44:08 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_STATIC "${CMAKE_CXX_FLAGS} -static")
|
2020-12-20 20:32:10 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pie -fpic")
|
2021-01-01 10:20:55 +00:00
|
|
|
|
2021-02-23 17:14:04 +00:00
|
|
|
if (ENABLE_COMPILETIME_FORMAT_CHECK)
|
|
|
|
add_compile_definitions(ENABLE_COMPILETIME_FORMAT_CHECK)
|
2021-02-08 17:26:28 +00:00
|
|
|
endif()
|
|
|
|
|
2020-05-06 15:40:06 +00:00
|
|
|
add_link_options(--sysroot ${CMAKE_BINARY_DIR}/Root)
|
|
|
|
|
2021-01-12 11:17:30 +00:00
|
|
|
include_directories(Userland/Libraries/LibC)
|
2021-05-01 09:38:19 +00:00
|
|
|
include_directories(Userland/Libraries/LibCrypt)
|
2021-01-12 11:17:30 +00:00
|
|
|
include_directories(Userland/Libraries/LibM)
|
2021-05-01 09:38:19 +00:00
|
|
|
include_directories(Userland/Libraries/LibPthread)
|
2021-02-05 11:16:30 +00:00
|
|
|
include_directories(Userland/Libraries/LibSystem)
|
2021-01-12 11:23:01 +00:00
|
|
|
include_directories(Userland/Services)
|
2021-01-12 10:53:14 +00:00
|
|
|
include_directories(Userland)
|
2020-09-14 10:51:12 +00:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
2021-01-12 11:23:01 +00:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Userland/Services)
|
2021-01-12 11:17:30 +00:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Userland/Libraries)
|
2021-01-12 10:53:14 +00:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Userland)
|
2020-05-06 15:40:06 +00:00
|
|
|
|
2021-05-24 01:40:22 +00:00
|
|
|
# FIXME: vptr sanitizing requires.. intense ABI wrangling of std::type_info
|
|
|
|
# And would be better served by porting ubsan_type_hash_itanium.cpp from compiler-rt
|
|
|
|
# We don't set this along with the original fsanitize=undefined because for host tools, we can rely on
|
|
|
|
# the host's libubsan to provide the ABI-specific vptr type cache.
|
|
|
|
# This is not a problem for the Kernel, because it does not have RTTI enabled :^)
|
|
|
|
if (ENABLE_UNDEFINED_SANITIZER)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize=vptr")
|
|
|
|
endif()
|
|
|
|
|
2021-06-15 13:07:25 +00:00
|
|
|
add_custom_target(components ALL)
|
|
|
|
option(BUILD_EVERYTHING "Build all optional components" ON)
|
|
|
|
|
|
|
|
include(${CMAKE_SOURCE_DIR}/Meta/CMake/utils.cmake)
|
|
|
|
|
|
|
|
serenity_component(
|
|
|
|
Tests
|
|
|
|
RECOMMENDED
|
|
|
|
)
|
|
|
|
|
2020-05-26 18:20:24 +00:00
|
|
|
add_subdirectory(AK)
|
2020-05-06 15:40:06 +00:00
|
|
|
add_subdirectory(Kernel)
|
|
|
|
add_subdirectory(Userland)
|
2021-05-06 08:14:50 +00:00
|
|
|
add_subdirectory(Tests)
|
2021-02-06 23:52:40 +00:00
|
|
|
|
2021-06-15 13:07:25 +00:00
|
|
|
export_components("${CMAKE_BINARY_DIR}/components.ini")
|
|
|
|
|
2021-03-03 22:50:25 +00:00
|
|
|
set(PCI_IDS_GZ_URL https://pci-ids.ucw.cz/v2.2/pci.ids.gz)
|
|
|
|
set(PCI_IDS_GZ_PATH ${CMAKE_BINARY_DIR}/pci.ids.gz)
|
|
|
|
set(PCI_IDS_PATH ${CMAKE_BINARY_DIR}/pci.ids)
|
|
|
|
set(PCI_IDS_INSTALL_PATH ${CMAKE_INSTALL_DATAROOTDIR}/pci.ids)
|
|
|
|
|
|
|
|
if(ENABLE_PCI_IDS_DOWNLOAD AND NOT EXISTS ${PCI_IDS_GZ_PATH})
|
|
|
|
message(STATUS "Downloading PCI ID database from ${PCI_IDS_GZ_URL}...")
|
|
|
|
file(DOWNLOAD ${PCI_IDS_GZ_URL} ${PCI_IDS_GZ_PATH} INACTIVITY_TIMEOUT 10)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(EXISTS ${PCI_IDS_GZ_PATH} AND NOT EXISTS ${PCI_IDS_INSTALL_PATH})
|
|
|
|
message(STATUS "Extracting PCI ID database from ${PCI_IDS_GZ_PATH}...")
|
|
|
|
execute_process(COMMAND gzip -k -d ${PCI_IDS_GZ_PATH})
|
|
|
|
file(MAKE_DIRECTORY ${CMAKE_INSTALL_DATAROOTDIR})
|
|
|
|
file(RENAME ${PCI_IDS_PATH} ${PCI_IDS_INSTALL_PATH})
|
2021-02-06 23:52:40 +00:00
|
|
|
endif()
|
2021-06-09 14:24:04 +00:00
|
|
|
|
|
|
|
set(USB_IDS_GZ_URL http://www.linux-usb.org/usb.ids.gz)
|
|
|
|
set(USB_IDS_GZ_PATH ${CMAKE_BINARY_DIR}/usb.ids.gz)
|
|
|
|
set(USB_IDS_PATH ${CMAKE_BINARY_DIR}/usb.ids)
|
|
|
|
set(USB_IDS_INSTALL_PATH ${CMAKE_INSTALL_DATAROOTDIR}/usb.ids)
|
|
|
|
|
|
|
|
if(ENABLE_USB_IDS_DOWNLOAD AND NOT EXISTS ${USB_IDS_GZ_PATH})
|
|
|
|
message(STATUS "Downloading USB ID database from ${USB_IDS_GZ_URL}...")
|
|
|
|
file(DOWNLOAD ${USB_IDS_GZ_URL} ${USB_IDS_GZ_PATH} INACTIVITY_TIMEOUT 10)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(EXISTS ${USB_IDS_GZ_PATH} AND NOT EXISTS ${USB_IDS_INSTALL_PATH})
|
|
|
|
message(STATUS "Extracting USB ID database from ${USB_IDS_GZ_PATH}...")
|
|
|
|
execute_process(COMMAND gzip -k -d ${USB_IDS_GZ_PATH})
|
|
|
|
file(MAKE_DIRECTORY ${CMAKE_INSTALL_DATAROOTDIR})
|
|
|
|
file(RENAME ${USB_IDS_PATH} ${USB_IDS_INSTALL_PATH})
|
|
|
|
endif()
|