try_compile: Honouring CMAKE_CXX_STANDARD, et. al. in check_cxx_source_compiles()
The implementation of check_cxx_source_compiles()
is essentially just a wrapper around try_compile()
. If a project has defined CMAKE_CXX_STANDARD
, CMAKE_CXX_STANDARD_REQUIRED
and CMAKE_CXX_EXTENSIONS
, one might reasonably expect these to carry through to a call to check_cxx_source_compiles()
. Unfortunately, these CMake variables are not passed through by try_compile()
to its underlying temporary CMake project, so the end result is that the check is performed the compiler's default C++ standard settings. Is there any reason why it would be undesirable for these three variables not to be passed through by try_compile()
as well? I think developers would intuitively expect that they are being passed through.
This issue was prompted by a recent question on the mailing list: https://cmake.org/pipermail/cmake/2016-November/064617.html