aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 27500ed99be8d9b0395707a2d014b53c6ea09786 (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
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("GenerateBootableIso")

#[============================================================================[
# Global Build System Configuration
#]============================================================================]

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 "20")
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)

#[============================================================================[
# Global Build System Configuration
#]============================================================================]

add_executable("kernel")

add_subdirectory("libs")
add_subdirectory("kern")
add_subdirectory("arch")

target_link_libraries("kernel" PRIVATE
    "arch::${CMAKE_SYSTEM_PROCESSOR}"
    "os::kern"
)

target_generate_bootable_iso("kernel")


# #[============================================================================[
# # Documentation
# #]============================================================================]

# find_package("Doxygen")

# set(DOXYGEN_GENERATE_HTML YES)
# set(DOXYGEN_GENERATE_XML YES)
# set(DOXYGEN_EXCLUDE_PATTERNS "*.cpp")
# set(DOXYGEN_OUTPUT_DIRECTORY "doxygen")
# set(DOXYGEN_QUIET YES)

# file(GLOB_RECURSE DOXYGEN_SOURCES CONFIGURE_DEPENDS "*.hpp")

# message(STATUS "${SPHINX_SOURCES}")

# doxygen_add_docs("docs_xml"
#   ${DOXYGEN_SOURCES}
#   ALL
#   USE_STAMP_FILE
#   COMMENT "Generating developer documentation sources"
# )

# set_target_properties("docs_xml" PROPERTIES
#   ADDITIONAL_CLEAN_FILES
#   "${PROJECT_BINARY_DIR}/doxygen"
# )

# file(GLOB_RECURSE SPHINX_SOURCES CONFIGURE_DEPENDS "../docs/**.rst") 

# add_custom_target("docs" ALL
#   COMMAND "${SPHINX_BUILD_EXE}"
#   "../docs"
#   "docs"
#   "-q"
#   DEPENDS "docs_xml"
#   SOURCES ${SPHINX_SOURCES}
#   COMMENT "Generating developer documentation html"
# )

# set_target_properties("docs" PROPERTIES
#   ADDITIONAL_CLEAN_FILES
#   "${PROJECT_BINARY_DIR}/docs"
# )

# #[============================================================================[
# # Global Compiler Configuration
# #]============================================================================]

# 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 Libraries
# #]============================================================================]

# add_subdirectory("libs/kstd" EXCLUDE_FROM_ALL SYSTEM)
# add_subdirectory("libs/multiboot2" EXCLUDE_FROM_ALL SYSTEM)

# #[============================================================================[
# # Global Directories
# #]============================================================================]

# include_directories(
#   "include"
#   "arch/${CMAKE_SYSTEM_PROCESSOR}/include"
# )

# #[============================================================================[
# # The Bootstrap Library
# #]============================================================================]

# add_library("_boot" OBJECT)
# add_library("teachos::boot" ALIAS "_boot")

# #[============================================================================[
# # The Video Library
# #]============================================================================]

# add_library("_video" OBJECT)
# add_library("teachos::video" ALIAS "_video")

# #[============================================================================[
# # THE Memory Library
# #]============================================================================]

# add_library("_memory" OBJECT)
# add_library("teachos::memory" ALIAS "_memory")

# #[============================================================================[
# # The Exception handling Library
# #]============================================================================]

# add_library("_exception" OBJECT)
# add_library("teachos::exception" ALIAS "_exception")

# #[============================================================================[
# # The Context switching Library
# #]============================================================================]

# add_library("_context" OBJECT)
# add_library("teachos::context_switching" ALIAS "_context")

# add_library("_interrupt_handling" OBJECT)
# add_library("teachos::interrupt_handling" ALIAS "_interrupt_handling")
# # https://forum.osdev.org/viewtopic.php?f=1&t=36712
# # https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html#index-interrupt-function-attribute_002c-x86
# target_compile_options("_interrupt_handling" PRIVATE "-mgeneral-regs-only")

# #[============================================================================[
# # The Kernel
# #]============================================================================]

# add_executable("_kernel"
#   "src/kernel/main.cpp"
# )
# add_executable("teachos::kernel" ALIAS "_kernel")

# target_link_libraries("_kernel" PRIVATE
#   "teachos::boot"
#   "teachos::video"
#   "teachos::memory"
#   "teachos::exception"
#   "teachos::context_switching"
#   "teachos::interrupt_handling"
# )

# #[============================================================================[
# # Platform Specific Components
# #]============================================================================]

# add_subdirectory("arch/${CMAKE_SYSTEM_PROCESSOR}")