-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
143 lines (123 loc) · 4.65 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 2.9)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR i386)
set(triple i386)
set(CMAKE_C_COMPILER /usr/bin/clang)
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER /usr/bin/clang++)
set(CMAKE_CXX_COMPILER_TARGET ${triple})
project(FluxedOS LANGUAGES CXX C ASM_NASM ASM)
set(CMAKE_NASM_LINK_EXECUTABLE "ld -o ")
set(CAN_USE_ASSEMBLER TRUE)
set(CMAKE_ASM_NASM_FLAGS "")
set(CMAKE_ASM_NASM_OBJECT_FORMAT elf)
set(CMAKE_ASM_FLAGS "-m32 -c")
set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <INCLUDES> <FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>")
add_custom_target(buildver
COMMAND python3 ../tools/argpass.py
)
set ( ASM
#src/boot/boot.asm
src/CPU/cpua.asm
src/CPU/gdta.asm
src/CPU/irqa.asm
src/CPU/isra.asm
src/System/panic/stack_dump.asm
)
set ( GAS
src/boot/boot.S
src/System/memory/paging/Paging.S
)
set ( C
src/boot/KenelEntry.c
src/CPU/cpu.c
src/CPU/gdt.c
src/CPU/idt.c
src/CPU/irq.c
src/CPU/isr.c
src/lib/StanderdOperations/Operations.c
)
set (CXX
src/lib/BundledContext/BundledContext.cpp
src/lib/SmartPointer/smartpointer.cpp
src/lib/bitmap/bitmap.cpp
src/lib/string/string.cpp
src/lib/assert/assert.cpp
src/lib/vector/k_vector/k_vector.cpp
src/lib/math/math.cpp
src/Kernel/kernel.cpp
src/Kernel/boot.cpp
src/Kernel/runtime.cpp
src/System/PCI/pci.cpp
src/System/Clock/PIT/PIT.cpp
src/System/Clock/RTC/RTC.cpp
src/System/CommandHandler/CommandHandler.cpp
src/System/Console/console.cpp
src/System/Display/Display.cpp
src/System/Keyboard/keyboard.cpp
src/System/Port/port.cpp
src/System/Power/Power.cpp
src/System/Serial/serial.cpp
src/System/cpu/cpu.cpp
src/System/kout/kernelout/kernelout.cpp
src/System/kout/kout.cpp
src/System/memory/paging/page.cpp
src/System/memory/pmm/pmm.cpp
src/System/memory/kmemory.cpp
src/System/tty/tty.cpp
src/System/panic/panic.cpp
src/System/FPU/fpu.cpp
src/System/Graphics/DisplayServer/ds.cpp
src/System/Graphics/vbe.cpp
src/System/memory/vmm/vmm.cpp
src/System/CompilerFixes/cxa.cpp
src/System/CompilerFixes/icxxabi.cpp
src/System/memory/staticalloc/skmalloc.cpp
src/System/Disk/ata.cpp
src/System/Disk/vDisk.cpp
src/System/Disk/vDisk.hpp
src/System/fs/mbt.cpp
src/System/fs/mbt.hpp
src/System/fs/ext2.cpp
src/System/fs/ext2.hpp
src/System/fs/vfs.cpp
src/System/fs/vfs.hpp src/System/fs/vfs_impl.tcc)
set_source_files_properties(${ASM} PROPERTIES LANGUAGE ASM_NASM)
set_source_files_properties(${GAS} PROPERTIES LANGUAGE ASM)
set(CMAKE_C_COMPILE_FEATURES -g -m32 -nostdinc -nostdlib
-fPIE -fomit-frame-pointer -Wall
-finline-functions -fno-stack-protector
-fpic -fshort-wchar -mno-red-zone -fno-builtin)
set(CMAKE_CXX_COMPILE_FEATURES -g -m32 -nostdinc -nostdlib
-fno-rtti -fPIE -fno-exceptions -Wno-write-strings -Wall
-fno-stack-protector
-fomit-frame-pointer -finline-functions -fno-builtin
-fdiagnostics-color=always)
set(CMAKE_ASM_COMPILE_FEATURES -shared )
add_link_options(-m32 -g -Wall -Werror -Wextra -ffreestanding -fno-rtti -fPIE -nodefaultlibs -fno-stack-protector -fno-exceptions -nostartfiles -Wno-undef -nostdlib -T ../src/linker.ld )
add_executable(FluxedOS.bin ${GAS} ${ASM} ${C} ${CXX})
add_dependencies(FluxedOS.bin buildver)
target_include_directories(FluxedOS.bin PUBLIC src)
target_compile_options(FluxedOS.bin PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,Clang>:
${CMAKE_CXX_COMPILE_FEATURES}
>)
target_compile_options(FluxedOS.bin PUBLIC $<$<COMPILE_LANG_AND_ID:C,Clang>:
${CMAKE_C_COMPILE_FEATURES}
>)
# making the ISO
add_custom_target(iso
COMMAND mkdir -p isodir/boot/grub && cp FluxedOS.bin isodir/boot/FluxedOS.bin && cp ../src/grub.cfg isodir/boot/grub/grub.cfg && grub-mkrescue -o FluxedOS.iso isodir && cp FluxedOS.iso ../ISO
BYPRODUCTS FluxedOS.iso
)
add_dependencies(iso FluxedOS.bin)
add_custom_target(run USES_TERMINAL
COMMAND qemu-system-x86_64 -boot order=dc -cdrom FluxedOS.iso -drive format=raw,file=disk.img -boot strict=on -cpu max -smp 1,sockets=1,cores=1,threads=1 -display gtk -m 800m -k en-us -serial stdio -nic none
DEPENDS iso
)
add_custom_target(mkimg USES_TERMINAL
COMMAND bash ../tools/mkimg.sh
)
add_custom_target(debug USES_TERMINAL
COMMAND objcopy --only-keep-debug FluxedOS.bin FluxedOS.elf && strip --strip-debug --strip-unneeded FluxedOS.bin && qemu-system-x86_64 -s -S FluxedOS.bin -cdrom FluxedOS.iso -boot strict=on -cpu max -smp 1,sockets=1,cores=1,threads=1 -display gtk -m 500m -k en-us -serial stdio &
DEPENDS iso
)