MSVC-CXX-FeatureTests.cmake 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # Reference: https://docs.microsoft.com/en-us/cpp/visual-cpp-language-conformance
  2. # https://blogs.msdn.microsoft.com/vcblog/2015/06/19/c111417-features-in-vs-2015-rtm/
  3. # https://blogs.msdn.microsoft.com/vcblog/2013/12/02/c1114-core-language-features-in-vs-2013-and-the-nov-2013-ctp/
  4. # https://blogs.msdn.microsoft.com/vcblog/2011/09/12/c11-features-in-visual-c-11/
  5. set(_cmake_oldestSupported "_MSC_VER >= 1600")
  6. # VS 2017 v15.3 fixes support for incomplete decltypes
  7. # https://docs.microsoft.com/en-us/cpp/cpp-conformance-improvements-2017#update_153
  8. set(_cmake_feature_test_cxx_decltype_incomplete_return_types "_MSC_VER >= 1911")
  9. # VS 2017 v15.3 fixes support for "N3652 Extended constexpr"
  10. set(_cmake_feature_test_cxx_relaxed_constexpr "_MSC_VER >= 1911")
  11. # VS 2017 Preview introduces support for aggregate initializers.
  12. set(_cmake_feature_test_cxx_aggregate_default_initializers "_MSC_FULL_VER >= 190024406")
  13. # VS 2015 Update 2 introduces support for variable templates.
  14. # https://www.visualstudio.com/en-us/news/vs2015-update2-vs.aspx
  15. set(_cmake_feature_test_cxx_variable_templates "_MSC_FULL_VER >= 190023918")
  16. set(MSVC_2015 "_MSC_VER >= 1900")
  17. set(_cmake_feature_test_cxx_alignas "${MSVC_2015}")
  18. set(_cmake_feature_test_cxx_alignof "${MSVC_2015}")
  19. set(_cmake_feature_test_cxx_attributes "${MSVC_2015}")
  20. set(_cmake_feature_test_cxx_attribute_deprecated "${MSVC_2015}")
  21. set(_cmake_feature_test_cxx_binary_literals "${MSVC_2015}")
  22. set(_cmake_feature_test_cxx_constexpr "${MSVC_2015}")
  23. set(_cmake_feature_test_cxx_decltype_auto "${MSVC_2015}")
  24. set(_cmake_feature_test_cxx_digit_separators "${MSVC_2015}")
  25. set(_cmake_feature_test_cxx_func_identifier "${MSVC_2015}")
  26. set(_cmake_feature_test_cxx_nonstatic_member_init "${MSVC_2015}")
  27. # Microsoft calls this 'rvalue references v3'
  28. set(_cmake_feature_test_cxx_defaulted_move_initializers "${MSVC_2015}")
  29. set(_cmake_feature_test_cxx_generic_lambdas "${MSVC_2015}")
  30. set(_cmake_feature_test_cxx_inheriting_constructors "${MSVC_2015}")
  31. set(_cmake_feature_test_cxx_inline_namespaces "${MSVC_2015}")
  32. set(_cmake_feature_test_cxx_lambda_init_captures "${MSVC_2015}")
  33. set(_cmake_feature_test_cxx_noexcept "${MSVC_2015}")
  34. set(_cmake_feature_test_cxx_return_type_deduction "${MSVC_2015}")
  35. set(_cmake_feature_test_cxx_sizeof_member "${MSVC_2015}")
  36. set(_cmake_feature_test_cxx_thread_local "${MSVC_2015}")
  37. set(_cmake_feature_test_cxx_unicode_literals "${MSVC_2015}")
  38. set(_cmake_feature_test_cxx_unrestricted_unions "${MSVC_2015}")
  39. set(_cmake_feature_test_cxx_user_literals "${MSVC_2015}")
  40. set(_cmake_feature_test_cxx_reference_qualified_functions "${MSVC_2015}")
  41. # "The copies and moves don't interact precisely like the Standard says they
  42. # should. For example, deletion of moves is specified to also suppress
  43. # copies, but Visual C++ in Visual Studio 2013 does not."
  44. # http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx
  45. # lists this as 'partial' in 2013
  46. set(_cmake_feature_test_cxx_deleted_functions "${MSVC_2015}")
  47. # http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx
  48. # Note 1. While previous version of VisualStudio said they supported these
  49. # they silently produced bad code, and are now marked as having partial
  50. # support in previous versions. The footnote says the support will be complete
  51. # in MSVC 2015, so support the feature for that version, assuming that is true.
  52. # The blog post also says that VS 2013 Update 3 generates an error in cases
  53. # that previously produced bad code.
  54. set(_cmake_feature_test_cxx_generalized_initializers "_MSC_FULL_VER >= 180030723")
  55. set(MSVC_2013 "_MSC_VER >= 1800")
  56. set(_cmake_feature_test_cxx_alias_templates "${MSVC_2013}")
  57. # Microsoft now states they support contextual conversions in 2013 and above.
  58. # See footnote 6 at:
  59. # http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx
  60. set(_cmake_feature_test_cxx_contextual_conversions "${MSVC_2013}")
  61. set(_cmake_feature_test_cxx_default_function_template_args "${MSVC_2013}")
  62. set(_cmake_feature_test_cxx_defaulted_functions "${MSVC_2013}")
  63. set(_cmake_feature_test_cxx_delegating_constructors "${MSVC_2013}")
  64. set(_cmake_feature_test_cxx_explicit_conversions "${MSVC_2013}")
  65. set(_cmake_feature_test_cxx_raw_string_literals "${MSVC_2013}")
  66. set(_cmake_feature_test_cxx_uniform_initialization "${MSVC_2013}")
  67. # Support is documented, but possibly partly broken:
  68. # https://msdn.microsoft.com/en-us/library/hh567368.aspx
  69. # http://thread.gmane.org/gmane.comp.lib.boost.devel/244986/focus=245333
  70. set(_cmake_feature_test_cxx_variadic_templates "${MSVC_2013}")
  71. set(MSVC_2012 "_MSC_VER >= 1700")
  72. set(_cmake_feature_test_cxx_enum_forward_declarations "${MSVC_2012}")
  73. set(_cmake_feature_test_cxx_final "${MSVC_2012}")
  74. set(_cmake_feature_test_cxx_range_for "${MSVC_2012}")
  75. set(_cmake_feature_test_cxx_strong_enums "${MSVC_2012}")
  76. set(MSVC_2010 "_MSC_VER >= 1600")
  77. set(_cmake_feature_test_cxx_auto_type "${MSVC_2010}")
  78. set(_cmake_feature_test_cxx_decltype "${MSVC_2010}")
  79. set(_cmake_feature_test_cxx_extended_friend_declarations "${MSVC_2010}")
  80. set(_cmake_feature_test_cxx_extern_templates "${MSVC_2010}")
  81. set(_cmake_feature_test_cxx_lambdas "${MSVC_2010}")
  82. set(_cmake_feature_test_cxx_local_type_template_args "${MSVC_2010}")
  83. set(_cmake_feature_test_cxx_long_long_type "${MSVC_2010}")
  84. set(_cmake_feature_test_cxx_nullptr "${MSVC_2010}")
  85. set(_cmake_feature_test_cxx_override "${MSVC_2010}")
  86. set(_cmake_feature_test_cxx_right_angle_brackets "${MSVC_2010}")
  87. set(_cmake_feature_test_cxx_rvalue_references "${MSVC_2010}")
  88. set(_cmake_feature_test_cxx_static_assert "${MSVC_2010}")
  89. set(_cmake_feature_test_cxx_template_template_parameters "${MSVC_2010}")
  90. set(_cmake_feature_test_cxx_trailing_return_types "${MSVC_2010}")
  91. set(_cmake_feature_test_cxx_variadic_macros "${MSVC_2010}")
  92. # Unset all the variables that we don't need exposed.
  93. # _cmake_oldestSupported is required by WriteCompilerDetectionHeader
  94. set(MSVC_2017)
  95. set(MSVC_2015)
  96. set(MSVC_2013)
  97. set(MSVC_2012)
  98. set(MSVC_2010)