From fd4700d7b73d341faad2a2bdd9e3303ee96ee5d0 Mon Sep 17 00:00:00 2001 From: Stephanos Ioannidis Date: Sat, 11 Sep 2021 22:06:28 +0900 Subject: [PATCH] cmake: compiler: Add framework for disabling C++ standard includes This commit adds a new C++ compiler property `nostdincxx` which specifies the C++ compiler flag for excluding the C++ standard library include directory from the include paths. Signed-off-by: Stephanos Ioannidis --- CMakeLists.txt | 6 +++++- cmake/compiler/compiler_flags_template.cmake | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21426bb3914..d41684ddfbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1675,13 +1675,17 @@ if((CMAKE_BUILD_TYPE IN_LIST build_types) AND (NOT NO_BUILD_TYPE_WARNING)) endif() endif() -# @Intent: Set compiler specific flags for standard C includes +# @Intent: Set compiler specific flags for standard C/C++ includes # Done at the very end, so any other system includes which may # be added by Zephyr components were first in list. # Note, the compile flags are moved, but the system include is still present here. zephyr_compile_options($) target_include_directories(zephyr_interface SYSTEM INTERFACE $) +if(NOT CONFIG_LIB_CPLUSPLUS) + zephyr_compile_options($<$:$>) +endif() + # Finally export all build flags from Zephyr add_subdirectory_ifdef( CONFIG_MAKEFILE_EXPORTS diff --git a/cmake/compiler/compiler_flags_template.cmake b/cmake/compiler/compiler_flags_template.cmake index 9d609a7acdb..4900a759465 100644 --- a/cmake/compiler/compiler_flags_template.cmake +++ b/cmake/compiler/compiler_flags_template.cmake @@ -50,6 +50,9 @@ set_compiler_property(PROPERTY cstd) set_compiler_property(PROPERTY nostdinc) set_compiler_property(PROPERTY nostdinc_include) +# Compiler flags for disabling C++ standard include. +set_compiler_property(TARGET compiler-cpp PROPERTY nostdincxx) + # Required C++ flags when compiling C++ code set_property(TARGET compiler-cpp PROPERTY required)