From d9e42ffd0d226ee028497550a028cca3f749ab33 Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Sun, 15 Oct 2023 23:12:58 -0500 Subject: [PATCH] Update flags for NVIDIA compilers in CMake builds. --- config/cmake/HDFCXXCompilerFlags.cmake | 11 ++++++++--- config/cmake/HDFCompilerFlags.cmake | 2 +- config/cmake/HDFFortranCompilerFlags.cmake | 5 ++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/config/cmake/HDFCXXCompilerFlags.cmake b/config/cmake/HDFCXXCompilerFlags.cmake index 1f4aea774be..13f712dd344 100644 --- a/config/cmake/HDFCXXCompilerFlags.cmake +++ b/config/cmake/HDFCXXCompilerFlags.cmake @@ -49,10 +49,15 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro AND CMAKE_CXX_COMPILER_LOADED) endif () endif () -if (CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Minform=warn") +if (CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC" AND CMAKE_CXX_COMPILER_LOADED) + if (NOT DEFINED CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION) + if (NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD EQUAL 11) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C11_STANDARD_COMPILE_OPTION}") + endif () + endif () if (NOT ${HDF_CFG_NAME} MATCHES "Debug" AND NOT ${HDF_CFG_NAME} MATCHES "Developer") - if (${HDF_CFG_NAME} MATCHES "RelWithDebInfo") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Minform=warn") + if (NOT ${HDF_CFG_NAME} MATCHES "RelWithDebInfo") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s") endif () else () diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index 569188c67cc..a6bce982849 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -50,7 +50,7 @@ endif() if(CMAKE_C_COMPILER_ID STREQUAL "NVHPC" ) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Minform=warn") if (NOT ${HDF_CFG_NAME} MATCHES "Debug" AND NOT ${HDF_CFG_NAME} MATCHES "Developer") - if (${HDF_CFG_NAME} MATCHES "RelWithDebInfo") + if (NOT ${HDF_CFG_NAME} MATCHES "RelWithDebInfo") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s") endif () else () diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake index 5db2704eb3b..57c4a2f05ed 100644 --- a/config/cmake/HDFFortranCompilerFlags.cmake +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -58,11 +58,10 @@ if (CMAKE_Fortran_COMPILER_ID STREQUAL "NAG") endif () if (CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC") - set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fPIC") if (NOT ${HDF_CFG_NAME} MATCHES "Debug" AND NOT ${HDF_CFG_NAME} MATCHES "Developer") set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mnoframe") - if (${HDF_CFG_NAME} MATCHES "RelWithDebInfo") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s") + if (NOT ${HDF_CFG_NAME} MATCHES "RelWithDebInfo") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -s") endif () else () set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mbounds -Mchkptr -Mdclchk -g")