blob: c6d991293f19ca069945f01f9dedb4b9d3b99621 (
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
|
# Regard that file as root of whole project
# which include farther subprojects source codes
# Expected input variables:
# ARCH: type of architecture
cmake_minimum_required(VERSION 3.25)
project(ObjectiveProject LANGUAGES CXX ASM_NASM)
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(metadata)
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
if(NOT ARCH IN_LIST OBJECTIVE_SUPPORTED_PROCESSORS)
list(GET OBJECTIVE_SUPPORTED_PROCESSORS 0 ARCH)
endif()
# Create target with compiler 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 compiler flags
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
target_compile_options(CXX_COMPILER_REQUIREMENTS INTERFACE
${ObjectiveProject_CXX_FLAGS}
)
endif()
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 Object 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
CRTI
Architecture
Kernel
Drivers
CRTN
)
target_link_libraries(Objective PRIVATE CXX_LINKER_REQUIREMENTS)
|