diff options
author | Levi Morrison <morrison.levi@gmail.com> | 2015-11-16 16:19:30 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-04-28 13:15:25 (GMT) |
commit | be910f00b580addcf60f33c6f6c0625dba505ef8 (patch) | |
tree | 991387e6f462eb3f4fa562f8384853647fac47dd /Modules/Compiler | |
parent | 7f401ae43fafed8258659f2da204bc818fd693d3 (diff) | |
download | CMake-be910f00b580addcf60f33c6f6c0625dba505ef8.zip CMake-be910f00b580addcf60f33c6f6c0625dba505ef8.tar.gz CMake-be910f00b580addcf60f33c6f6c0625dba505ef8.tar.bz2 |
Features: Record standards and features for Intel C++ on UNIX
Skip this for now on Windows (where Intel C++ simulates MSVC).
Diffstat (limited to 'Modules/Compiler')
-rw-r--r-- | Modules/Compiler/Intel-CXX-FeatureTests.cmake | 100 | ||||
-rw-r--r-- | Modules/Compiler/Intel-CXX.cmake | 58 |
2 files changed, 158 insertions, 0 deletions
diff --git a/Modules/Compiler/Intel-CXX-FeatureTests.cmake b/Modules/Compiler/Intel-CXX-FeatureTests.cmake new file mode 100644 index 0000000..d328e3c --- /dev/null +++ b/Modules/Compiler/Intel-CXX-FeatureTests.cmake @@ -0,0 +1,100 @@ +# References: +# - https://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler +# - https://software.intel.com/en-us/articles/c14-features-supported-by-intel-c-compiler + +# FIXME: Intel C++ feature detection works only when simulating the GNU compiler. +# When simulating MSVC, Intel always sets __cplusplus to 199711L. +if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + return() +endif() + +# these are not implemented in any version at time of writing +#set(_cmake_feature_test_cxx_variable_templates "${Intel15_CXX14}") +#set(_cmake_feature_test_cxx_relaxed_constexpr "${Intel15_CXX14}") + +set(_cmake_oldestSupported "__INTEL_COMPILER >= 1110") +set(DETECT_CXX11 "((__cplusplus >= 201103L) || defined(__INTEL_CXX11_MODE__) || defined(__GXX_EXPERIMENTAL_CXX0X__))") +#ICC version 15 update 1 has a bug where __cplusplus is defined as 1 no matter +#if you are compiling as 98/11/14. So to properly detect C++14 with this version +#we look for the existence of __GXX_EXPERIMENTAL_CXX0X__ but not __INTEL_CXX11_MODE__ +set(DETECT_BUGGY_ICC15 "((__INTEL_COMPILER == 1500) && (__INTEL_COMPILER_UPDATE == 1))") +set(DETECT_CXX14 "((__cplusplus >= 201300L) || ((__cplusplus == 201103L) && !defined(__INTEL_CXX11_MODE__)) || ((${DETECT_BUGGY_ICC15}) && defined(__GXX_EXPERIMENTAL_CXX0X__) && !defined(__INTEL_CXX11_MODE__) ) )") + +set(Intel16_CXX14 "__INTEL_COMPILER >= 1600 && ${DETECT_CXX14}") +set(_cmake_feature_test_cxx_aggregate_default_initializers "${Intel16_CXX14}") +set(_cmake_feature_test_cxx_contextual_conversions "${Intel16_CXX14}") +set(_cmake_feature_test_cxx_generic_lambdas "${Intel16_CXX14}") +set(_cmake_feature_test_cxx_digit_separators "${Intel16_CXX14}") +# This test is supposed to work in Intel 14 but the compiler has a bug +# in versions 14 and 15:: +# https://software.intel.com/en-us/forums/intel-c-compiler/topic/600514 +# It also appears to fail with an internal compiler error on Intel 16. +#set(_cmake_feature_test_cxx_generalized_initializers "${Intel16_CXX14}") + +set(Intel15_CXX14 "__INTEL_COMPILER >= 1500 && ${DETECT_CXX14}") +set(_cmake_feature_test_cxx_decltype_auto "${Intel15_CXX14}") +set(_cmake_feature_test_cxx_lambda_init_captures "${Intel15_CXX14}") +set(_cmake_feature_test_cxx_attribute_deprecated "${Intel15_CXX14}") +set(_cmake_feature_test_cxx_return_type_deduction "${Intel15_CXX14}") + +set(Intel15_CXX11 "__INTEL_COMPILER >= 1500 && ${DETECT_CXX11}") +set(_cmake_feature_test_cxx_alignas "${Intel15_CXX11}") +set(_cmake_feature_test_cxx_alignof "${Intel15_CXX11}") +set(_cmake_feature_test_cxx_inheriting_constructors "${Intel15_CXX11}") +set(_cmake_feature_test_cxx_user_literals "${Intel15_CXX11}") +set(_cmake_feature_test_cxx_thread_local "${Intel15_CXX11}") + +set(Intel14_CXX11 "${DETECT_CXX11} && (__INTEL_COMPILER > 1400 || (__INTEL_COMPILER == 1400 && __INTEL_COMPILER_UPDATE >= 2))") +# Documented as 12.0+ but in testing it only works on 14.0.2+ +set(_cmake_feature_test_cxx_decltype_incomplete_return_types "${Intel14_CXX11}") + +set(Intel14_CXX11 "__INTEL_COMPILER >= 1400 && ${DETECT_CXX11}") +set(_cmake_feature_test_cxx_delegating_constructors "${Intel14_CXX11}") +set(_cmake_feature_test_cxx_constexpr "${Intel14_CXX11}") +set(_cmake_feature_test_cxx_sizeof_member "${Intel14_CXX11}") +set(_cmake_feature_test_cxx_strong_enums "${Intel14_CXX11}") +set(_cmake_feature_test_cxx_reference_qualified_functions "${Intel14_CXX11}") +set(_cmake_feature_test_cxx_raw_string_literals "${Intel14_CXX11}") +set(_cmake_feature_test_cxx_unicode_literals "${Intel14_CXX11}") +set(_cmake_feature_test_cxx_inline_namespaces "${Intel14_CXX11}") +set(_cmake_feature_test_cxx_unrestricted_unions "${Intel14_CXX11}") +set(_cmake_feature_test_cxx_nonstatic_member_init "${Intel14_CXX11}") +set(_cmake_feature_test_cxx_enum_forward_declarations "${Intel14_CXX11}") +set(_cmake_feature_test_cxx_override "${Intel14_CXX11}") +set(_cmake_feature_test_cxx_final "${Intel14_CXX11}") +set(_cmake_feature_test_cxx_noexcept "${Intel14_CXX11}") +set(_cmake_feature_test_cxx_defaulted_move_initializers "${Intel14_CXX11}") + +set(Intel13_CXX11 "__INTEL_COMPILER >= 1300 && ${DETECT_CXX11}") +set(_cmake_feature_test_cxx_explicit_conversions "${Intel13_CXX11}") +set(_cmake_feature_test_cxx_range_for "${Intel13_CXX11}") +# Cannot find Intel documentation for N2640: cxx_uniform_initialization +set(_cmake_feature_test_cxx_uniform_initialization "${Intel13_CXX11}") + +set(Intel121_CXX11 "__INTEL_COMPILER >= 1210 && ${DETECT_CXX11}") +set(_cmake_feature_test_cxx_variadic_templates "${Intel121_CXX11}") +set(_cmake_feature_test_cxx_alias_templates "${Intel121_CXX11}") +set(_cmake_feature_test_cxx_nullptr "${Intel121_CXX11}") +set(_cmake_feature_test_cxx_trailing_return_types "${Intel121_CXX11}") +set(_cmake_feature_test_cxx_attributes "${Intel121_CXX11}") +set(_cmake_feature_test_cxx_default_function_template_args "${Intel121_CXX11}") + +set(Intel12_CXX11 "__INTEL_COMPILER >= 1200 && ${DETECT_CXX11}") +set(_cmake_feature_test_cxx_extended_friend_declarations "${Intel12_CXX11}") +set(_cmake_feature_test_cxx_rvalue_references "${Intel12_CXX11}") +set(_cmake_feature_test_cxx_decltype "${Intel12_CXX11}") +set(_cmake_feature_test_cxx_defaulted_functions "${Intel12_CXX11}") +set(_cmake_feature_test_cxx_deleted_functions "${Intel12_CXX11}") +set(_cmake_feature_test_cxx_local_type_template_args "${Intel12_CXX11}") +set(_cmake_feature_test_cxx_lambdas "${Intel12_CXX11}") + +set(Intel11_CXX11 "${_cmake_oldestSupported} && ${DETECT_CXX11}") +set(_cmake_feature_test_cxx_binary_literals "${Intel11_CXX11}") +set(_cmake_feature_test_cxx_static_assert "${Intel11_CXX11}") +set(_cmake_feature_test_cxx_right_angle_brackets "${Intel11_CXX11}") +set(_cmake_feature_test_cxx_auto_type "${Intel11_CXX11}") +set(_cmake_feature_test_cxx_extern_templates "${Intel11_CXX11}") +set(_cmake_feature_test_cxx_variadic_macros "${Intel11_CXX11}") +set(_cmake_feature_test_cxx_long_long_type "${Intel11_CXX11}") +set(_cmake_feature_test_cxx_func_identifier "${Intel11_CXX11}") +set(_cmake_feature_test_cxx_template_template_parameters "${Intel11_CXX11}") diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake index 02c636c..2785fd3 100644 --- a/Modules/Compiler/Intel-CXX.cmake +++ b/Modules/Compiler/Intel-CXX.cmake @@ -8,5 +8,63 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG") set(CMAKE_DEPFILE_FLAGS_CXX "-MD -MT <OBJECT> -MF <DEPFILE>") +if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0.2) + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") + # todo: there is no gnu++14 value supported; figure out what to do + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=c++14") + elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0.0) + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y") + # todo: there is no gnu++14 value supported; figure out what to do + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=c++1y") + endif() + + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") + elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") + endif() + + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") + endif() +endif() + +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) + if (NOT CMAKE_CXX_COMPILER_FORCED) + if (NOT CMAKE_CXX_STANDARD_COMPUTED_DEFAULT) + message(FATAL_ERROR "CMAKE_CXX_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) version ${CMAKE_CXX_COMPILER_VERSION}") + else() + set(CMAKE_CXX_STANDARD_DEFAULT ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}) + endif() + elseif (NOT CMAKE_CXX_STANDARD_COMPUTED_DEFAULT) + # Compiler id was forced so just guess the default standard level. + set(CMAKE_CXX_STANDARD_DEFAULT 98) + endif() +endif() + +macro(cmake_record_cxx_compile_features) + macro(_get_intel_features std_version list) + record_compiler_features(CXX "${std_version}" ${list}) + endmacro() + + set(_result 0) + if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC" AND + NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0) + _get_intel_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES) + endif() + if (_result EQUAL 0) + _get_intel_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) + endif() + if (_result EQUAL 0) + _get_intel_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES) + endif() + endif() +endmacro() + set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") |