-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
116 lines (102 loc) · 4.76 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
cmake_minimum_required(VERSION 3.22)
project(KernelOSPkg VERSION 0.1.0 LANGUAGES C ASM)
enable_language(C ASM ASM_NASM)
set(CMAKE_C_STANDARD 23)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_COMPILER /usr/local/bin/zigcc)
set(CMAKE_C_FLAGS_DEBUG "-DPRINT_TABS -DDEBUG_CPU -DDEBUG_INTERRUPTS")
set(CMAKE_ASM_COMPILER /usr/local/bin/nasm)
set(CMAKE_NASM_SOURCE_FILE_EXTENSIONS "s;S")
set(ASM_SOURCES
${CMAKE_SOURCE_DIR}/src/Assembly/FlushGDT.s
${CMAKE_SOURCE_DIR}/src/Assembly/Interrupts.s
${CMAKE_SOURCE_DIR}/src/Assembly/Exception.s)
foreach(ASM_SOURCE ${ASM_SOURCES})
get_filename_component(ASM_FILENAME ${ASM_SOURCE} NAME_WE)
set(ASM_OBJECT "${CMAKE_CURRENT_BINARY_DIR}/${ASM_FILENAME}.obj")
add_custom_command(
OUTPUT ${ASM_OBJECT}
COMMAND nasm -f win64 ${ASM_SOURCE} -o ${ASM_OBJECT}
DEPENDS ${ASM_SOURCE}
)
list(APPEND ASM_OBJECTS ${ASM_OBJECT})
endforeach()
add_executable(KernelOSPkg
${CMAKE_SOURCE_DIR}/src/Kernel/Kernel.c
${CMAKE_SOURCE_DIR}/src/Kernel/Acpi/MADTParser.c
${CMAKE_SOURCE_DIR}/src/Kernel/Drivers/IO/io.c
${CMAKE_SOURCE_DIR}/src/Kernel/Drivers/IO/serial.c
${CMAKE_SOURCE_DIR}/src/Kernel/Drivers/USB/KernKeyboard.c
${CMAKE_SOURCE_DIR}/src/Kernel/Drivers/PS2/PS2KeyboardDriver.c
${CMAKE_SOURCE_DIR}/src/Kernel/Interrupts/ApicHandler.c
${CMAKE_SOURCE_DIR}/src/Kernel/Interrupts/MSRegister.c
${CMAKE_SOURCE_DIR}/src/Kernel/Interrupts/GDT.c
${CMAKE_SOURCE_DIR}/src/Kernel/Interrupts/Interrupts.c
${CMAKE_SOURCE_DIR}/src/Kernel/Syscall/CPUID/CPUID.c
${CMAKE_SOURCE_DIR}/src/Kernel/Graphics/KernFontParser.c
${CMAKE_SOURCE_DIR}/src/Kernel/Graphics/KernGraphics.c
${CMAKE_SOURCE_DIR}/src/Kernel/Graphics/KernText.c
${CMAKE_SOURCE_DIR}/src/Kernel/Memory/KernMemoryManager.c
${CMAKE_SOURCE_DIR}/src/Kernel/Memory/KernMem.c
${CMAKE_SOURCE_DIR}/src/Kernel/Util/KernRuntimeValues.c
${CMAKE_SOURCE_DIR}/src/Kernel/Util/KernString.c
${CMAKE_SOURCE_DIR}/src/Kernel/Util/KernUtil.c
${CMAKE_SOURCE_DIR}/src/Math/Pow.c
${CMAKE_SOURCE_DIR}/src/Math/Logarithm.c
${CMAKE_SOURCE_DIR}/src/Common/Acpi/MADTParser.h
${CMAKE_SOURCE_DIR}/src/Common/Drivers/IO/io.h
${CMAKE_SOURCE_DIR}/src/Common/Drivers/IO/serial.h
${CMAKE_SOURCE_DIR}/src/Common/Drivers/USB/KernKeyboard.h
${CMAKE_SOURCE_DIR}/src/Common/Drivers/PS2/PS2KeyboardDriver.h
${CMAKE_SOURCE_DIR}/src/Common/Interrupts/ApicHandler.h
${CMAKE_SOURCE_DIR}/src/Common/Interrupts/MSRegister.h
${CMAKE_SOURCE_DIR}/src/Common/Interrupts/GDT.h
${CMAKE_SOURCE_DIR}/src/Common/Interrupts/IDTRTable.h
${CMAKE_SOURCE_DIR}/src/Common/Interrupts/TrapExceptions.h
${CMAKE_SOURCE_DIR}/src/Common/Interrupts/Interrupts.h
${CMAKE_SOURCE_DIR}/src/Common/Syscall/CPUID/CPUID.h
${CMAKE_SOURCE_DIR}/src/Common/Graphics/KernFontParser.h
${CMAKE_SOURCE_DIR}/src/Common/Graphics/KernGraphics.h
${CMAKE_SOURCE_DIR}/src/Common/Graphics/KernText.h
${CMAKE_SOURCE_DIR}/src/Common/Graphics/KernGop.h
${CMAKE_SOURCE_DIR}/src/Common/Memory/KernMemoryManager.h
${CMAKE_SOURCE_DIR}/src/Common/Memory/KernMem.h
${CMAKE_SOURCE_DIR}/src/Common/Memory/KernEfiMem.h
${CMAKE_SOURCE_DIR}/src/Common/Util/KernRuntimeValues.h
${CMAKE_SOURCE_DIR}/src/Common/Util/KernString.h
${CMAKE_SOURCE_DIR}/src/Common/Util/KernUtil.h
${CMAKE_SOURCE_DIR}/src/Common/Math/Pow.h
${CMAKE_SOURCE_DIR}/src/Common/Math/Logarithm.h
${ASM_OBJECTS}
)
set_target_properties(KernelOSPkg PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/hda-contents")
set_target_properties(KernelOSPkg PROPERTIES OUTPUT_NAME "kernel.bin")
target_compile_options(KernelOSPkg PRIVATE
-g
--target=x86_64-uefi-msvc
--sysroot=x86_64-w64-mingw32-gcc
-ffreestanding
-nostdlib
-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/src/Kernel/=
-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/src/Kernel/Drivers/IO/=
-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/src/Kernel/Drivers/USB/=
-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/src/Kernel/Graphics/=
-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/src/Kernel/Memory/=
-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/src/Kernel/Util/=
-fmacro-prefix-map=${CMAKE_SOURCE_DIR}/src/Kernel/Math/=
-Wextra
-pedantic
)
target_link_options(KernelOSPkg PRIVATE
--target=x86_64-uefi-msvc
--sysroot=x86_64-w64-mingw32-gcc
-fuse-ld=lld-link
-Wl,--entry,EfiMain
-Wl,--subsystem,efi_application
-fshort-wchar
)
target_include_directories(KernelOSPkg PRIVATE ${CMAKE_SOURCE_DIR}/src/Common/)
target_include_directories(KernelOSPkg PRIVATE ${CMAKE_SOURCE_DIR}/../MdePkg/Include/)
target_include_directories(KernelOSPkg PRIVATE ${CMAKE_SOURCE_DIR}/../MdePkg/Include/X64/)
link_libraries(/Users/kernel/Documents/audk/MdePkg/Library/)
target_link_libraries(KernelOSPkg PRIVATE ${ASM_OBJECTS})