mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
Previously we added the language standard flag near the end of all options, even after those added by `add_compile_options` and friends. However, on some compilers such as MSVC, the `-std` flag may reset defaults for flags that precede it on the command line. Move the language standard flag to before all other flags that CMake adds for other abstractions, and before those added by `add_compile_options`. `CMAKE_<LANG>_FLAGS` should still precede the language flags though, because they are meant to be treated as language-wide modifications to the compiler defaults, similar to `$CC $CFLAGS`. Fixes: #23860 Fixes: #24170
10 lines
240 B
C++
10 lines
240 B
C++
#if !defined(_MSVC_LANG) || _MSVC_LANG < 202002L
|
|
# error "This source must be compiled with MSVC as C++20 or later."
|
|
#endif
|
|
// Test a construct that is allowed by MSVC only with 'cl -permissive'.
|
|
enum class X
|
|
{
|
|
Y = 1
|
|
};
|
|
int array[X::Y];
|