From ba42d741cb3b4adbe117a1d3da1b1fc7ba0f1509 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 11 Feb 2021 21:20:10 +0100 Subject: [PATCH] Kernel: Add explicit __serenity__ define to workaround CLion problem CLion doesn't understand that we switch compilers mid-build (which I can understand since it's a bit unusual.) Defining __serenity__ makes the majority of IDE features work correctly in the kernel context. --- Kernel/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index 8f9d6ec94f4..c107f0583a3 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -300,13 +300,19 @@ foreach(flag IN LISTS KERNEL_FSANITIZE_FLAGS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${flag}") endforeach() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option -DKERNEL") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pie -fPIE -fno-rtti -ffreestanding -fbuiltin") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-80387 -mno-mmx -mno-sse -mno-sse2") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-asynchronous-unwind-tables") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib -nostdinc -nostdinc++") +add_compile_definitions(KERNEL) + +# HACK: This is a workaround for CLion to grok the kernel sources. +# It's needed because CLion doesn't understand the way we switch compilers mid-build. +add_compile_definitions(__serenity__) + add_link_options(LINKER:-T ${CMAKE_CURRENT_BINARY_DIR}/linker.ld -nostdlib) add_library(boot OBJECT Arch/i386/Boot/boot.S)