Pārlūkot izejas kodu

NVHPC: Fix detection of C++ 20 mode on NVHPC < 22.7

This compiler does not always define `__cplusplus` correctly, but does
define a feature macro that we can use to distinguish this mode.
Brad King 1 gadu atpakaļ
vecāks
revīzija
7f05d472a2

+ 6 - 0
Modules/CMakeCXXCompilerId.cpp.in

@@ -58,6 +58,12 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
 #  endif
 #elif defined(_MSC_VER) && defined(_MSVC_LANG)
 #  define CXX_STD _MSVC_LANG
+#elif defined(__NVCOMPILER)
+#  if __cplusplus == CXX_STD_17 && defined(__cpp_aggregate_paren_init)
+#    define CXX_STD CXX_STD_20
+#  else
+#    define CXX_STD __cplusplus
+#  endif
 #elif defined(__INTEL_COMPILER)
 #  if __cplusplus == CXX_STD_11 && defined(__cpp_namespace_attributes)
 #    define CXX_STD CXX_STD_17

+ 6 - 0
Tests/CompileFeatures/default_dialect.cpp

@@ -27,6 +27,12 @@ struct Outputter;
 #  endif
 #elif defined(_MSC_VER) && defined(_MSVC_LANG)
 #  define CXX_STD _MSVC_LANG
+#elif defined(__NVCOMPILER)
+#  if __cplusplus == CXX_STD_17 && defined(__cpp_aggregate_paren_init)
+#    define CXX_STD CXX_STD_20
+#  else
+#    define CXX_STD __cplusplus
+#  endif
 #elif defined(__INTEL_COMPILER)
 #  if __cplusplus == CXX_STD_11 && defined(__cpp_namespace_attributes)
 #    define CXX_STD CXX_STD_17