Skip to content

Commit fd4700d

Browse files
stephanosionashif
authored andcommitted
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 <[email protected]>
1 parent 80681d2 commit fd4700d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,13 +1675,17 @@ if((CMAKE_BUILD_TYPE IN_LIST build_types) AND (NOT NO_BUILD_TYPE_WARNING))
16751675
endif()
16761676
endif()
16771677

1678-
# @Intent: Set compiler specific flags for standard C includes
1678+
# @Intent: Set compiler specific flags for standard C/C++ includes
16791679
# Done at the very end, so any other system includes which may
16801680
# be added by Zephyr components were first in list.
16811681
# Note, the compile flags are moved, but the system include is still present here.
16821682
zephyr_compile_options($<TARGET_PROPERTY:compiler,nostdinc>)
16831683
target_include_directories(zephyr_interface SYSTEM INTERFACE $<TARGET_PROPERTY:compiler,nostdinc_include>)
16841684

1685+
if(NOT CONFIG_LIB_CPLUSPLUS)
1686+
zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:$<TARGET_PROPERTY:compiler-cpp,nostdincxx>>)
1687+
endif()
1688+
16851689
# Finally export all build flags from Zephyr
16861690
add_subdirectory_ifdef(
16871691
CONFIG_MAKEFILE_EXPORTS

cmake/compiler/compiler_flags_template.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ set_compiler_property(PROPERTY cstd)
5050
set_compiler_property(PROPERTY nostdinc)
5151
set_compiler_property(PROPERTY nostdinc_include)
5252

53+
# Compiler flags for disabling C++ standard include.
54+
set_compiler_property(TARGET compiler-cpp PROPERTY nostdincxx)
55+
5356
# Required C++ flags when compiling C++ code
5457
set_property(TARGET compiler-cpp PROPERTY required)
5558

0 commit comments

Comments
 (0)