-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
47 lines (41 loc) · 2.89 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
cmake_minimum_required(VERSION 3.23)
project(VSBL LANGUAGES C CXX ASM)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_FLAGS_RELEASE "")
set(CMAKE_CXX_FLAGS_RELEASE "")
set(CMAKE_C_FLAGS "-O2 -static -m64 -ffreestanding -fno-PIC -fno-PIE -Wall -Wextra -Werror -Wno-unused-parameter -fno-exceptions -nostartfiles -nodefaultlibs -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -masm=intel")
set(CMAKE_CXX_FLAGS "-O2 -static -m64 -ffreestanding -fno-PIC -fno-PIE -Wall -Wextra -Werror -Wno-unused-parameter -Wno-array-bounds -Wno-write-strings -fno-exceptions -fno-rtti -nostartfiles -nodefaultlibs -nostdinc++ -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -include ${PROJECT_SOURCE_DIR}/src/placement_new.h -masm=intel -std=gnu++2a")
set(CMAKE_C_COMPILER cc)
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_ASM_COMPILER yasm)
set(CMAKE_ASM_FLAGS "-f elf64")
set(CMAKE_LINKER ld)
set(CMAKE_EXE_LINKER_FLAGS "-T ${CMAKE_SOURCE_DIR}/linker.ld -nostdlib -O2 -m elf_x86_64 -M")
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <DEFINES> <INCLUDES> ${CMAKE_ASM_FLAGS} -o <OBJECT> <SOURCE>")
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> ${CMAKE_CXX_FLAGS} -o <OBJECT> -c <SOURCE>")
set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> ${CMAKE_C_FLAGS} -o <OBJECT> -c <SOURCE>")
file(GLOB_RECURSE SRC "src/**")
set(CMAKE_EXECUTABLE_SUFFIX .elf)
add_executable(${CMAKE_PROJECT_NAME} ${SRC})
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC __VSBL__)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC src)
file(REAL_PATH grub.cfg GRUB_CONFIG_ABS_PATH)
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
COMMAND sh ${CMAKE_SOURCE_DIR}/extract_image.sh $<TARGET_FILE:${CMAKE_PROJECT_NAME}> ${GRUB_CONFIG_ABS_PATH} $<TARGET_FILE:${CMAKE_PROJECT_NAME}>.bin
VERBATIM)
set(VBox_Machine_Name Test_VM)
set(VBox_Machine_Vdi ${CMAKE_SOURCE_DIR}/${VBox_Machine_Name}/${VBox_Machine_Name}.vdi)
add_custom_target(${CMAKE_PROJECT_NAME}_VBox_Update
COMMAND vboxmanage storageattach ${VBox_Machine_Name} --storagectl SATA --port 0 --medium none
COMMAND vboxmanage closemedium ${VBox_Machine_Vdi} --delete
COMMAND vboxmanage convertfromraw $<TARGET_FILE:${CMAKE_PROJECT_NAME}>.bin ${VBox_Machine_Vdi} --format VDI
COMMAND vboxmanage storageattach ${VBox_Machine_Name} --storagectl SATA --port 0 --type hdd --medium ${VBox_Machine_Vdi}
DEPENDS ${CMAKE_PROJECT_NAME}
VERBATIM)
add_custom_target(${CMAKE_PROJECT_NAME}_VBox_Medium_Create
COMMAND vboxmanage convertfromraw $<TARGET_FILE:${CMAKE_PROJECT_NAME}>.bin ${VBox_Machine_Vdi} --format VDI
COMMAND vboxmanage storageattach ${VBox_Machine_Name} --storagectl SATA --port 0 --type hdd --medium ${VBox_Machine_Vdi}
DEPENDS ${CMAKE_PROJECT_NAME}
VERBATIM)