summaryrefslogtreecommitdiffstats
path: root/Modules/Compiler
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2016-04-15 17:40:30 (GMT)
committerBrad King <brad.king@kitware.com>2016-04-28 13:16:35 (GMT)
commit36f32ede8d1a2aa1578a726f687a24dec4cc3f33 (patch)
tree8258a383b95b406a7a5dd0ab3f8c760c355d33ff /Modules/Compiler
parentd028b948721d7a6042b87e238542a11fea78edb0 (diff)
downloadCMake-36f32ede8d1a2aa1578a726f687a24dec4cc3f33.zip
CMake-36f32ede8d1a2aa1578a726f687a24dec4cc3f33.tar.gz
CMake-36f32ede8d1a2aa1578a726f687a24dec4cc3f33.tar.bz2
Features: Record standards and features for Intel C on UNIX
Record features for Intel C 12.1 and above. Skip this for now on Windows (where Intel C simulates MSVC).
Diffstat (limited to 'Modules/Compiler')
-rw-r--r--Modules/Compiler/Intel-C-FeatureTests.cmake23
-rw-r--r--Modules/Compiler/Intel-C.cmake50
2 files changed, 73 insertions, 0 deletions
diff --git a/Modules/Compiler/Intel-C-FeatureTests.cmake b/Modules/Compiler/Intel-C-FeatureTests.cmake
new file mode 100644
index 0000000..34175c8
--- /dev/null
+++ b/Modules/Compiler/Intel-C-FeatureTests.cmake
@@ -0,0 +1,23 @@
+# References:
+# - https://software.intel.com/en-us/articles/iso-iec-standards-language-conformance-for-intel-c-compiler
+# - https://software.intel.com/en-us/articles/c99-support-in-intel-c-compiler
+# - https://software.intel.com/en-us/articles/c11-support-in-intel-c-compiler
+
+# FIXME: Intel C feature detection works only when simulating the GNU compiler.
+if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
+ return()
+endif()
+
+set(DETECT_C99 "defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L")
+
+#static assert is only around in version 1500 update 2 and above
+set(_cmake_feature_test_c_static_assert "(__INTEL_COMPILER > 1500 || (__INTEL_COMPILER == 1500 && __INTEL_COMPILER_UPDATE > 1) ) && ${DETECT_C99}")
+
+set(_cmake_oldestSupported "__INTEL_COMPILER >= 1110")
+set(Intel_C99 "${_cmake_oldestSupported} && ${DETECT_C99}")
+set(_cmake_feature_test_c_restrict "${Intel_C99}")
+set(_cmake_feature_test_c_variadic_macros "${Intel_C99}")
+set(_cmake_feature_test_c_function_prototypes "${_cmake_oldestSupported}")
+unset(Intel_C99)
+
+unset(DETECT_C99)
diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake
index 77363eb..6e07436 100644
--- a/Modules/Compiler/Intel-C.cmake
+++ b/Modules/Compiler/Intel-C.cmake
@@ -8,5 +8,55 @@ set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG")
set(CMAKE_DEPFILE_FLAGS_C "-MD -MT <OBJECT> -MF <DEPFILE>")
+if(NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
+ if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0)
+ set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
+ set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=c11")
+ endif()
+
+ if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.1)
+ set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89")
+ set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=c89")
+ set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
+ set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=c99")
+ endif()
+endif()
+
+if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.1)
+ if (NOT CMAKE_C_COMPILER_FORCED)
+ if (NOT CMAKE_C_STANDARD_COMPUTED_DEFAULT)
+ message(FATAL_ERROR "CMAKE_C_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_C_COMPILER_ID} (${CMAKE_C_COMPILER}) version ${CMAKE_C_COMPILER_VERSION}")
+ endif()
+ set(CMAKE_C_STANDARD_DEFAULT ${CMAKE_C_STANDARD_COMPUTED_DEFAULT})
+ elseif(NOT DEFINED CMAKE_C_STANDARD_DEFAULT)
+ # Compiler id was forced so just guess the default standard level.
+ if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0)
+ set(CMAKE_C_STANDARD_DEFAULT 11)
+ else()
+ set(CMAKE_C_STANDARD_DEFAULT 90)
+ endif()
+ endif()
+endif()
+
+macro(cmake_record_c_compile_features)
+ macro(_get_intel_c_features std_version list)
+ record_compiler_features(C "${std_version}" ${list})
+ endmacro()
+
+ set(_result 0)
+ if (NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" AND
+ NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.1)
+ if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0)
+ _get_intel_c_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES)
+ endif()
+ if (_result EQUAL 0)
+ _get_intel_c_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES)
+ endif()
+ if (_result EQUAL 0)
+ _get_intel_c_features(${CMAKE_C90_STANDARD_COMPILE_OPTION} CMAKE_C90_COMPILE_FEATURES)
+ endif()
+ endif()
+endmacro()
+
set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")