有没有办法禁止“实验性”的测试? CMake配置中的C ++ 17? [英] Is there a way to disallow "experimental" C++17 in CMake configuration?
问题描述
我在CMakeLists.txt中设置了以下内容:
I have set the following in my CMakeLists.txt:
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS OFF)
但是,即使CMake仍然允许g ++ 6它不完全支持c ++ 17(它具有c ++ 1z标准,但没有c ++ 17标准)。有没有办法告诉CMake只允许完全支持该标准的编译器,而不仅仅是部分标准?
However, CMake still allows g++ 6, even though it doesn't fully support c++17 (it has a c++1z standard, but not a c++17 standard). Is there a way to tell CMake to only allow compilers that fully support the standard and not just pieces of it?
FWIW,我还尝试设置cxx_relaxed_constexpr,我认为它应该是相关的语言功能,但仍允许使用g ++6。但是它显然无法编译类似
FWIW, I also tried setting cxx_relaxed_constexpr, which I think should have been the relevant language feature, but that still allowed g++ 6. But it clearly can't compile code like
if constexpr (ENABLE_LOGGING) { do_loggy_stuff() };
所以我不确定是否应该使用较新的constexpr功能(似乎不是最新的cmake之一),或者如果CMake只是对GCC 6的功能感到困惑。
So I'm not sure if there is a newer constexpr feature I should be looking for (there doesn't seem to be one in the latest cmake) or if CMake is just confused about what GCC 6 can do.
编辑:我有些困惑。即使GCC 6没有将c ++ 17记录为-std的值,它也确实将其作为c ++-1z的同义词。因此,我想我正在寻找的是仅寻找非实验性 c ++ 17支持的方法。
It seems I was slightly confused. Even though GCC 6 doesn't document c++17 as a value of -std, it does accept it as a synonym for c++-1z. So I guess what I'm looking for is a way to only look for "non-experimental" c++17 support.
另外,请查看GCC文档,似乎我想要的功能是如果是constexpr。不幸的是,CMake无法将 cxx_constexpr_if
或 cxx_if_constexpr
识别为有效的编译功能。
Also, looking at the GCC documentation, it seems the feature I want is "constexpr if". Unfortunately, CMake doesn't recognize cxx_constexpr_if
or cxx_if_constexpr
as valid compile features.
推荐答案
有没有办法告诉CMake只允许完全支持该标准的编译器,而不仅仅是部分标准?
Is there a way to tell CMake to only allow compilers that fully support the standard and not just pieces of it?
否。 CMake没有该信息。
No. CMake does not have that information.
这篇关于有没有办法禁止“实验性”的测试? CMake配置中的C ++ 17?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!