Add option to override or ignore DUNE_HAVE_CXX_OPTIONAL and associated check
Description
The implementation of std::optional
shipped with Apple Clang v10 is incompatible to the DUNE Std::optional
implementation. This only becomes apparent when trying to compile dune-functions, see staging/dune-functions#41 (closed). The actual error is apparently caused by restrictions of the value type inserted into std::optional
.
The general check for std::optional
succeeds, therefore the CMake variable and CPP macro DUNE_HAVE_CXX_OPTIONAL
is set. This, in turn, disables the DUNE implementation in dune/common/std/optional.hh
.
Current workaround on Mac
Disabling all #ifdef DUNE_HAVE_CXX_OPTIONAL
blocks in dune/common/std/optional.hh
. This is not portable, of course.
Edit: Use -DDUNE_HAVE_CXX_OPTIONAL=OFF
as CMake flag.
Proposals
I have two ideas how to solve this:
-
Have a CMake flag that disables, or overrides the result of, the check forstd::optional
incmake/modules/CheckCXXFeatures.cmake
.Edit:
-DDUNE_HAVE_CXX_OPTIONAL=OFF
overrides the test result. -
Check if
CMAKE_CXX_COMPILER_ID
is equal toAppleClang
and then always disable the check.
Is there a general policy for such cases? If not, I can come up with a simple MR.