From 1f592bf98665f1ab03eb348a7d5422a6edc59d24 Mon Sep 17 00:00:00 2001 From: Bernhard Manfred Gruber Date: Wed, 29 Nov 2023 14:33:54 +0100 Subject: [PATCH] Detect __cplusplus with nvc++ --- cmake/modules/RootConfiguration.cmake | 8 ++++++-- config/__cplusplus.cxx | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmake/modules/RootConfiguration.cmake b/cmake/modules/RootConfiguration.cmake index 8f1370a002e7f..c0f02fa3b724e 100644 --- a/cmake/modules/RootConfiguration.cmake +++ b/cmake/modules/RootConfiguration.cmake @@ -551,9 +551,13 @@ set(pythonvers ${Python3_VERSION}) set(python${Python3_VERSION_MAJOR}vers ${Python3_VERSION}) #---RConfigure.h--------------------------------------------------------------------------------------------- -try_compile(has__cplusplus "${CMAKE_BINARY_DIR}" SOURCES "${CMAKE_SOURCE_DIR}/config/__cplusplus.cxx" +if (CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC") + execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dM -E /dev/null OUTPUT_VARIABLE __cplusplus_PPout) +else() + try_compile(has__cplusplus "${CMAKE_BINARY_DIR}" SOURCES "${CMAKE_SOURCE_DIR}/config/__cplusplus.cxx" OUTPUT_VARIABLE __cplusplus_PPout) -string(REGEX MATCH "__cplusplus=([0-9]+)" __cplusplus "${__cplusplus_PPout}") +endif() +string(REGEX MATCH "__cplusplus[=| ]([0-9]+)" __cplusplus "${__cplusplus_PPout}") set(__cplusplus ${CMAKE_MATCH_1}L) configure_file(${PROJECT_SOURCE_DIR}/config/RConfigure.in ginclude/RConfigure.h NEWLINE_STYLE UNIX) diff --git a/config/__cplusplus.cxx b/config/__cplusplus.cxx index 118f51ad27114..e2202f597fa9b 100644 --- a/config/__cplusplus.cxx +++ b/config/__cplusplus.cxx @@ -1,7 +1,7 @@ #define _STRINGIFY(x) #x #define STRINGIFY(x) _STRINGIFY(x) -// `#pragma message` is supported in well-known compilers including gcc, clang, icc, and MSVC +// `#pragma message` is supported in well-known compilers including gcc, clang, icc, and MSVC. But not nvc++. #pragma message("__cplusplus=" STRINGIFY(__cplusplus)) int main(void)