Browse Source

Merge topic 'clang-cl-showIncludes' into release-3.28

0d933fc0d9 Ninja: Update showIncludes prefix detection for clang-cl 18
a88acb0a41 Tests/RunCMake/Ninja: Rename showIncludes case for clang-cl <= 17

Acked-by: Kitware Robot <[email protected]>
Merge-request: !9229
Brad King 1 year ago
parent
commit
a98f3631c9

+ 1 - 1
Modules/CMakeDetermineCompilerId.cmake

@@ -1173,7 +1173,7 @@ function(CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX lang userflags)
     ENCODING AUTO # cl prints in console output code page
     )
   string(REPLACE "\n" "\n  " msg "  ${out}")
-  if(res EQUAL 0 AND "${out}" MATCHES "(^|\n)([^:\n][^:\n]+:[^:\n]*[^: \n][^: \n]:?[ \t]+)([A-Za-z]:\\\\|\\./|/)")
+  if(res EQUAL 0 AND "${out}" MATCHES "(^|\n)([^:\n][^:\n]+:[^:\n]*[^: \n][^: \n]:?[ \t]+)([A-Za-z]:\\\\|\\./|\\.\\\\|/)")
     set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "${CMAKE_MATCH_2}" PARENT_SCOPE)
     string(APPEND msg "\nFound prefix \"${CMAKE_MATCH_2}\"")
   else()

+ 2 - 1
Tests/RunCMake/Ninja/RunCMakeTest.cmake

@@ -46,7 +46,8 @@ if(WIN32)
   if(RunCMake_MAKE_PROGRAM)
     set(maybe_MAKE_PROGRAM "-DRunCMake_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM}")
   endif()
-  run_cmake_script(ShowIncludes-437-ClangCl -DshowIncludes=${showIncludes} ${maybe_MAKE_PROGRAM})
+  run_cmake_script(ShowIncludes-437-ClangCl-17 -DshowIncludes=${showIncludes} ${maybe_MAKE_PROGRAM})
+  run_cmake_script(ShowIncludes-437-ClangCl-18 -DshowIncludes=${showIncludes} ${maybe_MAKE_PROGRAM})
   run_cmake_script(ShowIncludes-437-English -DshowIncludes=${showIncludes} ${maybe_MAKE_PROGRAM})
   run_cmake_script(ShowIncludes-437-French -DshowIncludes=${showIncludes} ${maybe_MAKE_PROGRAM})
   run_cmake_script(ShowIncludes-437-German -DshowIncludes=${showIncludes} ${maybe_MAKE_PROGRAM})

+ 1 - 1
Tests/RunCMake/Ninja/ShowIncludes-437-ClangCl-check.cmake → Tests/RunCMake/Ninja/ShowIncludes-437-ClangCl-17-check.cmake

@@ -1,3 +1,3 @@
-# 'clang-cl /showIncludes' prefix.
+# 'clang-cl /showIncludes' prefix for clang-cl <= 17.
 set(expect "Note: including file: ")
 include(${CMAKE_CURRENT_LIST_DIR}/ShowIncludes-check.cmake)

+ 0 - 0
Tests/RunCMake/Ninja/ShowIncludes-437-ClangCl-stdout.txt → Tests/RunCMake/Ninja/ShowIncludes-437-ClangCl-17-stdout.txt


+ 1 - 1
Tests/RunCMake/Ninja/ShowIncludes-437-ClangCl.cmake → Tests/RunCMake/Ninja/ShowIncludes-437-ClangCl-17.cmake

@@ -1,3 +1,3 @@
 set(CODEPAGE 437)
-set(VSLANG "clang-cl") # Special case for test, not a real VS value.
+set(VSLANG "clang-cl-17") # Special case for test, not a real VS value.
 include(${CMAKE_CURRENT_LIST_DIR}/ShowIncludes.cmake)

+ 3 - 0
Tests/RunCMake/Ninja/ShowIncludes-437-ClangCl-18-check.cmake

@@ -0,0 +1,3 @@
+# 'clang-cl /showIncludes' prefix for clang-cl >= 18.
+set(expect "Note: including file: ")
+include(${CMAKE_CURRENT_LIST_DIR}/ShowIncludes-check.cmake)

+ 1 - 0
Tests/RunCMake/Ninja/ShowIncludes-437-ClangCl-18-stdout.txt

@@ -0,0 +1 @@
+-- showIncludes='Note: including file: '

+ 3 - 0
Tests/RunCMake/Ninja/ShowIncludes-437-ClangCl-18.cmake

@@ -0,0 +1,3 @@
+set(CODEPAGE 437)
+set(VSLANG "clang-cl-18") # Special case for test, not a real VS value.
+include(${CMAKE_CURRENT_LIST_DIR}/ShowIncludes.cmake)

+ 10 - 2
Tests/RunCMake/showIncludes.c

@@ -28,14 +28,22 @@ int main()
   printf("OEM code page: %u\n", GetOEMCP());
   printf("VSLANG: %s\n", vslang);
 
-  // clang-cl (special case for test, not a real VS value).
-  if (strcmp(vslang, "clang-cl") == 0) {
+  // clang-cl <= 17 (special case for test, not a real VS value).
+  if (strcmp(vslang, "clang-cl-17") == 0) {
     if (cp == 437 || cp == 65001) {
       printf("Note: including file: ./foo.h\n");
       return 0;
     }
   }
 
+  // clang-cl >= 18 (special case for test, not a real VS value).
+  if (strcmp(vslang, "clang-cl-18") == 0) {
+    if (cp == 437 || cp == 65001) {
+      printf("Note: including file: .\\\\foo.h\n");
+      return 0;
+    }
+  }
+
   // msvc-wine (special case for test, not a real VS value).
   if (strcmp(vslang, "msvc-wine") == 0) {
     if (cp == 437 || cp == 65001) {