cmake_minimum_required(VERSION "3.27") project("kernel" DESCRIPTION "An educational OS kernel" HOMEPAGE_URL "https://gitlab.ost.ch/teachos/kernel" VERSION "0.0.1" LANGUAGES ASM C CXX ) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules") include("ElfTransformations") include("GenerateBootableIso") #[============================================================================[ # External Dependencies #]============================================================================] include("FetchContent") if (NOT CMAKE_CROSSCOMPILING) FetchContent_Declare( "Catch2" URL "https://github.com/catchorg/Catch2/archive/refs/tags/v3.7.1.tar.gz" URL_HASH "SHA256=c991b247a1a0d7bb9c39aa35faf0fe9e19764213f28ffba3109388e62ee0269c" EXCLUDE_FROM_ALL FIND_PACKAGE_ARGS ) FetchContent_MakeAvailable("Catch2") endif() #[============================================================================[ # Global Build System Options #]============================================================================] option(TEACHOS_ENABLE_LINTING "Enable linting during build" ON) option(TEACHOS_GENERATE_DOCS "Generate documentation during build" ON) #[============================================================================[ # Global Build System Configuration #]============================================================================] if(POLICY CMP0209) cmake_policy(SET CMP0209 NEW) endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") set(CMAKE_INTERPROCEDURAL_OPTIMIZATION YES) set(CMAKE_CXX_STANDARD "23") set(CMAKE_CXX_STANDARD_REQUIRED YES) set(CMAKE_CXX_EXTENSIONS NO) add_compile_options( "$<$:-Wall>" "$<$:-Wextra>" "$<$:-Werror>" "$<$:-pedantic-errors>" ) #[============================================================================[ # Global Linting Configuration #]============================================================================] find_program(CLANG_TIDY_EXE NAMES "clang-tidy-21" "clang-tidy" ) if(CLANG_TIDY_EXE AND TEACHOS_ENABLE_LINTING) set(CMAKE_C_CLANG_TIDY "${CLANG_TIDY_EXE}") set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}") endif() #[============================================================================[ # Global Documentation Configuration #]============================================================================] find_package(Doxygen "1.10") if(Doxygen_FOUND AND TEACHOS_GENERATE_DOCS) doxygen_add_docs("docs" ALL COMMENT "Generating documentation" CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile" ) endif() #[============================================================================[ # Build Host Testing #]============================================================================] if(NOT CMAKE_CROSSCOMPILING) include("EnableCoverage") enable_testing() find_package("Catch2") include("Catch") if(TARGET "Catch2" AND TARGET "Catch2WithMain") set_target_properties("Catch2" "Catch2WithMain" PROPERTIES C_CLANG_TIDY "" CXX_CLANG_TIDY "" ) endif() endif() #[============================================================================[ # Global Targets #]============================================================================] if(CMAKE_CROSSCOMPILING) add_subdirectory("arch/${CMAKE_SYSTEM_PROCESSOR}") endif() add_subdirectory("kapi") add_subdirectory("kernel") add_subdirectory("libs")