2020-05-15 10:52:37 +03:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
|
|
|
project(SerenityOS C CXX ASM)
|
2020-05-06 18:40:06 +03:00
|
|
|
|
2020-06-06 04:23:31 +03:00
|
|
|
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "")
|
2021-05-13 14:15:35 +03:00
|
|
|
message(FATAL_ERROR
|
2020-06-06 04:23:31 +03: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 11:18:22 +03: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 17:52:39 +03:00
|
|
|
set(CMAKE_INSTALL_MESSAGE NEVER)
|
|
|
|
|
2020-05-06 18:40:06 +03:00
|
|
|
enable_testing()
|
|
|
|
|
2020-11-12 01:59:06 +03:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2020-12-29 06:38:52 +03:00
|
|
|
set(SERENITY_ARCH "i686" CACHE STRING "Target architecture for SerenityOS.")
|
|
|
|
|
2021-07-13 17:43:45 +03:00
|
|
|
if("${SERENITY_ARCH}" STREQUAL "i686")
|
|
|
|
set(SERENITY_CLANG_ARCH "i386")
|
|
|
|
else()
|
|
|
|
set(SERENITY_CLANG_ARCH ${SERENITY_ARCH})
|
|
|
|
endif()
|
|
|
|
|
2021-01-01 13:26:52 +03:00
|
|
|
# Central location for all custom options used in the Serenity build.
|
2021-02-23 20:14:04 +03: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)
|
2021-06-07 02:15:07 +03:00
|
|
|
option(ENABLE_KERNEL_COVERAGE_COLLECTION "Enable KCOV and kernel coverage instrumentation in gcc/clang" OFF)
|
2021-02-23 20:14:04 +03:00
|
|
|
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 23:20:22 +03:00
|
|
|
option(ENABLE_EXTRA_KERNEL_DEBUG_SYMBOLS "Enable -Og and -ggdb3 options for Kernel code for easier debugging" OFF)
|
2021-02-23 20:14:04 +03:00
|
|
|
option(ENABLE_ALL_THE_DEBUG_MACROS "Enable all debug macros to validate they still compile" OFF)
|
2021-05-24 00:33:52 +03:00
|
|
|
option(ENABLE_ALL_DEBUG_FACILITIES "Enable all noisy debug symbols and options. Not recommended for normal developer use" OFF)
|
2021-03-04 01:29:37 +03: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 17:24:04 +03:00
|
|
|
option(ENABLE_USB_IDS_DOWNLOAD "Enable download of the usb.ids database at build time" ON)
|
2021-02-23 20:14:04 +03:00
|
|
|
option(BUILD_LAGOM "Build parts of the system targeting the host OS for fuzzing/testing" OFF)
|
2021-04-29 16:25:31 +03:00
|
|
|
option(ENABLE_KERNEL_LTO "Build the kernel with link-time optimization" OFF)
|
2021-07-13 17:43:45 +03:00
|
|
|
option(USE_CLANG_TOOLCHAIN "Build the kernel with the experimental Clang toolchain" OFF)
|
2021-05-26 21:34:52 +03:00
|
|
|
|
|
|
|
include(Meta/CMake/wasm_spec_tests.cmake)
|
2021-01-01 13:19:48 +03:00
|
|
|
|
2020-05-06 18:40:06 +03:00
|
|
|
add_custom_target(run
|
2021-08-08 03:32:49 +03:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_ARCH=${SERENITY_ARCH}" "${SerenityOS_SOURCE_DIR}/Meta/run.sh"
|
2020-05-06 18:40:06 +03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2021-02-15 02:59:20 +03: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 04:04:42 +03:00
|
|
|
add_custom_target(image
|
|
|
|
DEPENDS qemu-image
|
|
|
|
)
|
2021-07-13 17:43:45 +03:00
|
|
|
|
|
|
|
set(GCC_VERSION 11.2.0)
|
|
|
|
set(LLVM_VERSION 12.0.1)
|
|
|
|
|
2020-06-20 04:04:42 +03:00
|
|
|
add_custom_target(qemu-image
|
2021-08-08 03:32:49 +03:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "USE_CLANG_TOOLCHAIN=$<BOOL:${USE_CLANG_TOOLCHAIN}>" "LLVM_VERSION=${LLVM_VERSION}" "${SerenityOS_SOURCE_DIR}/Meta/build-image-qemu.sh"
|
|
|
|
BYPRODUCTS "${CMAKE_BINARY_DIR}/_disk_image"
|
2020-06-20 04:04:42 +03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
2020-05-27 00:51:18 +03:00
|
|
|
add_custom_target(grub-image
|
2021-08-08 03:32:49 +03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "USE_CLANG_TOOLCHAIN=$<BOOL:${USE_CLANG_TOOLCHAIN}>" "LLVM_VERSION=${LLVM_VERSION}" "${SerenityOS_SOURCE_DIR}/Meta/build-image-grub.sh"
|
2020-05-28 11:08:38 +03:00
|
|
|
BYPRODUCTS ${CMAKE_BINARY_DIR}/grub_disk_image
|
2020-05-27 00:51:18 +03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
2021-05-08 14:02:36 +03:00
|
|
|
add_custom_target(extlinux-image
|
2021-08-08 03:32:49 +03:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "USE_CLANG_TOOLCHAIN=$<BOOL:${USE_CLANG_TOOLCHAIN}>" "LLVM_VERSION=${LLVM_VERSION}" "${SerenityOS_SOURCE_DIR}/Meta/build-image-extlinux.sh"
|
|
|
|
BYPRODUCTS "${CMAKE_BINARY_DIR}/extlinux_disk_image"
|
2021-05-08 14:02:36 +03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
2020-05-27 00:51:18 +03:00
|
|
|
|
2020-05-28 22:06:44 +03:00
|
|
|
add_custom_target(lint-shell-scripts
|
2021-08-08 03:32:49 +03:00
|
|
|
COMMAND "${SerenityOS_SOURCE_DIR}/Meta/lint-shell-scripts.sh"
|
2020-05-28 22:06:44 +03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
add_custom_target(check-style
|
2021-08-08 03:32:49 +03:00
|
|
|
COMMAND "${SerenityOS_SOURCE_DIR}/Meta/check-style.sh"
|
2020-05-28 22:06:44 +03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2021-04-03 06:53:41 +03:00
|
|
|
add_custom_target(install-ports
|
2021-08-08 03:32:49 +03:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "${SerenityOS_SOURCE_DIR}/Meta/install-ports-tree.sh"
|
2021-04-03 06:53:41 +03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2021-06-20 15:54:45 +03:00
|
|
|
add_custom_target(configure-components
|
2021-08-08 03:32:49 +03:00
|
|
|
COMMAND "$<TARGET_FILE:ConfigureComponents>"
|
2021-06-20 15:54:45 +03:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
2021-08-08 03:32:49 +03:00
|
|
|
add_dependencies(configure-components ConfigureComponents)
|
2021-06-20 15:54:45 +03:00
|
|
|
|
2020-12-22 03:47:47 +03:00
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
2021-08-07 22:29:39 +03:00
|
|
|
add_compile_options(-fsized-deallocation)
|
2021-03-28 22:32:28 +03:00
|
|
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
2021-07-12 20:51:19 +03:00
|
|
|
add_compile_options(-Wno-literal-suffix)
|
2021-04-30 06:04:59 +03:00
|
|
|
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang$")
|
2021-07-13 17:43:45 +03:00
|
|
|
add_compile_options(-Wno-overloaded-virtual)
|
|
|
|
add_compile_options(-Wno-user-defined-literals)
|
|
|
|
add_compile_options(-fconstexpr-steps=16777216)
|
2021-03-28 22:32:28 +03:00
|
|
|
endif()
|
|
|
|
|
2021-05-24 00:33:52 +03:00
|
|
|
if (ENABLE_ALL_DEBUG_FACILITIES)
|
|
|
|
set(ENABLE_ALL_THE_DEBUG_MACROS ON)
|
|
|
|
set(ENABLE_EXTRA_KERNEL_DEBUG_SYMBOLS ON)
|
2021-05-31 12:38:50 +03: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-06-07 02:15:07 +03:00
|
|
|
|
|
|
|
# Enables KCOV API and injects kernel coverage instrumentation via
|
|
|
|
# -fsanitize-coverage=trace-pc. Mostly here to ensure that the CI catches
|
|
|
|
# commits breaking this flag.
|
|
|
|
set(ENABLE_KERNEL_COVERAGE_COLLECTION ON)
|
2021-05-24 00:33:52 +03:00
|
|
|
endif()
|
|
|
|
|
2021-01-01 13:26:52 +03:00
|
|
|
if (ENABLE_ALL_THE_DEBUG_MACROS)
|
2021-08-08 03:32:49 +03:00
|
|
|
include("${SerenityOS_SOURCE_DIR}/Meta/CMake/all_the_debug_macros.cmake")
|
2021-01-01 13:26:52 +03:00
|
|
|
endif(ENABLE_ALL_THE_DEBUG_MACROS)
|
2020-08-27 01:59:36 +03:00
|
|
|
|
2021-01-24 01:29:11 +03:00
|
|
|
configure_file(AK/Debug.h.in AK/Debug.h @ONLY)
|
2021-01-25 18:07:10 +03:00
|
|
|
configure_file(Kernel/Debug.h.in Kernel/Debug.h @ONLY)
|
2021-01-24 01:29:11 +03:00
|
|
|
|
2021-01-12 14:17:30 +03:00
|
|
|
include_directories(Userland/Libraries)
|
2020-05-06 18:40:06 +03:00
|
|
|
include_directories(.)
|
2021-01-24 01:29:11 +03:00
|
|
|
include_directories(${CMAKE_BINARY_DIR})
|
2020-05-06 18:40:06 +03:00
|
|
|
|
2021-07-25 22:15:47 +03:00
|
|
|
set(write_if_different ${CMAKE_SOURCE_DIR}/Meta/write-only-on-difference.sh)
|
|
|
|
|
2020-05-06 18:40:06 +03:00
|
|
|
add_subdirectory(Meta/Lagom)
|
2021-05-24 04:40:22 +03:00
|
|
|
|
|
|
|
if (ENABLE_UNDEFINED_SANITIZER)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
|
|
|
|
endif()
|
|
|
|
|
2021-01-12 14:18:55 +03: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 10:53:49 +03:00
|
|
|
add_subdirectory(Userland/DevTools/StateMachineGenerator)
|
2021-07-25 22:10:51 +03:00
|
|
|
add_subdirectory(Userland/Libraries/LibUnicode/CodeGenerators)
|
2021-01-12 14:17:30 +03:00
|
|
|
add_subdirectory(Userland/Libraries/LibWeb/CodeGenerators)
|
2021-06-20 15:54:45 +03:00
|
|
|
add_subdirectory(Meta/CMake/ConfigureComponents)
|
2020-05-06 18:40:06 +03: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 17:38:20 +03:00
|
|
|
|
2021-02-15 00:49:25 +03:00
|
|
|
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES SerenityOS)
|
|
|
|
message("Good job on building cmake!")
|
2021-07-13 17:43:45 +03:00
|
|
|
elseif(USE_CLANG_TOOLCHAIN)
|
|
|
|
set(TOOLCHAIN_ROOT ${CMAKE_SOURCE_DIR}/Toolchain/Local/clang/${SERENITY_ARCH}/)
|
|
|
|
set(TOOLCHAIN_PATH ${TOOLCHAIN_ROOT}/bin)
|
|
|
|
|
|
|
|
set(CMAKE_C_COMPILER ${TOOLCHAIN_PATH}/clang)
|
|
|
|
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PATH}/clang++)
|
|
|
|
set(CMAKE_ASM_COMPILER ${TOOLCHAIN_PATH}/clang)
|
|
|
|
set(CMAKE_LINKER ${TOOLCHAIN_PATH}/ld.lld)
|
|
|
|
set(CMAKE_RANLIB ${TOOLCHAIN_PATH}/llvm-ranlib)
|
|
|
|
set(CMAKE_STRIP ${TOOLCHAIN_PATH}/llvm-strip)
|
|
|
|
set(CMAKE_AR ${TOOLCHAIN_PATH}/llvm-ar)
|
|
|
|
set(CMAKE_CXXFILT ${TOOLCHAIN_PATH}/llvm-cxxfilt)
|
|
|
|
# FIXME: Persuade LLVM maintainers to add `--update-section` to llvm-objcopy, as it's required for the kernel symbol map.
|
|
|
|
set(CMAKE_OBJCOPY ${TOOLCHAIN_ROOT}/binutils/bin/${SERENITY_ARCH}-pc-serenity-objcopy)
|
2021-02-15 00:49:25 +03:00
|
|
|
else()
|
2021-08-08 03:32:49 +03:00
|
|
|
set(TOOLCHAIN_ROOT ${SerenityOS_SOURCE_DIR}/Toolchain/Local/${SERENITY_ARCH}/)
|
2021-04-27 10:25:02 +03:00
|
|
|
set(TOOLCHAIN_PATH ${TOOLCHAIN_ROOT}/bin)
|
2021-02-15 00:49:25 +03: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 16:25:31 +03:00
|
|
|
set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}gcc-ranlib)
|
2021-02-15 00:49:25 +03:00
|
|
|
set(CMAKE_STRIP ${TOOLCHAIN_PREFIX}strip)
|
2021-04-29 16:25:31 +03:00
|
|
|
set(CMAKE_AR ${TOOLCHAIN_PREFIX}gcc-ar)
|
2021-07-15 11:17:58 +03:00
|
|
|
set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy)
|
2021-07-29 09:48:47 +03:00
|
|
|
set(CMAKE_CXXFILT ${TOOLCHAIN_PREFIX}c++filt)
|
2021-02-15 00:49:25 +03:00
|
|
|
endif()
|
2020-05-06 18:40:06 +03:00
|
|
|
|
2020-07-09 00:57:51 +03: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 13:39:24 +03:00
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES Darwin)
|
2021-04-29 23:58:05 +03:00
|
|
|
## macOS workaround. Use GNU ld flags for SONAMEs.
|
2021-01-07 13:39:24 +03:00
|
|
|
set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
|
2021-04-29 23:58:05 +03: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 13:39:24 +03:00
|
|
|
endif()
|
2020-07-09 00:57:51 +03:00
|
|
|
endforeach()
|
|
|
|
|
2020-12-28 02:04:29 +03:00
|
|
|
set(CMAKE_INSTALL_NAME_TOOL "")
|
2020-07-09 00:57:51 +03:00
|
|
|
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
|
2021-03-19 08:47:23 +03:00
|
|
|
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-shared -Wl,--hash-style=gnu,-z,relro,-z,now,-z,noexecstack")
|
2021-06-28 18:19:18 +03:00
|
|
|
set(CMAKE_CXX_LINK_FLAGS "-Wl,--hash-style=gnu,-z,relro,-z,now,-z,noexecstack,-z,max-page-size=0x1000")
|
2020-07-09 00:57:51 +03:00
|
|
|
|
2021-01-07 02:55:01 +03:00
|
|
|
# We disable it completely because it makes cmake very spammy.
|
2020-12-28 02:04:29 +03:00
|
|
|
# This will need to be revisited when the Loader supports RPATH/RUN_PATH.
|
2021-01-07 02:55:01 +03:00
|
|
|
set(CMAKE_SKIP_RPATH TRUE)
|
2020-12-28 02:04:29 +03:00
|
|
|
|
2021-03-28 17:48:37 +03:00
|
|
|
add_compile_options(-Wformat=2)
|
|
|
|
add_compile_options(-fdiagnostics-color=always)
|
|
|
|
|
|
|
|
if (NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES SerenityOS)
|
2021-03-28 17:43:05 +03: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 17:48:37 +03:00
|
|
|
add_compile_options(-Werror)
|
2021-03-28 17:43:05 +03:00
|
|
|
endif()
|
|
|
|
|
2021-03-28 17:48:37 +03:00
|
|
|
add_compile_options(-Wall)
|
|
|
|
add_compile_options(-Wextra)
|
|
|
|
|
2021-04-15 10:07:44 +03:00
|
|
|
# The following warnings are sorted by the "base" name (the part excluding the initial Wno or W).
|
2021-03-28 17:48:37 +03:00
|
|
|
add_compile_options(-Wno-address-of-packed-member)
|
|
|
|
add_compile_options(-Wcast-qual)
|
|
|
|
add_compile_options(-Wno-deprecated-copy)
|
2021-04-15 10:07:44 +03:00
|
|
|
add_compile_options(-Wduplicated-cond)
|
2021-03-28 17:48:37 +03:00
|
|
|
add_compile_options(-Wno-expansion-to-defined)
|
2021-04-15 10:07:44 +03:00
|
|
|
add_compile_options(-Wformat=2)
|
2021-03-28 17:48:37 +03:00
|
|
|
add_compile_options(-Wimplicit-fallthrough)
|
2021-04-15 10:07:44 +03:00
|
|
|
add_compile_options(-Wlogical-op)
|
|
|
|
add_compile_options(-Wmisleading-indentation)
|
2021-03-28 17:48:37 +03:00
|
|
|
add_compile_options(-Wmissing-declarations)
|
2021-04-15 20:43:29 +03:00
|
|
|
add_compile_options(-Wnon-virtual-dtor)
|
2021-03-28 17:48:37 +03:00
|
|
|
add_compile_options(-Wno-unknown-warning-option)
|
|
|
|
add_compile_options(-Wundef)
|
2021-04-15 10:07:44 +03:00
|
|
|
add_compile_options(-Wunused)
|
2021-07-13 17:43:45 +03:00
|
|
|
add_compile_options(-Wno-unused-private-field)
|
|
|
|
add_compile_options(-Wno-unused-const-variable)
|
|
|
|
add_compile_options(-Wno-unused-command-line-argument)
|
2021-03-28 17:48:37 +03:00
|
|
|
add_compile_options(-Wwrite-strings)
|
2021-06-09 18:51:17 +03:00
|
|
|
add_compile_options(-Wno-maybe-uninitialized)
|
2021-03-28 17:48:37 +03:00
|
|
|
|
2021-08-08 03:32:49 +03:00
|
|
|
add_compile_options(-ffile-prefix-map=${SerenityOS_SOURCE_DIR}=.)
|
2021-03-28 17:48:37 +03:00
|
|
|
add_compile_options(-fno-exceptions)
|
2021-07-13 17:43:45 +03:00
|
|
|
add_compile_options(-ftls-model=initial-exec)
|
|
|
|
add_compile_options(-fno-semantic-interposition)
|
|
|
|
add_compile_options(-fstack-clash-protection)
|
2021-03-28 17:48:37 +03:00
|
|
|
add_compile_options(-fstack-protector-strong)
|
|
|
|
add_compile_options(-g1)
|
2020-05-06 18:40:06 +03:00
|
|
|
|
2021-07-13 17:43:45 +03:00
|
|
|
if (USE_CLANG_TOOLCHAIN)
|
|
|
|
add_compile_options(-Wno-atomic-alignment)
|
|
|
|
add_compile_options(-Wno-c99-designator)
|
|
|
|
add_compile_options(-Wno-implicit-const-int-float-conversion)
|
|
|
|
add_compile_options(-Wno-inconsistent-missing-override)
|
|
|
|
add_compile_options(-Wno-tautological-constant-out-of-range-compare)
|
|
|
|
add_compile_options(-Wno-unneeded-internal-declaration)
|
|
|
|
add_compile_options(-Wno-unused-function)
|
|
|
|
add_compile_options(-Wno-user-defined-literals)
|
|
|
|
# Without the 'SHELL' prefix, this would get removed through de-duplication with the flags set for the host compiler.
|
|
|
|
# Then, that would come before '-Wextra', so it would not negate the '-Woverloaded-virtual' set by '-Wextra'.
|
|
|
|
add_compile_options(SHELL:-Wno-overloaded-virtual)
|
|
|
|
|
|
|
|
add_compile_options(--sysroot=${CMAKE_BINARY_DIR}/Root)
|
|
|
|
add_compile_options(--target=${SERENITY_CLANG_ARCH}-pc-serenity)
|
|
|
|
add_compile_options(-fno-aligned-allocation)
|
|
|
|
add_compile_options(-fconstexpr-steps=16777216)
|
|
|
|
add_compile_options(-gdwarf-4)
|
|
|
|
|
|
|
|
# FIXME: Why is Clang not picking up this path?
|
|
|
|
link_directories(${TOOLCHAIN_ROOT}/lib/clang/${LLVM_VERSION}/lib/serenity)
|
|
|
|
|
|
|
|
add_link_options(LINKER:--allow-shlib-undefined)
|
|
|
|
else()
|
|
|
|
add_compile_options(-Wcast-align)
|
|
|
|
add_compile_options(-Wdouble-promotion)
|
|
|
|
endif()
|
|
|
|
|
2021-08-18 18:39:04 +03:00
|
|
|
add_link_options(LINKER:-z,text)
|
|
|
|
|
2021-07-13 17:43:45 +03:00
|
|
|
if("${SERENITY_ARCH}" STREQUAL "i686")
|
|
|
|
add_compile_options(-march=i686)
|
|
|
|
else()
|
|
|
|
add_compile_options(-march=x86-64)
|
2021-02-23 16:15:26 +03:00
|
|
|
endif()
|
|
|
|
|
2021-07-12 10:31:47 +03:00
|
|
|
add_compile_definitions(SANITIZE_PTRS)
|
2020-12-11 16:44:08 +03:00
|
|
|
set(CMAKE_CXX_FLAGS_STATIC "${CMAKE_CXX_FLAGS} -static")
|
2020-12-20 23:32:10 +03:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pie -fpic")
|
2021-01-01 13:20:55 +03:00
|
|
|
|
2021-02-23 20:14:04 +03:00
|
|
|
if (ENABLE_COMPILETIME_FORMAT_CHECK)
|
|
|
|
add_compile_definitions(ENABLE_COMPILETIME_FORMAT_CHECK)
|
2021-02-08 20:26:28 +03:00
|
|
|
endif()
|
|
|
|
|
2020-05-06 18:40:06 +03:00
|
|
|
add_link_options(--sysroot ${CMAKE_BINARY_DIR}/Root)
|
2021-07-13 17:43:45 +03:00
|
|
|
add_link_options(-Wno-unused-command-line-argument)
|
2020-05-06 18:40:06 +03:00
|
|
|
|
2021-01-12 14:17:30 +03:00
|
|
|
include_directories(Userland/Libraries/LibC)
|
2021-05-01 12:38:19 +03:00
|
|
|
include_directories(Userland/Libraries/LibCrypt)
|
2021-01-12 14:17:30 +03:00
|
|
|
include_directories(Userland/Libraries/LibM)
|
2021-05-01 12:38:19 +03:00
|
|
|
include_directories(Userland/Libraries/LibPthread)
|
2021-02-05 14:16:30 +03:00
|
|
|
include_directories(Userland/Libraries/LibSystem)
|
2021-01-12 14:23:01 +03:00
|
|
|
include_directories(Userland/Services)
|
2021-01-12 13:53:14 +03:00
|
|
|
include_directories(Userland)
|
2020-09-14 13:51:12 +03:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
2021-01-12 14:23:01 +03:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Userland/Services)
|
2021-01-12 14:17:30 +03:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Userland/Libraries)
|
2021-01-12 13:53:14 +03:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Userland)
|
2020-05-06 18:40:06 +03:00
|
|
|
|
2021-05-24 04:40:22 +03: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 16:07:25 +03:00
|
|
|
add_custom_target(components ALL)
|
|
|
|
option(BUILD_EVERYTHING "Build all optional components" ON)
|
|
|
|
|
2021-08-08 03:32:49 +03:00
|
|
|
include(Meta/CMake/utils.cmake)
|
2021-06-15 16:07:25 +03:00
|
|
|
|
|
|
|
serenity_component(
|
|
|
|
Tests
|
|
|
|
RECOMMENDED
|
|
|
|
)
|
|
|
|
|
2020-05-26 21:20:24 +03:00
|
|
|
add_subdirectory(AK)
|
2020-05-06 18:40:06 +03:00
|
|
|
add_subdirectory(Kernel)
|
|
|
|
add_subdirectory(Userland)
|
2021-05-06 11:14:50 +03:00
|
|
|
add_subdirectory(Tests)
|
2021-02-07 02:52:40 +03:00
|
|
|
|
2021-06-15 16:07:25 +03:00
|
|
|
export_components("${CMAKE_BINARY_DIR}/components.ini")
|
|
|
|
|
2021-03-04 01:50:25 +03: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-07 02:52:40 +03:00
|
|
|
endif()
|
2021-06-09 17:24:04 +03: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()
|