-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
84 lines (62 loc) · 2.47 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
cmake_minimum_required(VERSION 3.10)
project(arctic)
set(CMAKE_C_COMPILER wsl $WSLENV/x86_64-elf-gcc)
set(CMAKE_CXX_COMPILER wsl $WSLENV/x86_64-elf-gcc)
set(CMAKE_ASM_COMPILER nasm)
set(SOURCES src)
set(BUILD build)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BUILD})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BUILD})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BUILD})
set(CMAKE_CXX_FLAGS_DEBUG "-m32 -ffreestanding -nostdlib -nostdinc -lgcc")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-m32 -ffreestanding -nostdlib -nostdinc -lgcc")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-m32 -ffreestanding -nostdlib -nostdinc -lgcc")
set(CMAKE_CXX_FLAGS_RELEASE "-m32 -ffreestanding -nostdlib -nostdinc -lgcc")
set(CMAKE_LINK_FLAGS "-m elf_i386 -T ${SOURCES}/link.ld -o ${BUILD}/Kernel-0 ")
set(KERNEL_BIN Kernel-0)
include_directories(
${SOURCES}/kernel
${SOURCES}/kernel/cpu
${SOURCES}/kernel/dev
${SOURCES}/kernel/driver
${SOURCES}/kernel/io
${SOURCES}/kernel/memory
${SOURCES}/kernel/shell
${SOURCES}/kernel/utils
)
set (ASM_SOURCES
${SOURCES}/kernel/Kernel.asm
${SOURCES}/kernel/cpu/CPU.asm
${SOURCES}/kernel/cpu/GDT.asm
${SOURCES}/kernel/cpu/IDT.asm
${SOURCES}/kernel/memory/Memory.asm
${SOURCES}/kernel/memory/Paging.asm
)
set(CXX_SOURCES
${SOURCES}/kernel/Kernel.cpp
${SOURCES}/kernel/cpu/CPU.cpp
${SOURCES}/kernel/cpu/GDT.cpp
${SOURCES}/kernel/cpu/IDT.cpp
${SOURCES}/kernel/cpu/Interrupt.cpp
${SOURCES}/kernel/dev/Block.cpp
${SOURCES}/kernel/dev/Character.cpp
${SOURCES}/kernel/dev/Keyboard.cpp
${SOURCES}/kernel/dev/Mouse.cpp
${SOURCES}/kernel/dev/Timer.cpp
${SOURCES}/kernel/driver/Driver.cpp
${SOURCES}/kernel/driver/PS2Keyboard.cpp
${SOURCES}/kernel/driver/VGAGraphics.cpp
${SOURCES}/kernel/io/KPrintf.cpp
${SOURCES}/kernel/io/Port.cpp
${SOURCES}/kernel/memory/Memory.cpp
${SOURCES}/kernel/memory/Paging.cpp
${SOURCES}/kernel/shell/Shell.cpp
${SOURCES}/kernel/utils/Bitmap.cpp
)
## Building the kernel binary
add_executable(${KERNEL_BIN} ${ASM_SOURCES} ${CXX_SOURCES})
# add the link command
set_target_properties(${KERNEL_BIN} PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS})
add_custom_command(TARGET ${KERNEL_BIN} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD}
COMMAND ${CMAKE_COMMAND} -E copy ${KERNEL_BIN} ${BUILD})