Luna/kernel/CMakeLists.txt
apio 139c0b5eb1
Kernel: Make a UserVM wrapper around Bitmap and use that to allocate user VM
This lets us allocate more than one page of memory from the user side.
2023-01-13 19:05:20 +01:00

95 lines
3.0 KiB
CMake

# The Moon kernel for Luna.
set(SOURCES
src/main.cpp
src/Log.cpp
src/cxxabi.cpp
src/video/Framebuffer.cpp
src/video/TextConsole.cpp
src/memory/MemoryManager.cpp
src/memory/Heap.cpp
src/memory/KernelVM.cpp
src/memory/UserVM.cpp
src/memory/MemoryMap.cpp
src/boot/Init.cpp
src/arch/Serial.cpp
src/arch/Timer.cpp
src/thread/Spinlock.cpp
src/thread/Thread.cpp
src/thread/Scheduler.cpp
src/sys/Syscall.cpp
src/sys/exit.cpp
src/sys/console_write.cpp
src/sys/clock_gettime.cpp
src/sys/allocate_memory.cpp
src/InitRD.cpp
src/ELF.cpp
)
if("${ARCH}" MATCHES "x86_64")
set(SOURCES
${SOURCES}
src/arch/x86_64/IO.cpp
src/arch/x86_64/Serial.cpp
src/arch/x86_64/MMU.cpp
src/arch/x86_64/CPU.cpp
src/arch/x86_64/Timer.cpp
src/arch/x86_64/Thread.cpp
src/arch/x86_64/init/GDT.cpp
src/arch/x86_64/init/IDT.cpp
src/arch/x86_64/init/PIC.cpp
)
endif()
add_executable(moon ${SOURCES})
if("${ARCH}" MATCHES "x86_64")
set(ASM_SOURCES
src/arch/x86_64/CPU.asm
src/arch/x86_64/Entry.asm
)
add_library(moon-asm STATIC ${ASM_SOURCES})
target_link_libraries(moon moon-asm)
endif()
target_link_libraries(moon luna-freestanding)
target_compile_definitions(moon PRIVATE IN_MOON)
target_compile_options(moon PRIVATE -Os)
target_compile_options(moon PRIVATE -Wall -Wextra -Werror -Wvla -Wsign-conversion)
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)
if("${ARCH}" MATCHES "x86_64")
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 -mno-red-zone)
endif()
if(MOON_DEBUG_SYMBOLS)
message(STATUS "Building Moon with debug symbols")
target_compile_options(moon PRIVATE -ggdb)
include(debug.cmake)
endif()
target_link_options(moon PRIVATE -lgcc -Wl,--build-id=none -z max-page-size=0x1000 -mcmodel=kernel)
set_target_properties(moon PROPERTIES CXX_STANDARD 20)
target_include_directories(moon PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src)
target_include_directories(moon PRIVATE ${LUNA_BASE}/usr/include)
configure_file(src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/gen/config.h @ONLY)
target_include_directories(moon PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/gen)
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)