diff --git a/cmake/onnxruntime_common.cmake b/cmake/onnxruntime_common.cmake index 906f0271c1..687a231e05 100644 --- a/cmake/onnxruntime_common.cmake +++ b/cmake/onnxruntime_common.cmake @@ -87,8 +87,10 @@ source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_common_src}) onnxruntime_add_static_library(onnxruntime_common ${onnxruntime_common_src}) if(WIN32) - set_property(TARGET onnxruntime_common PROPERTY CXX_STANDARD 23) - target_compile_options(onnxruntime_common PRIVATE "/Zc:char8_t-") + if("cxx_std_23" IN_LIST CMAKE_CXX_COMPILE_FEATURES) + set_property(TARGET onnxruntime_common PROPERTY CXX_STANDARD 23) + target_compile_options(onnxruntime_common PRIVATE "/Zc:char8_t-") + endif() endif() if (onnxruntime_USE_TELEMETRY) set_target_properties(onnxruntime_common PROPERTIES COMPILE_FLAGS "/FI${ONNXRUNTIME_INCLUDE_DIR}/core/platform/windows/TraceLoggingConfigPrivate.h") diff --git a/onnxruntime/core/platform/windows/stacktrace.cc b/onnxruntime/core/platform/windows/stacktrace.cc index 2def304638..cac6f4f290 100644 --- a/onnxruntime/core/platform/windows/stacktrace.cc +++ b/onnxruntime/core/platform/windows/stacktrace.cc @@ -5,6 +5,11 @@ #include #include #include +#ifdef __has_include +#if __has_include() +#include +#endif +#endif #include #include "core/common/logging/logging.h" @@ -27,7 +32,7 @@ class CaptureStackTrace { std::vector GetStackTrace() { #ifndef NDEBUG // TVM need to run with shared CRT, so won't work with debug helper now -#if !(defined _OPSCHEMA_LIB_) && !(defined _GAMING_XBOX) +#if (defined __cpp_lib_stacktrace) && !(defined _OPSCHEMA_LIB_) && !(defined _GAMING_XBOX) && !(defined ONNXRUNTIME_ENABLE_MEMLEAK_CHECK) return detail::CaptureStackTrace().Trace(); #else return {}; @@ -39,7 +44,7 @@ std::vector GetStackTrace() { namespace detail { #ifndef NDEBUG -#if !(defined _OPSCHEMA_LIB_) && !(defined _GAMING_XBOX) +#if (defined __cpp_lib_stacktrace) && !(defined _OPSCHEMA_LIB_) && !(defined _GAMING_XBOX) && !(defined ONNXRUNTIME_ENABLE_MEMLEAK_CHECK) std::vector CaptureStackTrace::Trace() const { std::vector stacktrace;