Luna/kernel/CMakeLists.txt

58 lines
1.8 KiB
CMake
Raw Normal View History

2022-11-13 09:09:09 +00:00
set(SOURCES
src/main.cpp
2022-11-13 09:30:10 +00:00
src/string.cpp
2022-11-13 10:25:15 +00:00
src/Framebuffer.cpp
2022-11-13 13:29:15 +00:00
src/MemoryManager.cpp
2022-11-13 11:20:53 +00:00
src/Init.cpp
2022-11-13 09:30:10 +00:00
src/arch/Serial.cpp
)
2022-11-15 18:10:32 +00:00
# x86-64 specific
2022-11-13 09:30:10 +00:00
set(SOURCES
${SOURCES}
src/arch/x86_64/IO.cpp
src/arch/x86_64/Serial.cpp
2022-11-13 13:29:15 +00:00
src/arch/x86_64/MMU.cpp
2022-11-15 18:10:32 +00:00
src/arch/x86_64/CPU.cpp
2022-11-13 09:09:09 +00:00
)
2022-11-15 18:10:32 +00:00
# x86-64 specific
set(ASM_SOURCES
src/arch/x86_64/CPU.asm
)
add_library(moon-asm STATIC ${ASM_SOURCES})
2022-11-13 09:09:09 +00:00
2022-11-15 18:10:32 +00:00
add_executable(moon ${SOURCES})
2022-11-13 09:09:09 +00:00
2022-11-15 18:10:32 +00:00
target_link_libraries(moon moon-asm)
2022-11-13 09:09:09 +00:00
target_compile_definitions(moon PRIVATE IN_MOON)
2022-11-15 18:10:32 +00:00
target_compile_options(moon PRIVATE -Os)
2022-11-13 09:09:09 +00:00
target_compile_options(moon PRIVATE -Wall -Wextra -Werror -Wvla)
2022-11-15 18:10:32 +00:00
target_compile_options(moon PRIVATE -Wdisabled-optimization -Wformat=2 -Winit-self)
target_compile_options(moon PRIVATE -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef)
target_compile_options(moon PRIVATE -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion)
target_compile_options(moon PRIVATE -fno-rtti -ffreestanding -fno-exceptions)
target_compile_options(moon PRIVATE -fno-asynchronous-unwind-tables -fno-omit-frame-pointer)
target_compile_options(moon PRIVATE -nostdlib -mcmodel=kernel)
# x86-64 specific
target_compile_options(moon PRIVATE -mno-red-zone)
target_compile_options(moon PRIVATE -mno-80387 -mno-mmx -mno-sse -mno-sse2)
target_link_options(moon PRIVATE -lgcc -Wl,--build-id=none -z max-page-size=0x1000 -mcmodel=kernel)
# x86-64 specific
target_link_options(moon PRIVATE -mno-red-zone)
2022-11-13 09:09:09 +00:00
2022-11-13 10:25:15 +00:00
set_target_properties(moon PROPERTIES CXX_STANDARD 20)
2022-11-13 09:09:09 +00:00
target_include_directories(moon PUBLIC ${LUNA_ROOT}/luna)
2022-11-13 09:30:10 +00:00
target_include_directories(moon PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src)
2022-11-13 09:09:09 +00:00
target_link_options(moon PRIVATE LINKER:-T ${CMAKE_CURRENT_LIST_DIR}/moon.ld -nostdlib -nodefaultlibs)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/moon" DESTINATION ${LUNA_ROOT}/initrd/boot)