@@ -11,8 +11,21 @@ set(CMAKE_ASM_NASM_FLAGS "-f elf32")
1111project (BasicallyLinux C ASM_NASM )
1212
1313# Toolchain configuration (can be overridden by command line)
14- set (CMAKE_C_COMPILER i686-linux -gnu-gcc)
15- set (CMAKE_ASM_NASM_COMPILER nasm)
14+ if (NOT CMAKE_C_COMPILER )
15+ find_program (C_COMPILER_I686 i686-linux-gnu-gcc )
16+ find_program (C_COMPILER_ELF i686-elf-gcc )
17+ if (C_COMPILER_I686)
18+ set (CMAKE_C_COMPILER ${C_COMPILER_I686} )
19+ elseif (C_COMPILER_ELF)
20+ set (CMAKE_C_COMPILER ${C_COMPILER_ELF} )
21+ else ()
22+ set (CMAKE_C_COMPILER gcc) # Fallback to system gcc
23+ endif ()
24+ endif ()
25+
26+ if (NOT CMAKE_ASM_NASM_COMPILER)
27+ set (CMAKE_ASM_NASM_COMPILER nasm)
28+ endif ()
1629
1730# Compilation flags for C files only
1831add_compile_options (
@@ -33,8 +46,23 @@ add_compile_options(
3346include_directories (include )
3447
3548# Source discovery
36- file (GLOB_RECURSE ASM_SOURCES "src/*.asm" )
37- file (GLOB_RECURSE C_SOURCES "src/*.c" )
49+ message (STATUS "Searching for sources in ${CMAKE_CURRENT_SOURCE_DIR} /src" )
50+ file (GLOB_RECURSE ASM_SOURCES "${CMAKE_CURRENT_SOURCE_DIR} /src/*.asm" )
51+ file (GLOB_RECURSE C_SOURCES "${CMAKE_CURRENT_SOURCE_DIR} /src/*.c" )
52+
53+ # Debugging: print found sources if they are empty
54+ if (NOT ASM_SOURCES AND NOT C_SOURCES)
55+ message (WARNING "No source files found in ${CMAKE_CURRENT_SOURCE_DIR} /src. Trying relative path..." )
56+ file (GLOB_RECURSE ASM_SOURCES "src/*.asm" )
57+ file (GLOB_RECURSE C_SOURCES "src/*.c" )
58+ endif ()
59+
60+ if (NOT ASM_SOURCES AND NOT C_SOURCES)
61+ message (FATAL_ERROR "No source files found in any search path!" )
62+ endif ()
63+
64+ message (STATUS "Found ${ASM_SOURCES} ASM files" )
65+ message (STATUS "Found ${C_SOURCES} C files" )
3866
3967# AI model blob handling
4068set (MODEL_BLOB "${CMAKE_CURRENT_SOURCE_DIR} /model.bin" )
@@ -54,10 +82,14 @@ if(EXISTS "${MODEL_BLOB}")
5482else ()
5583 message (WARNING "AI model blob not found. Kernel will be built without AI support." )
5684 set (MODEL_OBJ_PATH "" )
85+ add_compile_definitions (NO_AI_MODEL )
5786endif ()
5887
5988# Ensure boot.asm is ALWAYS FIRST in the link order to keep Multiboot header at the top
60- set (BOOT_ASM "${CMAKE_CURRENT_SOURCE_DIR} /src/boot.asm" )
89+ set (BOOT_ASM "${CMAKE_CURRENT_SOURCE_DIR} /src/arch/x86/boot.asm" )
90+ if (NOT EXISTS "${BOOT_ASM} " )
91+ message (FATAL_ERROR "Could not find boot.asm at ${BOOT_ASM} " )
92+ endif ()
6193list (REMOVE_ITEM ASM_SOURCES "${BOOT_ASM} " )
6294set (ASM_SOURCES "${BOOT_ASM} " ${ASM_SOURCES} )
6395
0 commit comments