CMake incorrectly reports that "cxx_nullptr" is not known to PGI pgc++
I have the following CMakeLists.txt:
project(hello)
cmake_minimum_required(VERSION 3.3)
add_executable(hello hello.cpp)
target_compile_features(hello PRIVATE cxx_nullptr)
and the following hello.cpp:
#include <iostream>
#include <cstddef> // to get std::nullptr_;t
struct S { };
template <int *> struct X { };
void f() {
void *p = nullptr; // Initializes p to null pointer
int S::* mp = nullptr; // Initializes mp to null ptr-to-member
X<nullptr> xnull0; // Instantiates X with null int * value
}
using namespace std;
int main() {
cout << "Hello World!\n";
return 0;
}
Running cmake gives the following error:
cmake .
...
CMake Error at CMakeLists.txt:4 (target_compile_features):
target_compile_features The compiler feature "cxx_nullptr" is not known to
CXX compiler
"PGI"
version 19.3.0.
But pgc++ compiles and runs hello.cpp without any errors:
pgc++ --c++11 hello.cpp && ./a.out
"hello.cpp", line 7: warning: variable "p" was declared but never referenced
void *p = nullptr; // Initializes p to null pointer
^
"hello.cpp", line 8: warning: variable "mp" was declared but never referenced
int S::* mp = nullptr; // Initializes mp to null ptr-to-member
^
"hello.cpp", line 9: warning: variable "xnull0" was declared but never
referenced
X<nullptr> xnull0; // Instantiates X with null int * value
^
Hello World!