Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
146 lines (112 loc) · 5.01 KB
/
Copy pathCMakeLists.txt
File metadata and controls
146 lines (112 loc) · 5.01 KB
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
# SPDX-License-Identifier: MIT
# Copyright (c) 2025-2026 The AlkOS Authors
# See the AUTHORS file for the full list of contributors.
cmake_minimum_required(VERSION 3.30)
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" ALKOS_VERSION_RAW)
string(STRIP "${ALKOS_VERSION_RAW}" ALKOS_VERSION)
project(AlkOS VERSION ${ALKOS_VERSION} LANGUAGES C CXX ASM_NASM)
enable_language(ASM_NASM)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(PROJECT_AUTHOR "The AlkOS Authors")
################################################################################
# Helpers #
################################################################################
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(ValidationHelpers)
include(SourceHelpers)
include(RuntimeHelpers)
include(BashConfigHelpers)
include(MiscHelpers)
add_library(alkos.target.properties.interface INTERFACE) # Populated by the toolchain file
set(CMAKE_ROOT_DIR ${CMAKE_SOURCE_DIR})
################################################################################
# Conf file #
################################################################################
set(BASH_CONF_FILE "${CMAKE_ROOT_DIR}/config/conf.generated.bash")
alkos_init_bash_config()
set(CMAKE_CONF_FILE "${CMAKE_ROOT_DIR}/config/conf.generated.cmake")
# Check if configuration was done
if (NOT EXISTS "${CMAKE_CONF_FILE}")
message(FATAL_ERROR "Cmake configuration (conf.generated.cmake) file does not exists... Try running configure.bash script first!")
else ()
message(STATUS "Detected configuration file. Updating variables...")
endif ()
include("${CMAKE_CONF_FILE}")
################################################################################
# Toolchain #
################################################################################
include(${CMAKE_TOOLCHAIN_FILE})
include(${CMAKE_FLAGS_FILE})
################################################################################
# Messages #
################################################################################
string(REPEAT "=" 80 separator)
message(STATUS "${separator}")
message(STATUS "AlkOS Build Configuration Summary")
message(STATUS "")
message(STATUS " Architecture: ${ARCH}")
message(STATUS " Build Type: ${CMAKE_BUILD_TYPE}")
message(STATUS " Toolchain: ${CMAKE_TOOLCHAIN_FILE}")
message(STATUS "")
message(STATUS " C Compiler: ${CMAKE_C_COMPILER}")
message(STATUS " C++ Compiler: ${CMAKE_CXX_COMPILER}")
message(STATUS " C Flags: ${CMAKE_C_FLAGS}")
message(STATUS " C++ Flags: ${CMAKE_CXX_FLAGS}")
message(STATUS " ASM (NASM) Flags: ${CMAKE_ASM_NASM_FLAGS}")
message(STATUS "")
message(STATUS " Linker: ${CMAKE_LINKER}")
message(STATUS " Archiver: ${CMAKE_AR}")
message(STATUS " Ranlib: ${CMAKE_RANLIB}")
message(STATUS " Debugger: ${CMAKE_GDB}")
message(STATUS "${separator}")
################################################################################
# Sysroot #
################################################################################
set(SYSROOT ${CMAKE_BINARY_DIR}/sysroot)
set(CMAKE_SYSROOT ${SYSROOT})
file(MAKE_DIRECTORY ${CMAKE_SYSROOT}/usr/include)
file(MAKE_DIRECTORY ${CMAKE_SYSROOT}/usr/lib)
file(MAKE_DIRECTORY ${CMAKE_SYSROOT}/boot)
file(MAKE_DIRECTORY ${CMAKE_SYSROOT}/boot/grub)
################################################################################
# Load subdirectories #
################################################################################
set(SYSTEM_LIB_TYPE k)
alkos_add_subdirs(libs)
add_subdirectory(generated)
add_subdirectory(kernel)
add_subdirectory(userspace)
add_subdirectory(rootfs)
################################################################################
# Aliases #
################################################################################
alkos_ensure_defined(
VARS ARCH
MESSAGE "The ARCH variable must be set to the target architecture (e.g., x86_64, i686, arm64)."
)
message(STATUS "Creating build aliases for ARCH='${ARCH}'")
add_custom_target(iso
DEPENDS iso-${ARCH}
COMMENT "Alias for: make iso-${ARCH}"
)
add_custom_target(run
DEPENDS run-${ARCH}
COMMENT "Alias for: make run-${ARCH}"
)
add_custom_target(run-with-gdb
DEPENDS run-with-gdb-${ARCH}
COMMENT "Alias for: make run-with-gdb-${ARCH}"
)
add_custom_target(mount
DEPENDS mount-${ARCH}
COMMENT "Alias for: make mount-${ARCH}"
)
if (CMAKE_FEATURE_FLAG_RUN_TEST_MODE)
add_custom_target(tests
DEPENDS tests-${ARCH}
COMMENT "Alias for: make tests-${ARCH}"
)
endif()