From 863cde8c19d63177da2212f06a0b7d93279e04c9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Apr 2024 17:45:01 -0400 Subject: Intel: Fix detection of C++ 14/17 modes on Linux/macOS The Intel Classic C++ compiler is based on EDG. It does not always define `__cplusplus` correctly, but does define feature macros that we can use to distinguish these modes. --- Modules/CMakeCXXCompilerId.cpp.in | 8 ++++++++ Tests/CompileFeatures/default_dialect.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index e83cfe6..3a334ed 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -58,6 +58,14 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; # endif #elif defined(_MSC_VER) && defined(_MSVC_LANG) # define CXX_STD _MSVC_LANG +#elif defined(__INTEL_COMPILER) +# if __cplusplus == CXX_STD_11 && defined(__cpp_namespace_attributes) +# define CXX_STD CXX_STD_17 +# elif __cplusplus == CXX_STD_11 && defined(__cpp_aggregate_nsdmi) +# define CXX_STD CXX_STD_14 +# else +# define CXX_STD __cplusplus +# endif #else # define CXX_STD __cplusplus #endif diff --git a/Tests/CompileFeatures/default_dialect.cpp b/Tests/CompileFeatures/default_dialect.cpp index 3f95b6c..82a8698 100644 --- a/Tests/CompileFeatures/default_dialect.cpp +++ b/Tests/CompileFeatures/default_dialect.cpp @@ -27,6 +27,14 @@ struct Outputter; # endif #elif defined(_MSC_VER) && defined(_MSVC_LANG) # define CXX_STD _MSVC_LANG +#elif defined(__INTEL_COMPILER) +# if __cplusplus == CXX_STD_11 && defined(__cpp_namespace_attributes) +# define CXX_STD CXX_STD_17 +# elif __cplusplus == CXX_STD_11 && defined(__cpp_aggregate_nsdmi) +# define CXX_STD CXX_STD_14 +# else +# define CXX_STD __cplusplus +# endif #else # define CXX_STD __cplusplus #endif -- cgit v0.12