Intel-CXX-FeatureTests.cmake 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. # References:
  2. # - https://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler
  3. # - https://software.intel.com/en-us/articles/c14-features-supported-by-intel-c-compiler
  4. # - http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0096r3.html
  5. # Notes:
  6. # [1] Some Intel versions define some feature macros under -std=gnu++98
  7. # that do not work in that mode (or work with warnings):
  8. # - __cpp_attributes 200809
  9. # - __cpp_init_captures 201304
  10. # - __cpp_lambdas 200907
  11. # - __cpp_rvalue_references 200610
  12. # - __cpp_variadic_templates 200704
  13. set(_cmake_feature_test_cxx_variable_templates "__cpp_variable_templates >= 201304")
  14. set(_cmake_oldestSupported "__INTEL_COMPILER >= 1210")
  15. set(DETECT_CXX11 "((__cplusplus >= 201103L) || defined(__INTEL_CXX11_MODE__) || defined(__GXX_EXPERIMENTAL_CXX0X__))")
  16. #ICC version 15 update 1 has a bug where __cplusplus is defined as 1 no matter
  17. #if you are compiling as 98/11/14. So to properly detect C++14 with this version
  18. #we look for the existence of __GXX_EXPERIMENTAL_CXX0X__ but not __INTEL_CXX11_MODE__
  19. set(DETECT_BUGGY_ICC15 "((__INTEL_COMPILER == 1500) && (__INTEL_COMPILER_UPDATE == 1))")
  20. set(DETECT_CXX14 "((__cplusplus >= 201300L) || ((__cplusplus == 201103L) && !defined(__INTEL_CXX11_MODE__)) || ((${DETECT_BUGGY_ICC15}) && defined(__GXX_EXPERIMENTAL_CXX0X__) && !defined(__INTEL_CXX11_MODE__) ) || (defined(__INTEL_CXX11_MODE__) && defined(__cpp_aggregate_nsdmi)) )")
  21. unset(DETECT_BUGGY_ICC15)
  22. set(Intel17_CXX14 "__INTEL_COMPILER >= 1700 && ${DETECT_CXX14}")
  23. set(_cmake_feature_test_cxx_relaxed_constexpr "__cpp_constexpr >= 201304 || (${Intel17_CXX14} && !defined(_MSC_VER))")
  24. set(Intel16_CXX14 "__INTEL_COMPILER >= 1600 && ${DETECT_CXX14}")
  25. set(_cmake_feature_test_cxx_aggregate_default_initializers "${Intel16_CXX14}")
  26. set(_cmake_feature_test_cxx_contextual_conversions "${Intel16_CXX14}")
  27. set(_cmake_feature_test_cxx_generic_lambdas "__cpp_generic_lambdas >= 201304")
  28. set(_cmake_feature_test_cxx_digit_separators "${Intel16_CXX14}")
  29. unset(Intel16_CXX14)
  30. set(Intel15 "__INTEL_COMPILER >= 1500")
  31. set(Intel15_CXX14 "${Intel15} && ${DETECT_CXX14}")
  32. set(_cmake_feature_test_cxx_decltype_auto "__cpp_decltype_auto >= 201304 || ${Intel15_CXX14}")
  33. set(_cmake_feature_test_cxx_lambda_init_captures "(__cpp_init_captures >= 201304 || ${Intel15}) && ${DETECT_CXX14}") # [1]
  34. set(_cmake_feature_test_cxx_attribute_deprecated "${Intel15_CXX14}")
  35. set(_cmake_feature_test_cxx_return_type_deduction "__cpp_return_type_deduction >= 201304 || ${Intel15_CXX14}")
  36. unset(Intel15_CXX14)
  37. unset(Intel15)
  38. set(Intel15_CXX11 "__INTEL_COMPILER >= 1500 && ${DETECT_CXX11}")
  39. set(_cmake_feature_test_cxx_alignas "${Intel15_CXX11}")
  40. set(_cmake_feature_test_cxx_alignof "${Intel15_CXX11}")
  41. set(_cmake_feature_test_cxx_inheriting_constructors "${Intel15_CXX11}")
  42. set(_cmake_feature_test_cxx_user_literals "__cpp_user_defined_literals >= 200809 || (${Intel15_CXX11} && (!defined(_MSC_VER) || __INTEL_COMPILER >= 1600))")
  43. set(_cmake_feature_test_cxx_thread_local "${Intel15_CXX11}")
  44. unset(Intel15_CXX11)
  45. set(Intel14_CXX11 "${DETECT_CXX11} && (__INTEL_COMPILER > 1400 || (__INTEL_COMPILER == 1400 && __INTEL_COMPILER_UPDATE >= 2))")
  46. # Documented as 12.0+ but in testing it only works on 14.0.2+
  47. set(_cmake_feature_test_cxx_decltype_incomplete_return_types "${Intel14_CXX11} && !defined(_MSC_VER)")
  48. set(Intel14_CXX11 "__INTEL_COMPILER >= 1400 && ${DETECT_CXX11}")
  49. set(_cmake_feature_test_cxx_delegating_constructors "${Intel14_CXX11}")
  50. set(_cmake_feature_test_cxx_constexpr "__cpp_constexpr >= 200704 || ${Intel14_CXX11}")
  51. set(_cmake_feature_test_cxx_sizeof_member "${Intel14_CXX11}")
  52. set(_cmake_feature_test_cxx_strong_enums "${Intel14_CXX11}")
  53. set(_cmake_feature_test_cxx_reference_qualified_functions "${Intel14_CXX11}")
  54. set(_cmake_feature_test_cxx_raw_string_literals "__cpp_raw_strings >= 200710 || ${Intel14_CXX11}")
  55. set(_cmake_feature_test_cxx_unicode_literals "__cpp_unicode_literals >= 200710 || (${Intel14_CXX11} && (!defined(_MSC_VER) || __INTEL_COMPILER >= 1600))")
  56. set(_cmake_feature_test_cxx_inline_namespaces "${Intel14_CXX11}")
  57. set(_cmake_feature_test_cxx_unrestricted_unions "${Intel14_CXX11}")
  58. set(_cmake_feature_test_cxx_nonstatic_member_init "${Intel14_CXX11}")
  59. set(_cmake_feature_test_cxx_enum_forward_declarations "${Intel14_CXX11}")
  60. set(_cmake_feature_test_cxx_override "${Intel14_CXX11}")
  61. set(_cmake_feature_test_cxx_final "${Intel14_CXX11}")
  62. set(_cmake_feature_test_cxx_noexcept "${Intel14_CXX11}")
  63. set(_cmake_feature_test_cxx_defaulted_move_initializers "${Intel14_CXX11}")
  64. set(_cmake_feature_test_cxx_generalized_initializers "${Intel14_CXX11}")
  65. unset(Intel14_CXX11)
  66. set(Intel13_CXX11 "__INTEL_COMPILER >= 1300 && ${DETECT_CXX11}")
  67. set(_cmake_feature_test_cxx_explicit_conversions "${Intel13_CXX11}")
  68. set(_cmake_feature_test_cxx_range_for "${Intel13_CXX11}")
  69. # Cannot find Intel documentation for N2640: cxx_uniform_initialization
  70. set(_cmake_feature_test_cxx_uniform_initialization "${Intel13_CXX11}")
  71. unset(Intel13_CXX11)
  72. set(Intel121 "${_cmake_oldestSupported}")
  73. set(Intel121_CXX11 "${Intel121} && ${DETECT_CXX11}")
  74. set(_cmake_feature_test_cxx_variadic_templates "(__cpp_variadic_templates >= 200704 || ${Intel121}) && ${DETECT_CXX11}") # [1]
  75. set(_cmake_feature_test_cxx_alias_templates "${Intel121_CXX11}")
  76. set(_cmake_feature_test_cxx_nullptr "${Intel121_CXX11}")
  77. set(_cmake_feature_test_cxx_trailing_return_types "${Intel121_CXX11}")
  78. set(_cmake_feature_test_cxx_attributes "(__cpp_attributes >= 200809 || ${Intel121}) && ${DETECT_CXX11}") # [1]
  79. set(_cmake_feature_test_cxx_default_function_template_args "${Intel121_CXX11}")
  80. set(_cmake_feature_test_cxx_extended_friend_declarations "${Intel121_CXX11}")
  81. set(_cmake_feature_test_cxx_rvalue_references "(__cpp_rvalue_references >= 200610 || ${Intel121}) && ${DETECT_CXX11}") # [1]
  82. set(_cmake_feature_test_cxx_decltype "__cpp_decltype >= 200707 || ${Intel121_CXX11}")
  83. set(_cmake_feature_test_cxx_defaulted_functions "${Intel121_CXX11}")
  84. set(_cmake_feature_test_cxx_deleted_functions "${Intel121_CXX11}")
  85. set(_cmake_feature_test_cxx_local_type_template_args "${Intel121_CXX11}")
  86. set(_cmake_feature_test_cxx_lambdas "(__cpp_lambdas >= 200907 || ${Intel121}) && ${DETECT_CXX11}") # [1]
  87. set(_cmake_feature_test_cxx_binary_literals "__cpp_binary_literals >= 201304 || ${Intel121}")
  88. set(_cmake_feature_test_cxx_static_assert "(__cpp_static_assert >= 200410 || ${Intel121}) && ${DETECT_CXX11}")
  89. set(_cmake_feature_test_cxx_right_angle_brackets "${Intel121_CXX11}")
  90. set(_cmake_feature_test_cxx_auto_type "${Intel121_CXX11}")
  91. set(_cmake_feature_test_cxx_extern_templates "${Intel121_CXX11}")
  92. set(_cmake_feature_test_cxx_variadic_macros "${Intel121_CXX11}")
  93. set(_cmake_feature_test_cxx_long_long_type "${Intel121_CXX11}")
  94. set(_cmake_feature_test_cxx_func_identifier "${Intel121_CXX11}")
  95. set(_cmake_feature_test_cxx_template_template_parameters "${Intel121_CXX11}")
  96. unset(Intel121_CXX11)
  97. unset(Intel121)
  98. unset(DETECT_CXX11)
  99. unset(DETECT_CXX14)