diff --git a/CMakeLists.txt b/CMakeLists.txt index b9c503172d..239fedfdfc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,13 @@ enable_testing() set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +if(NOT COMMAND serenity_option) + macro(serenity_option) + set(${ARGV}) + endmacro() +endif() +include(serenity_options) + set(SERENITY_ARCH "i686" CACHE STRING "Target architecture for SerenityOS.") if("${SERENITY_ARCH}" STREQUAL "i686") @@ -31,22 +38,6 @@ else() set(SERENITY_CLANG_ARCH ${SERENITY_ARCH}) endif() -# Central location for all custom options used in the Serenity build. -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_KERNEL_COVERAGE_COLLECTION "Enable KCOV and kernel coverage instrumentation 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) -option(ENABLE_EXTRA_KERNEL_DEBUG_SYMBOLS "Enable -Og and -ggdb3 options for Kernel code for easier debugging" OFF) -option(ENABLE_ALL_THE_DEBUG_MACROS "Enable all debug macros to validate they still compile" OFF) -option(ENABLE_ALL_DEBUG_FACILITIES "Enable all noisy debug symbols and options. Not recommended for normal developer use" OFF) -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) -option(ENABLE_USB_IDS_DOWNLOAD "Enable download of the usb.ids database at build time" ON) -option(BUILD_LAGOM "Build parts of the system targeting the host OS for fuzzing/testing" OFF) -option(ENABLE_KERNEL_LTO "Build the kernel with link-time optimization" OFF) -option(USE_CLANG_TOOLCHAIN "Build the kernel with the experimental Clang toolchain" OFF) # Meta target to run all code-gen steps in the build. add_custom_target(all_generated) diff --git a/Meta/CMake/common_options.cmake b/Meta/CMake/common_options.cmake new file mode 100644 index 0000000000..d46fe3f734 --- /dev/null +++ b/Meta/CMake/common_options.cmake @@ -0,0 +1,12 @@ +# +# Options common for the Serenity (target) and Lagom (host) builds +# + +serenity_option(ENABLE_COMPILETIME_FORMAT_CHECK ON CACHE BOOL "Enable compiletime format string checks") +serenity_option(ENABLE_UNDEFINED_SANITIZER OFF CACHE BOOL "Enable undefined behavior sanitizer testing in gcc/clang") + +serenity_option(ENABLE_ALL_THE_DEBUG_MACROS OFF CACHE BOOL "Enable all debug macros to validate they still compile") +serenity_option(ENABLE_ALL_DEBUG_FACILITIES OFF CACHE BOOL "Enable all noisy debug symbols and options. Not recommended for normal developer use") + +serenity_option(ENABLE_UNICODE_DATABASE_DOWNLOAD ON CACHE BOOL "Enable download of Unicode UCD and CLDR files at build time") +serenity_option(INCLUDE_WASM_SPEC_TESTS OFF CACHE BOOL "Download and include the WebAssembly spec testsuite") diff --git a/Meta/CMake/lagom_options.cmake b/Meta/CMake/lagom_options.cmake new file mode 100644 index 0000000000..c17a5ebc23 --- /dev/null +++ b/Meta/CMake/lagom_options.cmake @@ -0,0 +1,11 @@ +# +# Options specific to the Lagom (host) build +# + +include(${CMAKE_CURRENT_LIST_DIR}/common_options.cmake) + +serenity_option(ENABLE_ADDRESS_SANITIZER OFF CACHE BOOL "Enable address sanitizer testing in gcc/clang") +serenity_option(ENABLE_MEMORY_SANITIZER OFF CACHE BOOL "Enable memory sanitizer testing in gcc/clang") +serenity_option(ENABLE_FUZZER_SANITIZER OFF CACHE BOOL "Enable fuzzer sanitizer testing in clang") +serenity_option(BUILD_LAGOM OFF CACHE BOOL "Build parts of the system targeting the host OS for fuzzing/testing") +serenity_option(ENABLE_LAGOM_CCACHE OFF CACHE BOOL "Enable ccache for Lagom builds") diff --git a/Meta/CMake/serenity_options.cmake b/Meta/CMake/serenity_options.cmake new file mode 100644 index 0000000000..f5cbc5dec0 --- /dev/null +++ b/Meta/CMake/serenity_options.cmake @@ -0,0 +1,12 @@ +# +# Options specific to the Serenity (target) build +# + +include(${CMAKE_CURRENT_LIST_DIR}/common_options.cmake) + +serenity_option(ENABLE_PCI_IDS_DOWNLOAD ON CACHE BOOL "Enable download of the pci.ids database at build time") +serenity_option(ENABLE_USB_IDS_DOWNLOAD ON CACHE BOOL "Enable download of the usb.ids database at build time") +serenity_option(ENABLE_KERNEL_ADDRESS_SANITIZER OFF CACHE BOOL "Enable kernel address sanitizer testing in gcc/clang") +serenity_option(ENABLE_KERNEL_COVERAGE_COLLECTION OFF CACHE BOOL "Enable KCOV and kernel coverage instrumentation in gcc/clang") +serenity_option(ENABLE_KERNEL_LTO OFF CACHE BOOL "Build the kernel with link-time optimization") +serenity_option(ENABLE_EXTRA_KERNEL_DEBUG_SYMBOLS OFF CACHE BOOL "Enable -Og and -ggdb3 options for Kernel code for easier debugging") diff --git a/Meta/CMake/wasm_spec_tests.cmake b/Meta/CMake/wasm_spec_tests.cmake index bc3152836c..864d2bca1f 100644 --- a/Meta/CMake/wasm_spec_tests.cmake +++ b/Meta/CMake/wasm_spec_tests.cmake @@ -1,5 +1,3 @@ -option(INCLUDE_WASM_SPEC_TESTS "Download and include the WebAssembly spec testsuite" OFF) - if(INCLUDE_WASM_SPEC_TESTS) if (CMAKE_PROJECT_NAME STREQUAL "SerenityOS") set(SOURCE_DIR "${SerenityOS_SOURCE_DIR}") diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index f35a5d908c..69fcdd6a5c 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -8,7 +8,6 @@ project( LANGUAGES C CXX ) -option(ENABLE_LAGOM_CCACHE "Enable ccache for Lagom builds" OFF) option(BUILD_SHARED_LIBS "Build shared libraries instead of static libraries" ON) if (ENABLE_OSS_FUZZ) set(BUILD_SHARED_LIBS OFF) # Don't use shared libraries on oss-fuzz, for ease of integration with their infrastructure @@ -26,6 +25,14 @@ get_filename_component( list(APPEND CMAKE_MODULE_PATH "${SERENITY_PROJECT_ROOT}/Meta/CMake") +if(NOT COMMAND serenity_option) + macro(serenity_option) + set(${ARGV}) + endmacro() +endif() + +include(lagom_options) + find_package(Threads REQUIRED) if (ENABLE_LAGOM_CCACHE)