Why CMake doesn't see -std=c++20?

Hi there!
I'm trying to install an library. After the "make" command, there are a lot of errors regarding std::chrono. As I see it, it is related to the c++20 standard. To a file CMakeCache.txt - there is no mention of the "-std=gnu++2a" flag, but it still tries to compile with it. Additional flag instructions like "-std=c++2a" or 20 do not eliminate the error. How can this be fixed? Why doesn't the compiler see "std::chrono"? The file "types.hpp" itself contains the <chrono> header.


[ 84%] Building CXX object CMakeFiles/fastcgipp.dir/src/parameters.cpp.o
/usr/bin/c++ -Dfastcgipp_EXPORTS -I/root/fastcgipp/include -I/root/fastcgi++/include -I/usr/include/postgresql -I/usr/include/postgresql/13/server -O3 -DNDEBUG -fPIC -Wall -Werror -fno-omit-frame-pointer -std=gnu++2a -o CMakeFiles/fastcgipp.dir/src/parameters.cpp.o -c /root/fastcgi++/src/parameters.cpp
In file included from /root/fastcgi++/include/sqlTraits.hpp:41,
                 from /root/fastcgi++/src/parameters.cpp:29:
/root/fastcgi++/include/fastcgi++/sql/types.hpp:54:30: error: ‘year_month_day’ in namespace ‘std::chrono’ does not name a type
   54 |         typedef std::chrono::year_month_day DATE;
      |                              ^~~~~~~~~~~~~~
In file included from /root/fastcgi++/src/parameters.cpp:29:
/root/fastcgi++/include/sqlTraits.hpp:170:34: error: ‘DATE’ was not declared in this scope
  170 |         template<> struct Traits<DATE>
      |                                  ^~~~
/root/fastcgi++/include/sqlTraits.hpp:170:38: error: template argument 1 is invalid
  170 |         template<> struct Traits<DATE>
      |                                      ^
etc...


g++ (Debian 10.2.1-6) 10.2.1 20210110

GNU Make 4.3
Built for x86_64-pc-linux-gnu

from CMakeCache.txt:

//CXX compiler
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++

//A wrapper around 'ar' adding the appropriate '--plugin' option
// for the GCC compiler
CMAKE_CXX_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-10

//A wrapper around 'ranlib' adding the appropriate '--plugin' option
// for the GCC compiler
CMAKE_CXX_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-10

//Flags used by the CXX compiler during all build types.
CMAKE_CXX_FLAGS:STRING=

//Flags used by the CXX compiler during DEBUG builds.
CMAKE_CXX_FLAGS_DEBUG:STRING=-g

//Flags used by the CXX compiler during MINSIZEREL builds.
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG

//Flags used by the CXX compiler during RELEASE builds.
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG

//Flags used by the CXX compiler during RELWITHDEBINFO builds.
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG


Advice please. Thank you.
spistol wrote:
g++ (Debian 10.2.1-6) 10.2.1 20210110

GCC 10 doesn't seem to have support for the "Calendar and timezone" utilities (not even partial) according to cppreference.com.

https://en.cppreference.com/w/cpp/compiler_support/20
Last edited on
Peter87 wrote:
GCC 10 doesn't seem to have support "Calendar and timezone" utilities


Probably you are right, but what about version date - 20210110. It looks like 2021/01/10. And what can I do now if this is the newest stable version for Debian 11?

sudo apt install g++
g++ is already the newest version (4:10.2.1-1).
I have just got an additional g++-13 installed from testing repository..
g++-13 --version
g++-13 (Debian 13.2.0-2) 13.2.0

Not sure it works properly..

from CMakeCache.txt

CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++-13
CMAKE_CXX_COMPILER_AR:FILEPATH=/usr/bin/gcc-ar-13
CMAKE_CXX_COMPILER_RANLIB:FILEPATH=/usr/bin/gcc-ranlib-13


the output

/usr/bin/g++-13 -Dfastcgipp_EXPORTS -I/root/fastcgipp/include -I/root/fastcgi++/include -fPIC g++-13 -Wall -Werror -fno-omit-frame-pointer -std=gnu++2a -o CMakeFiles/fastcgipp.dir/src/log.cpp.o -c /root/fastcgi++/src/log.cpp
g++-13: warning: g++-13: linker input file unused because linking not done
g++-13: error: g++-13: linker input file not found: No such file or directory


Someone ever had problem like this?
Oh, it was my fault - I edited "c++" to "g++-13" in CMakeLists.txt Now the lib installed.
spistol wrote:
but what about version date - 20210110. It looks like 2021/01/10.

A C++ compiler released in 2021 doesn't necessarily support everything in C++20. It usually takes some time to implement everything.
If cppreference is to be believed even GCC 13 is not 100% compliant with C++20, there are a few features that still have only partial support.

https://en.cppreference.com/w/cpp/compiler_support/20

GCC is getting there, it's C++23 support is more comprehensive than other compilers.

https://en.cppreference.com/w/cpp/compiler_support/23

Weirdly enough Clang is ahead in the race for C++26. Go figure.

https://en.cppreference.com/w/cpp/compiler_support/26
Topic archived. No new replies allowed.