mirror of
https://github.com/johndoe6345789/MetalOS.git
synced 2026-04-24 13:45:02 +00:00
Fix CMake kernel build and clarify SMP support in ROADMAP
- Fix kernel/CMakeLists.txt to find source files in src/ directory - Add NASM support to CMake for assembling .asm files - Update ROADMAP.md to reflect that SMP is intentionally included - CMake and Makefile now consistent in handling kernel sources Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
@@ -327,10 +327,10 @@ MetalOS is **the absolute minimum operating system** needed to boot QT6 Hello Wo
|
||||
4. **Dynamic Linking**: ❌ Not needed
|
||||
- Static link everything for simplicity
|
||||
|
||||
5. **SMP**: ⚠️ Basic support implemented
|
||||
- Basic multicore/SMP framework in place for learning
|
||||
- Single core is sufficient for hello world
|
||||
- Can be simplified later if needed
|
||||
5. **SMP**: ✅ Included
|
||||
- Multicore/SMP support implemented
|
||||
- Enables better performance and learning opportunities
|
||||
- Not strictly necessary but adds value
|
||||
|
||||
6. **ACPI**: ✅ Implemented
|
||||
- RSDP discovery in bootloader
|
||||
|
||||
@@ -6,22 +6,38 @@ cmake_minimum_required(VERSION 3.16)
|
||||
project(MetalOS_Kernel C ASM)
|
||||
|
||||
# Source files
|
||||
file(GLOB KERNEL_C_SOURCES "src/*.c")
|
||||
file(GLOB KERNEL_ASM_SOURCES "src/*.asm")
|
||||
|
||||
set(KERNEL_SOURCES
|
||||
src/main.c
|
||||
${KERNEL_C_SOURCES}
|
||||
)
|
||||
|
||||
# Find all source files in subdirectories
|
||||
file(GLOB_RECURSE CORE_SOURCES "src/core/*.c")
|
||||
file(GLOB_RECURSE HAL_SOURCES "src/hal/*.c")
|
||||
file(GLOB_RECURSE DRIVER_SOURCES "src/drivers/*.c")
|
||||
file(GLOB_RECURSE SYSCALL_SOURCES "src/syscall/*.c")
|
||||
|
||||
list(APPEND KERNEL_SOURCES
|
||||
${CORE_SOURCES}
|
||||
${HAL_SOURCES}
|
||||
${DRIVER_SOURCES}
|
||||
${SYSCALL_SOURCES}
|
||||
)
|
||||
# Find NASM assembler
|
||||
find_program(NASM nasm)
|
||||
if(NOT NASM)
|
||||
message(WARNING "NASM not found - assembly files will not be built")
|
||||
message(WARNING "Install NASM: sudo apt-get install nasm")
|
||||
else()
|
||||
message(STATUS "Found NASM: ${NASM}")
|
||||
|
||||
# Assemble each .asm file
|
||||
set(KERNEL_ASM_OBJECTS "")
|
||||
foreach(asm_file ${KERNEL_ASM_SOURCES})
|
||||
get_filename_component(asm_name ${asm_file} NAME_WE)
|
||||
set(asm_obj "${CMAKE_CURRENT_BINARY_DIR}/${asm_name}.o")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${asm_obj}
|
||||
COMMAND ${NASM} -f elf64 ${asm_file} -o ${asm_obj}
|
||||
DEPENDS ${asm_file}
|
||||
COMMENT "Assembling ${asm_name}.asm"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
list(APPEND KERNEL_ASM_OBJECTS ${asm_obj})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Compiler flags for kernel
|
||||
set(KERNEL_CFLAGS
|
||||
@@ -41,7 +57,7 @@ target_include_directories(kernel_obj PRIVATE include)
|
||||
target_compile_options(kernel_obj PRIVATE ${KERNEL_CFLAGS})
|
||||
|
||||
# Create kernel binary
|
||||
add_executable(kernel_elf $<TARGET_OBJECTS:kernel_obj>)
|
||||
add_executable(kernel_elf $<TARGET_OBJECTS:kernel_obj> ${KERNEL_ASM_OBJECTS})
|
||||
set_target_properties(kernel_elf PROPERTIES
|
||||
OUTPUT_NAME metalos.elf
|
||||
LINKER_LANGUAGE C
|
||||
|
||||
Reference in New Issue
Block a user