I'm unsure if I have my toolchain properly configured
I plan on this being a fully-fledged OS so I set up my `CMakeLists.txt` in the top level directory like:
Code: Select all
cmake_minimum_required(VERSION 3.20)
project(NakOS)
add_subdirectory(Kernel)
Code: Select all
set(KERNEL_SOURCES
${CMAKE_SOURCE_DIR/Boot/boot.s} # Bootstrapped Assembly
${CMAKE_SOURCE_DIR/Kernel/src/kernel_main.cpp}
)
add_executable(nak ${KERNEL_SOURCES})
target_include_directories(nak PUBLIC ${CMAKE_SOURCE_DIR} )
target_compile_options(nak PRIVATE
$<$<CONFIG:Debug>:
-fsanitize=address,leak,undefined -pedantic -Wall -Wextra -Wundef -Werror -Wno-unused-parameter -ffreestanding -fno-exceptions -fno-rtti
>
)
target_link_options(nak PRIVATE
$<$<CONFIG:Debug>:
-fsanitize=address,leak,undefined -ffreestanding -nostdlib -T loader.ld -T ${CMAKE_CURRENT_SOURCE_DIR}/Boot/loader.ld # specifies linker script
>
)
target_compile_features(nak
PRIVATE
cxx_std_20
)
Code: Select all
#/bin/bash
export PREFIX="$HOME/opt/cross"
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"
# Use the cross compiler
export CXX="$HOME/opt/cross/bin/$TARGET-gcc"
Code: Select all
set(CMAKE_SYSTEM_PROCESSOR i686)
set(CMAKE_C_COMPILER ${CMAKE_SOURCE_DIR}/Toolchain/opt/cross/bin/i686-elf-gcc)
set(CMAKE_CXX_COMPILER ${CMAKE_SOURCE_DIR}/Toolchain/opt/cross/bin/i686-elf-g++)
Code: Select all
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 . -GNinja -DCMAKE_TOOLCHAIN_FILE=Toolchain/os-dev-toolchain.cmake