-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
42 lines (33 loc) · 1.08 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
cmake_minimum_required(VERSION 3.26)
project(ovenkernel)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 -ffreestanding -nostdlib -nostdinc")
set(CMAKE_ASM_NASM_OBJECT_FORMAT "elf32")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ffreestanding -nostdlib -nostdinc -O3 -T ${CMAKE_BINARY_DIR}/linker.ld")
enable_language(C ASM_NASM)
include_directories(${CMAKE_BINARY_DIR}/commonlib)
add_library(commonlib STATIC
commonlib/mem.c
commonlib/console.c
commonlib/strutils.c
commonlib/error.c
)
add_library(bootstrap STATIC
bootstrap/boot.asm
bootstrap/start.c
)
add_executable(${CMAKE_PROJECT_NAME}
src/main.c
)
target_link_libraries(bootstrap commonlib)
target_link_libraries(${CMAKE_PROJECT_NAME} commonlib bootstrap)
add_custom_target(run
COMMAND qemu-system-i386 -cdrom ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}_grub.iso
DEPENDS ovenkernel
)
add_custom_target(grub
COMMAND rm -rf ./iso/boot/ovenkernel -v
COMMAND rm -rf ${CMAKE_PROJECT_NAME}_grub.iso -v
COMMAND cp ${CMAKE_PROJECT_NAME} ./iso/boot -v
COMMAND grub-mkrescue -o ${CMAKE_PROJECT_NAME}_grub.iso ./iso/
DEPENDS ovenkernel
)