diff --git a/CMakeLists.txt b/CMakeLists.txt index efc10de2503..33c1899b523 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -230,9 +230,8 @@ if(NOT CONFIG_NATIVE_APPLICATION) endif() if(CONFIG_LIB_CPLUSPLUS) -zephyr_ld_options( - -lstdc++ -) + # @Intent: Set linker specific flags for C++ + toolchain_ld_cpp() endif() # ========================================================================== diff --git a/cmake/linker/ld/target.cmake b/cmake/linker/ld/target.cmake index ae5b2834448..2dbd87cf945 100644 --- a/cmake/linker/ld/target.cmake +++ b/cmake/linker/ld/target.cmake @@ -7,3 +7,4 @@ set_ifndef(LINKERFLAGPREFIX -Wl) # Load toolchain_ld-family macros include(${ZEPHYR_BASE}/cmake/linker/${LINKER}/target_base.cmake) include(${ZEPHYR_BASE}/cmake/linker/${LINKER}/target_baremetal.cmake) +include(${ZEPHYR_BASE}/cmake/linker/${LINKER}/target_cpp.cmake) diff --git a/cmake/linker/ld/target_cpp.cmake b/cmake/linker/ld/target_cpp.cmake new file mode 100644 index 00000000000..89dca592ccc --- /dev/null +++ b/cmake/linker/ld/target_cpp.cmake @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: Apache-2.0 + +# See root CMakeLists.txt for description and expectations of these macros + +macro(toolchain_ld_cpp) + + zephyr_ld_options( + -lstdc++ + ) + +endmacro()