From 8902032b4255d10876e61b985e30f03bd1f6fb24 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 18 Aug 2024 20:44:12 +0300 Subject: [PATCH] BuildSystem: Cleanup kernel cmake file --- kernel/CMakeLists.txt | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index 350045ec08..104e0f192c 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -175,35 +175,42 @@ set(KERNEL_SOURCES add_executable(kernel ${KERNEL_SOURCES}) -target_compile_definitions(kernel PUBLIC __is_kernel) +target_compile_definitions(kernel PRIVATE __is_kernel) target_compile_definitions(kernel PRIVATE __arch=${BANAN_ARCH}) target_compile_definitions(kernel PRIVATE __enable_sse=${BANAN_ENABLE_SSE}) -if (NOT BANAN_ENABLE_SSE) - target_compile_options(kernel PRIVATE -mno-sse -mno-sse2) -endif () -target_compile_options(kernel PUBLIC -O2 -g) -target_compile_options(kernel PUBLIC $<$:-Wno-literal-suffix -fno-rtti -fno-exceptions>) -target_compile_options(kernel PUBLIC -fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.) -target_compile_options(kernel PUBLIC -fstack-protector -ffreestanding -fno-omit-frame-pointer -fstrict-volatile-bitfields -mgeneral-regs-only) -target_compile_options(kernel PUBLIC -Wall -Wextra -Werror -Wstack-usage=1024) +target_compile_options(kernel PRIVATE + -O2 -g + -fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=. + -fstack-protector + -ffreestanding + -fno-omit-frame-pointer + -fstrict-volatile-bitfields + -mgeneral-regs-only + -Wall -Wextra -Werror -Wstack-usage=1024 +) # This might not work with other toolchains -target_compile_options(kernel PUBLIC $<$:-Wno-invalid-offsetof>) +target_compile_options(kernel PRIVATE $<$: + -Wno-literal-suffix + -Wno-invalid-offsetof + -fno-rtti + -fno-exceptions> +) if(ENABLE_KERNEL_UBSAN) - target_compile_options(kernel PUBLIC -fsanitize=undefined) + target_compile_options(kernel PRIVATE -fsanitize=undefined) endif() if("${BANAN_ARCH}" STREQUAL "x86_64") - target_compile_options(kernel PUBLIC -mcmodel=kernel -mno-red-zone) - target_link_options(kernel PUBLIC LINKER:-z,max-page-size=4096) - target_link_options(kernel PUBLIC LINKER:-T,${CMAKE_CURRENT_SOURCE_DIR}/arch/x86_64/linker.ld) + target_compile_options(kernel PRIVATE -mcmodel=kernel -mno-red-zone) + target_link_options(kernel PRIVATE LINKER:-z,max-page-size=4096) + target_link_options(kernel PRIVATE LINKER:-T,${CMAKE_CURRENT_SOURCE_DIR}/arch/x86_64/linker.ld) elseif("${BANAN_ARCH}" STREQUAL "i686") - target_link_options(kernel PUBLIC LINKER:-T,${CMAKE_CURRENT_SOURCE_DIR}/arch/i686/linker.ld) + target_link_options(kernel PRIVATE LINKER:-T,${CMAKE_CURRENT_SOURCE_DIR}/arch/i686/linker.ld) endif() -target_link_options(kernel PUBLIC -ffreestanding -nostdlib) +target_link_options(kernel PRIVATE -ffreestanding -nostdlib) execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=crtbegin.o OUTPUT_VARIABLE CRTBEGIN OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=crtend.o OUTPUT_VARIABLE CRTEND OUTPUT_STRIP_TRAILING_WHITESPACE)