diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5e6ee15 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.16) +project(BarinkOS LANGUAGES C CXX ASM) + +add_subdirectory(CoreLib) +add_subdirectory(Kernel) diff --git a/CoreLib/CMakeLists.txt b/CoreLib/CMakeLists.txt new file mode 100644 index 0000000..24ec53e --- /dev/null +++ b/CoreLib/CMakeLists.txt @@ -0,0 +1,14 @@ +project(CoreLib LANGUAGES CXX) + +set(SOURCES + ctype.cpp + Memory.cpp + Path.cpp + Stack.cpp + String.cpp + StringView.cpp +) + +add_library(CoreLib STATIC ${SOURCES}) + +target_include_directories(CoreLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt new file mode 100644 index 0000000..70bb459 --- /dev/null +++ b/kernel/CMakeLists.txt @@ -0,0 +1,13 @@ + +project(Kernel LANGUAGES C CXX ASM) + +set(SOURCES + main.cpp + boot.s +) + +add_executable(kernel.elf ${SOURCES}) +target_link_libraries(kernel.elf PRIVATE CoreLib) +set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/link.ld) +target_link_options(kernel.elf PRIVATE "-T${LINKER_SCRIPT}") + diff --git a/toolchain-i686-elf.cmake b/toolchain-i686-elf.cmake new file mode 100644 index 0000000..634d550 --- /dev/null +++ b/toolchain-i686-elf.cmake @@ -0,0 +1,17 @@ +# toolchain-i686-elf.cmake +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR i686) + +# Point to your custom cross tools +set(CMAKE_C_COMPILER /opt/cross/bin/i686-elf-gcc) +set(CMAKE_CXX_COMPILER /opt/cross/bin/i686-elf-g++) +set(CMAKE_ASM_COMPILER /opt/cross/bin/i686-elf-as) +set(CMAKE_AR /opt/cross/bin/i686-elf-ar) +set(CMAKE_RANLIB /opt/cross/bin/i686-elf-ranlib) +set(CMAKE_C_COMPILER_WORKS TRUE) +set(CMAKE_CXX_COMPILER_WORKS TRUE) + +# Flags for freestanding OS development +set(CMAKE_C_FLAGS "-ffreestanding -Og -ggdb -Wall -Wextra") +set(CMAKE_CXX_FLAGS "-ffreestanding -Og -ggdb -Wall -Wextra") +