NVHPC 24.1 does not understand -std=c++17

I’m using nvcc and nvc++ in NVHPC 24.1. When I use -std=c++17, nvcc complains that it is not supported with the configured host compiler:

nvcc warning : The -std=c++17 flag is not supported with the configured host compiler. Flag will be ignored.

and I get a bunch of compile errors. If I use -std=c++14, it works.

I’m setting the following variables in the CMake build script:

set (CMAKE_C_COMPILER nvc)
set (CMAKE_CXX_COMPILER nvc++)
set (CUDA_HOST_COMPILER nvc++)

set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -std=c++17 -O2 -w -rdc=true -use_fast_math ${TURING_CC})
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -O2 -w -mp=gpu -Minfo=mp -fPIC ${OpenMP_CXX_FLAGS}")

and CMake does detect the host compilers properly.

-- The C compiler identification is NVHPC 24.1.0
-- The CXX compiler identification is NVHPC 24.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /proj/cuda/Linux_x86_64/24.1/compilers/bin/nvc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /proj/cuda/Linux_x86_64/24.1/compilers/bin/nvc++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  

Can anyone tell me what is going on here?

It may be a CMake issue. Enable verbose output in CMake, and show the full command that gives rise to the error.