blob: 0fa2c03ca7c6005d12e55b9c126ffd5e95086085 (
plain) (
blame)
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
|
#[[
* Copyright (c) 2026 Alexey Gavrilov <alexey.gavrilov@mail.com>
*
* This file is part of ObjectiveOS.
*
* ObjectiveOS is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* ObjectiveOS is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* ObjectiveOS. If not, see <https://www.gnu.org/licenses/>.
]]
# Regard that file as root of whole project
# which include farther subprojects source codes
# Expected input variables:
# ObjectiveProject_ARCHITECTURE: type of architecture
cmake_minimum_required(VERSION 3.25)
list(APPEND CMAKE_MESSAGE_CONTEXT ObjectiveProject)
project(ObjectiveProject LANGUAGES CXX ASM_NASM)
# Check on supported compiler
message(CHECK_START "Checking compiler support")
list(APPEND CMAKE_MESSAGE_INDENT " ")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
message(CHECK_PASS "Found")
message(STATUS "${CMAKE_CXX_COMPILER_ID} found compiler")
else()
message(CHECK_PASS "Not Found")
message(STATUS "${CMAKE_CXX_COMPILER_ID} compiler isn't supported")
endif()
list(POP_BACK CMAKE_MESSAGE_INDENT)
set(ObjectiveProject_CXX_FLAGS
$<$<CONFIG:Debug>:-Wall -Wextra -ggdb -g3 -O0>
$<$<CONFIG:Release>:-Wall -Werror>
-ffreestanding
-nostdinc
-nostdlib
-fno-rtti
-mgeneral-regs-only
)
set(ObjectiveProject_ASM_NASM_FLAGS
$<$<CONFIG:Debug>:-g -O0 -Wall>
$<$<CONFIG:RELEASE>:-Wall>
)
list(APPEND CMAKE_MODULE_PATH
"${ObjectiveProject_SOURCE_DIR}/cmake/module"
)
include(feature)
include(metadata)
include(runfile)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_executable(Objective)
# Set architecture by default if not present
message(CHECK_START "Checking architecture support")
list(APPEND CMAKE_MESSAGE_INDENT " ")
if(NOT ObjectiveProject_ARCHITECTURE IN_LIST OBJECTIVE_SUPPORTED_PROCESSORS)
if(ObjectiveProject_ARCHITECTURE STREQUAL "" OR NOT DEFINED ObjectiveProject_ARCHITECTURE)
message(CHECK_FAIL "not set")
message(FATAL_ERROR "Architecture isn't set")
else()
message(CHECK_FAIL "unknown")
message(FATAL_ERROR "${ObjectiveProject_ARCHITECTURE} - unknown architecture")
endif()
else()
message(CHECK_FAIL "ok")
message(STATUS "${ObjectiveProject_ARCHITECTURE} - chosen architecture")
endif()
list(POP_BACK CMAKE_MESSAGE_INDENT)
# Create targets with compilers requirements (include directories, flags and etc)
add_library(CXX_COMPILER_REQUIREMENTS INTERFACE)
add_library(ASM_NASM_COMPILER_REQUIREMENTS INTERFACE)
# Target with linker requirements
add_library(CXX_LINKER_REQUIREMENTS INTERFACE)
target_link_options(CXX_LINKER_REQUIREMENTS INTERFACE
${ObjectiveProject_CXX_FLAGS}
)
target_link_libraries(CXX_LINKER_REQUIREMENTS INTERFACE
gcc
)
# Set cxx compiler flags
target_compile_options(CXX_COMPILER_REQUIREMENTS INTERFACE
${ObjectiveProject_CXX_FLAGS}
)
# Set nasm compiler flags
target_compile_options(ASM_NASM_COMPILER_REQUIREMENTS INTERFACE
${ObjectiveProject_ASM_NASM_FLAGS}
)
target_include_directories(CXX_COMPILER_REQUIREMENTS
INTERFACE
${ObjectiveProject_SOURCE_DIR}/include
)
# Subscribe compiler requirements to Objective executable
target_link_libraries(Objective PUBLIC CXX_COMPILER_REQUIREMENTS)
add_subdirectory(arch)
add_subdirectory(kernel)
add_subdirectory(drivers)
add_subdirectory(include)
add_subdirectory(libgcc)
target_sources(Objective PRIVATE
$<TARGET_OBJECTS:Boot>
)
target_link_libraries(Objective PRIVATE
$<TARGET_OBJECTS:CRTI>
$<TARGET_OBJECTS:CRTBEGIN>
Architecture
Kernel
Drivers
$<TARGET_OBJECTS:CRTEND>
$<TARGET_OBJECTS:CRTN>
)
# Set cxx linker options
target_link_libraries(Objective PRIVATE CXX_LINKER_REQUIREMENTS)
outFeaturesToFile()
writerunfile()
|