[CMake] Add function to allow modules to require a minimum C++ standard
This patch adds a new function dune_require_cxx_standard() that any Dune module can call to require support for at least a given C++ standard. If the compiler doesn't meet the requirements, the function will report the required and the actually available standard versions and abort with a fatal error. Moreover, it knows about CXX_MAX_STANDARD and will tell the user if the value of that variable is below the requirements. This avoids desperate users that have a shiny beta of GCC 6 with C++17 support wondering why their own module using shiny C++17 concepts stubbornly fails to build... ;-)
Probably you want to use the stuff CMake already provides, at least in the case CMake is recent enough. Since CMake 3.1
CMAKE_CXX_STANDARDcan be set to
14and it will error out if the required version is not met. CMake has a list for a lot of compilers with the right flags.
Unfortunately, that isn't enough for some of our use cases. We have some weird situations that CMake doesn't typically assume, like the issue that first cropped up when you added C++14 detection support and Marian's build broke because he had installed a recent Clang (which had C++14 support) into his home directory that was using the libstdc++ from his system (which didn't). Kaboom!
So we really need to make sure that the compiler is paired with a matching library, because there are quite a few people with weird compiler setups to work around their old Linux distribution etc. And AFAIK CMake just uses a pre-built table for this which won't catch problems with those oddball configurations.
PS: And I want to be able to specify C++17