57 lines
1.7 KiB
CMake
57 lines
1.7 KiB
CMake
project(yak-kernel)
|
|
|
|
set(CMAKE_SYSROOT "/does-not-exist")
|
|
|
|
option(USE_LIMINE "Enable support for the limine boot protocol" ON)
|
|
|
|
add_compile_options(
|
|
-ffreestanding
|
|
-fno-lto
|
|
-fno-pie
|
|
-fno-pic
|
|
-m64
|
|
--target=x86_64-pc-none-eabi
|
|
-mno-80387
|
|
-mno-mmx
|
|
-mno-sse
|
|
-mno-sse2
|
|
-mno-red-zone
|
|
-mcmodel=kernel
|
|
)
|
|
add_link_options(
|
|
-nostdlib
|
|
-static
|
|
-z max-page-size=0x1000
|
|
-T ${CMAKE_CURRENT_SOURCE_DIR}/linker.lds
|
|
)
|
|
|
|
FetchContent_Declare(printf_library
|
|
GIT_REPOSITORY https://github.com/eyalroz/printf.git
|
|
GIT_TAG v6.1.0)
|
|
FetchContent_GetProperties(printf_library)
|
|
if (NOT printf_library_POPULATED)
|
|
FetchContent_Populate(printf_library)
|
|
endif ()
|
|
|
|
|
|
if (NOT ${USE_LIMINE})
|
|
message(FATAL_ERROR "At least one boot protocol is required")
|
|
endif ()
|
|
|
|
file(GLOB KERNEL_SOURCES src/rt/*.c src/ulibc/*.c)
|
|
file(GLOB PLATFORM_GENERIC_SOURCES src/platform/generic/*.c)
|
|
|
|
if (${USE_LIMINE})
|
|
file(GLOB LIMINE_KERNEL_SOURCES src/rt/limine/*.c)
|
|
endif ()
|
|
if (NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/${CMAKE_SYSTEM_PROCESSOR})
|
|
message(FATAL_ERROR "Unknown architecture ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/${CMAKE_SYSTEM_PROCESSOR}")
|
|
endif ()
|
|
|
|
file(GLOB PLATFORM_SPECIFIC_SOURCES src/platform/x86_64/*.c)
|
|
|
|
set(KERNEL_SOURCE_FILES ${KERNEL_SOURCES} ${LIMINE_KERNEL_SOURCES} ${PLATFORM_GENERIC_SOURCES} ${PLATFORM_SPECIFIC_SOURCES})
|
|
|
|
add_executable(yak.elf ${KERNEL_SOURCE_FILES})
|
|
target_link_libraries(yak.elf PRIVATE /usr/lib/clang/15.0.7/lib/linux/libclang_rt.builtins-x86_64.a)
|
|
target_include_directories(yak.elf PRIVATE include ../limine/include ${printf_library_SOURCE_DIR}/src)# ${printf_library_SOURCE_DIR}/src) |