Skip to content

Commit cbceeb4

Browse files
stephanosiotpambor
authored andcommitted
cmake: toolchain: Introduce TOOLCHAIN_HAS_GLIBCXX
This commit introduces `TOOLCHAIN_HAS_GLIBCXX` CMake variable, which is set to `y` when GNU C++ Standard Library aka. libstdc++ is available. This helps filter libstdc++-specific Kconfig and tests in a more refined manner. Signed-off-by: Stephanos Ioannidis <[email protected]>
1 parent 3310600 commit cbceeb4

File tree

6 files changed

+17
-2
lines changed

6 files changed

+17
-2
lines changed

cmake/modules/kconfig.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ else()
129129
set(_local_TOOLCHAIN_HAS_PICOLIBC n)
130130
endif()
131131

132+
if(TOOLCHAIN_HAS_GLIBCXX)
133+
set(_local_TOOLCHAIN_HAS_GLIBCXX y)
134+
else()
135+
set(_local_TOOLCHAIN_HAS_GLIBCXX n)
136+
endif()
137+
132138
# APP_DIR: Path to the main image (sysbuild) or synonym for APPLICATION_SOURCE_DIR (non-sysbuild)
133139
zephyr_get(APP_DIR VAR APP_DIR APPLICATION_SOURCE_DIR)
134140

@@ -157,6 +163,7 @@ set(COMMON_KCONFIG_ENV_SETTINGS
157163
TOOLCHAIN_KCONFIG_DIR=${TOOLCHAIN_KCONFIG_DIR}
158164
TOOLCHAIN_HAS_NEWLIB=${_local_TOOLCHAIN_HAS_NEWLIB}
159165
TOOLCHAIN_HAS_PICOLIBC=${_local_TOOLCHAIN_HAS_PICOLIBC}
166+
TOOLCHAIN_HAS_GLIBCXX=${_local_TOOLCHAIN_HAS_GLIBCXX}
160167
EDT_PICKLE=${EDT_PICKLE}
161168
# Export all Zephyr modules to Kconfig
162169
${ZEPHYR_KCONFIG_MODULES_DIR}

cmake/toolchain/espressif/generic.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,4 @@ if(NOT CROSS_COMPILE_TARGET)
5454
endif()
5555

5656
set(TOOLCHAIN_HAS_NEWLIB ON CACHE BOOL "True if toolchain supports newlib")
57+
set(TOOLCHAIN_HAS_GLIBCXX ON CACHE BOOL "True if toolchain supports libstdc++")

cmake/toolchain/gnuarmemb/generic.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ set(SYSROOT_TARGET arm-none-eabi)
1818

1919
set(CROSS_COMPILE ${TOOLCHAIN_HOME}/bin/${CROSS_COMPILE_TARGET}-)
2020
set(SYSROOT_DIR ${TOOLCHAIN_HOME}/${SYSROOT_TARGET})
21+
2122
set(TOOLCHAIN_HAS_NEWLIB ON CACHE BOOL "True if toolchain supports newlib")
23+
set(TOOLCHAIN_HAS_GLIBCXX ON CACHE BOOL "True if toolchain supports libstdc++")
2224

2325
message(STATUS "Found toolchain: gnuarmemb (${GNUARMEMB_TOOLCHAIN_PATH})")

cmake/toolchain/host/generic.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ set(LINKER ld)
55
set(BINTOOLS host-gnu)
66

77
set(TOOLCHAIN_HAS_NEWLIB OFF CACHE BOOL "True if toolchain supports newlib")
8+
set(TOOLCHAIN_HAS_GLIBCXX ON CACHE BOOL "True if toolchain supports libstdc++")
89

910
message(STATUS "Found toolchain: host (gcc/ld)")

cmake/toolchain/zephyr/generic.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ include(${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr/generic.cmake)
44

55
set(TOOLCHAIN_KCONFIG_DIR ${ZEPHYR_SDK_INSTALL_DIR}/cmake/zephyr)
66

7-
message(STATUS "Found toolchain: zephyr ${SDK_VERSION} (${ZEPHYR_SDK_INSTALL_DIR})")
7+
# Zephyr SDK < 0.17.1 does not set TOOLCHAIN_HAS_GLIBCXX
8+
set(TOOLCHAIN_HAS_GLIBCXX ON CACHE BOOL "True if toolchain supports libstdc++")
9+
10+
message(STATUS "Found toolchain: zephyr-sdk-gnu ${SDK_VERSION} (${ZEPHYR_SDK_INSTALL_DIR})")

lib/cpp/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ choice LIBCPP_IMPLEMENTATION
102102
prompt "C++ Standard Library Implementation"
103103
default EXTERNAL_LIBCPP if REQUIRES_FULL_LIBCPP && NATIVE_BUILD
104104
default LIBCXX_LIBCPP if REQUIRES_FULL_LIBCPP && "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "llvm"
105-
default GLIBCXX_LIBCPP if REQUIRES_FULL_LIBCPP
105+
default GLIBCXX_LIBCPP if REQUIRES_FULL_LIBCPP && "$(TOOLCHAIN_HAS_GLIBCXX)" = "y"
106106
default MINIMAL_LIBCPP
107107

108108
config MINIMAL_LIBCPP
@@ -117,6 +117,7 @@ config MINIMAL_LIBCPP
117117

118118
config GLIBCXX_LIBCPP
119119
bool "GNU C++ Standard Library"
120+
depends on "$(TOOLCHAIN_HAS_GLIBCXX)" = "y"
120121
depends on NEWLIB_LIBC || PICOLIBC
121122
select FULL_LIBCPP_SUPPORTED
122123
help

0 commit comments

Comments
 (0)