67 lines
2.1 KiB
CMake
67 lines
2.1 KiB
CMake
cmake_minimum_required(VERSION 3.15)
|
|
project(new_kernel C ASM)
|
|
set(CMAKE_C_STANDARD 99)
|
|
|
|
# Define compiler run time
|
|
SET(COMPILER_RT ${CMAKE_CURRENT_LIST_DIR}/compiler/target/bin)
|
|
SET(CMAKE_C_COMPILER ${COMPILER_RT}/i686-elf-gcc)
|
|
SET(CMAKE_ASM_COMPILER ${COMPILER_RT}/i686-elf-gcc)
|
|
|
|
# Optionally enable cmake debugging
|
|
#SET(CMAKE_VERBOSE_MAKEFILE ON)
|
|
|
|
# Set compile flags
|
|
SET(CMAKE_C_FLAGS "-g -ffreestanding -Wall -Wextra -fno-exceptions -fstack-protector -fno-pie -m32")
|
|
SET(CMAKE_ASM_FLAGS "${CFLAGS} -m32 -x assembler-with-cpp")
|
|
SET(CMAKE_EXE_LINKER_FLAGS "-T${CMAKE_CURRENT_LIST_DIR}/linker.ld -nostdlib -lgcc")
|
|
|
|
# Include directory
|
|
include_directories(AFTER include)
|
|
|
|
################
|
|
# Features #
|
|
################
|
|
|
|
set(ENABLE_ACPI ON CACHE BOOL "Enable ACPI Suppport")
|
|
|
|
####################
|
|
# ACPI Feature #
|
|
####################
|
|
if (ENABLE_ACPI)
|
|
include_directories(AFTER lai/include)
|
|
FILE(GLOB lai lai/core/*.c lai/helpers/*.c lai/driver/*.c)
|
|
ELSE()
|
|
set(lai)
|
|
endif ()
|
|
|
|
# Other sourcees
|
|
FILE(GLOB_RECURSE kernel_src kernel/**.c)
|
|
FILE(GLOB_RECURSE kernel_asm kernel/**.S)
|
|
FILE(GLOB_RECURSE boot_asm boot/boot.S)
|
|
|
|
add_compile_definitions(__kernel__)
|
|
|
|
#######################
|
|
# Kernel Features #
|
|
#######################
|
|
|
|
# ACPI
|
|
if (ENABLE_ACPI)
|
|
add_compile_definitions(ENABLE_ACPI)
|
|
endif ()
|
|
|
|
# Run IDE in DMA mode if available (NYI)
|
|
#add_compile_definitions(IDE_ENABLE_INTERRUPT)
|
|
# Kernel Command Line features
|
|
add_compile_definitions(ENABLE_K_SHELL) # Run the kernel shell as the main task
|
|
add_compile_definitions(ENABLE_SELF_TEST) # Compile in self test kernel CLI command
|
|
add_compile_definitions(ENABLE_PCIPP) # Support for pretty printing pci class/subclass/interface
|
|
|
|
# find libgcc.a
|
|
add_library(libgcc STATIC IMPORTED)
|
|
set_target_properties(libgcc PROPERTIES IMPORTED_LOCATION ${COMPILER_RT}/../lib/gcc/i686-elf/10.2.0/libgcc.a)
|
|
|
|
add_executable(my-kernel.bin ${kernel_src} ${kernel_asm} ${boot_asm} ${lai})
|
|
target_link_libraries(my-kernel.bin libgcc)
|
|
set_source_files_properties(${kernel_src} PROPERTIES LANGUAGE C COMPILE_FLAGS "")
|
|
set_target_properties(my-kernel.bin PROPERTIES LINKER_LANGUAGE C PREFIX "" SUFFIX "" LINK_FLAGS "") |