Supported c++ standard reported incorrectly for Visual Studio 2013
Hi,
I am using Visual Studio 2013 and I am trying to find out about the support C++ standard features from C++11 and above. However from looking at MSVC-CXX.cmake it seems to me that CMake simply returns a list of all known C++ standards for Visual Studio 2010 - 2015. For my version I am getting
cxx_std_98
cxx_std_11
cxx_std_14
cxx_std_17
cxx_std_20
cxx_alias_templates
cxx_auto_type
cxx_contextual_conversions
cxx_decltype
cxx_default_function_template_args
cxx_defaulted_functions
cxx_delegating_constructors
cxx_enum_forward_declarations
cxx_explicit_conversions
cxx_extended_friend_declarations
cxx_extern_templates
cxx_final
cxx_generalized_initializers
cxx_lambdas
cxx_local_type_template_args
cxx_long_long_type
cxx_nullptr
cxx_override
cxx_range_for
cxx_raw_string_literals
cxx_right_angle_brackets
cxx_rvalue_references
cxx_static_assert
cxx_strong_enums
cxx_template_template_parameters
cxx_trailing_return_types
cxx_uniform_initialization
cxx_variadic_macros
cxx_variadic_templates
which cannot be right. The list of specific features looks fine. However I don't want to check for the 'nullptr' feature in order to be sure that I can include 'thread'. I created a similar question on stackoverflow: https://stackoverflow.com/questions/54515364/how-to-detect-c11-support-of-a-compiler-with-cmake-and-react-without-faili but ended up here now.
What I am actually trying to do is something like this:
set(TARGET MyTarget)
if(CPP_STANDARD_VERSION GREATER_EQUAL 11)
set(SOURCE myModernFile.cpp)
else()
set(SOURCE myLegacyFile.cpp)
endif()
add_executable(${TARGET} ${SOURCE })
if(CPP_STANDARD_VERSION GREATER_EQUAL 11)
# Here failing would be fine if lambdas are not supported!
target_compile_features(${TARGET} PRIVATE cxx_lambdas)
endif()
Are there any plans to change/fix this or do I simply have to update Visual Studio. Is this working reliable for gcc/clang etc. so is this only and issue with the Visual Studio versions mentioned above?