I want to run my unit tests in all available C++ versions, so I have a directory structure like
tests/
component/
tst_component.cpp
cxx11/
cxx14/
cxx17/
cxx20/
And I compile tst_component.cpp
in each of the cxxNN
subdirs in C++NN using CONFIG += c++NN
. This works well if the compiler supports all these (with 1z for 17 and 2a for 20, for older qmakes). But on our CI, I have one compiler that's too old to understand the -std=c++2a
option that CONFIG+=c++2a
adds to the command line, so I'd like to conditionally exclude the cxx20 subdir when the compiler doesn't support (even a subset of) c++20.
I know of
CONFIG(QT_CONFIG, c++2a):SUBDIRS += cxx20
but that's testing whether Qt was built in C++20 mode, which is not what I want. It's what I'm using atm, to get the change through the CI, but it means, of course, that the C++20 mode isn't actually tested on the CI until someone installs a Qt built with C++20.
Is there a way that's independent of how Qt is built and doesn't involve maintaining a compiler version whitelist in the build system by hand?
EDIT:20210609 Something like a config test: I try to compile something with CONFIG+=c++2a
and if that works, some flag is set (like have_cxx20
, enabling me to say have_cxx20:SUBDIRS+=cxx20
)?