blob: 6cc8a2f7facf2e5f2987d5bce9d08ab5e48e4ce0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
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(
"$<$<CXX_COMPILER_ID:GNU>:-Wall>"
"$<$<CXX_COMPILER_ID:GNU>:-Wextra>"
"$<$<CXX_COMPILER_ID:GNU>:-Werror>"
"$<$<CXX_COMPILER_ID:GNU>:-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()
#[============================================================================[
# Global Targets
#]============================================================================]
if(CMAKE_CROSSCOMPILING)
add_subdirectory("arch/${CMAKE_SYSTEM_PROCESSOR}")
add_subdirectory("kernel")
add_subdirectory("kapi")
add_subdirectory("libs")
else()
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()
add_subdirectory("libs")
endif()
|