Browse Source

Merge topic 'intel-oneapi-std-windows' into release-3.21

a82af0e2ce Merge branch 'backport-3.20-intel-oneapi-std-windows'
1c227583a4 Tests: Fix RunCMake.try_compile C/CXX standards with IntelLLVM MSVC mode
1c14691a86 CMakeCCompilerId: Fix C standard detection in Clang and IntelLLVM MSVC mode
6eea123e3a Tests: Fix RunCMake.try_compile C/CXX standards with IntelLLVM MSVC mode

Acked-by: Kitware Robot <[email protected]>
Merge-request: !6328
Brad King 4 years ago
parent
commit
5df2c45854
1 changed files with 11 additions and 0 deletions
  1. 11 0
      Tests/RunCMake/CMakeLists.txt

+ 11 - 0
Tests/RunCMake/CMakeLists.txt

@@ -443,6 +443,17 @@ function(add_RunCMake_test_try_compile)
       set(CMAKE_C_STANDARD_DEFAULT 11)
     endif()
   endif()
+  if(CMAKE_VERSION VERSION_LESS 3.20.6 AND "x${CMAKE_C_COMPILER_ID}" STREQUAL "xIntelLLVM" AND "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
+    # Older CMake versions accidentally set the default standards to empty when
+    # IntelLLVM targets the MSVC ABI, thus not activating standard selection.
+    # Approximate the logic from IntelLLVM-{C,CXX}.cmake.
+    if(DEFINED CMAKE_C_STANDARD_DEFAULT AND "${CMAKE_C_STANDARD_DEFAULT}" STREQUAL "")
+      set(CMAKE_C_STANDARD_DEFAULT 17)
+    endif()
+    if(DEFINED CMAKE_CXX_STANDARD_DEFAULT AND "${CMAKE_CXX_STANDARD_DEFAULT}" STREQUAL "")
+      set(CMAKE_CXX_STANDARD_DEFAULT 14)
+    endif()
+  endif()
   foreach(var
       CMAKE_SYSTEM_NAME
       CMAKE_C_COMPILER_ID