diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2023-10-07 11:31:42 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2023-10-07 11:31:42 +0200 |
| commit | 0942321b4f09db58927dcd56940785567e19db92 (patch) | |
| tree | 496fa2db10dff18ae54c973592ee6d273877d2d0 /source | |
| parent | 090ba239c5c71c765706019fa2733ed2b28ece8f (diff) | |
| download | teachos-0942321b4f09db58927dcd56940785567e19db92.tar.xz teachos-0942321b4f09db58927dcd56940785567e19db92.zip | |
build: perform cleaner split for platform settings
Diffstat (limited to 'source')
| -rw-r--r-- | source/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | source/boot/CMakeLists.txt | 15 | ||||
| -rw-r--r-- | source/boot/arch/x86_64/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | source/kernel/CMakeLists.txt | 33 | ||||
| -rw-r--r-- | source/kernel/arch/x86_64/CMakeLists.txt | 30 |
5 files changed, 60 insertions, 24 deletions
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 80b566e..0ae9e40 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -7,5 +7,5 @@ project("kernel" LANGUAGES ASM C CXX ) -add_subdirectory("boot/arch/${CMAKE_SYSTEM_PROCESSOR}") +add_subdirectory("boot") add_subdirectory("kernel") diff --git a/source/boot/CMakeLists.txt b/source/boot/CMakeLists.txt new file mode 100644 index 0000000..5591d70 --- /dev/null +++ b/source/boot/CMakeLists.txt @@ -0,0 +1,15 @@ +#[============================================================================[ +# Configure the generic settings for the bootstrapping library. +# +# All the settings (e.g. include paths, linker flags, etc.) applied in this +# directly, are expected to be platform independent. +#]============================================================================] + +add_library("_boot" STATIC) +add_library("teachos::boot" ALIAS "_boot") + +#[============================================================================[ +# Apply the platform dependent settings to the bootstrapping library. +#]============================================================================] + +add_subdirectory("arch/${CMAKE_SYSTEM_PROCESSOR}")
\ No newline at end of file diff --git a/source/boot/arch/x86_64/CMakeLists.txt b/source/boot/arch/x86_64/CMakeLists.txt index 454f347..0fd6539 100644 --- a/source/boot/arch/x86_64/CMakeLists.txt +++ b/source/boot/arch/x86_64/CMakeLists.txt @@ -1,8 +1,6 @@ -add_library("boot" STATIC +target_sources("_boot" PRIVATE "src/boot.s" "src/crti.s" "src/crtn.s" "src/multiboot.s" ) - -add_library("teachos::boot" ALIAS "boot")
\ No newline at end of file diff --git a/source/kernel/CMakeLists.txt b/source/kernel/CMakeLists.txt index 48c9e4a..64b5bcf 100644 --- a/source/kernel/CMakeLists.txt +++ b/source/kernel/CMakeLists.txt @@ -1,9 +1,11 @@ -set(TEACHOS_KERNEL_LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/arch/${CMAKE_SYSTEM_PROCESSOR}/kern.ld") -mark_as_advanced(TEACHOS_KERNEL_LINKER_SCRIPT) +#[============================================================================[ +# Configure the generic settings for the kernel image. +# +# All the settings (e.g. include paths, linker flags, etc.) applied in this +# directly, are expected to be platform independent. +#]============================================================================] -add_executable("kernel" - "arch/${CMAKE_SYSTEM_PROCESSOR}/src/entry.cpp" -) +add_executable("kernel") target_compile_features("kernel" PRIVATE "cxx_std_20" @@ -16,22 +18,13 @@ target_compile_options("kernel" PRIVATE "$<$<CXX_COMPILER_ID:GNU>:-pedantic-errors>" ) -target_include_directories("kernel" PRIVATE - "arch/${CMAKE_SYSTEM_PROCESSOR}/include" -) - -target_link_options("kernel" PRIVATE - "-T${TEACHOS_KERNEL_LINKER_SCRIPT}" -) - -target_link_libraries("kernel" PRIVATE - "-Wl,--whole-archive" - "teachos::boot" - "-Wl,--no-whole-archive" -) - set_target_properties("kernel" PROPERTIES CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED YES - LINK_DEPENDS "${TEACHOS_KERNEL_LINKER_SCRIPT}" ) + +#[============================================================================[ +# Apply the platform dependent settings to the kernel image. +#]============================================================================] + +add_subdirectory("arch/${CMAKE_SYSTEM_PROCESSOR}")
\ No newline at end of file diff --git a/source/kernel/arch/x86_64/CMakeLists.txt b/source/kernel/arch/x86_64/CMakeLists.txt new file mode 100644 index 0000000..04701c6 --- /dev/null +++ b/source/kernel/arch/x86_64/CMakeLists.txt @@ -0,0 +1,30 @@ +#[============================================================================[ +# x86_64 specific configuration for the kernel image. +#]============================================================================] + +set(TEACHOS_KERNEL_LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/kern.ld") +mark_as_advanced(TEACHOS_KERNEL_LINKER_SCRIPT) + +target_sources("kernel" PRIVATE + "src/entry.cpp" +) + +target_include_directories("kernel" PRIVATE + "include" +) + +target_link_options("kernel" PRIVATE + "-T${TEACHOS_KERNEL_LINKER_SCRIPT}" +) + +target_link_libraries("kernel" PRIVATE + "-Wl,--whole-archive" + "teachos::boot" + "-Wl,--no-whole-archive" +) + +set_target_properties("kernel" PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD_REQUIRED YES + LINK_DEPENDS "${TEACHOS_KERNEL_LINKER_SCRIPT}" +) |
