Ninja: Restore detection of clang-cl showIncludes prefix
Since commit 8f82e755f3
(Ninja: Fix detection of MSVC showIncludes
prefix in Italian, 2023-01-26, v3.26.0-rc1~20^2) our regex no longer
matches the output from `clang-cl`, which uses a relative path, forward
slashes, and is always in English [1]:
Note: including file: ./foo.h
Update the regex to match that too.
[1] https://github.com/llvm/llvm-project/blob/llvmorg-16.0.0/clang/lib/Frontend/HeaderIncludeGen.cpp#L102
Co-authored-by: Brad King <brad.king@kitware.com>
This commit is contained in:
parent
3346570ae9
commit
843fc607de
@ -1144,7 +1144,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()
|
||||
|
@ -46,6 +46,7 @@ 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-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})
|
||||
|
@ -0,0 +1,3 @@
|
||||
# 'clang-cl /showIncludes' prefix.
|
||||
set(expect "Note: including file: ")
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ShowIncludes-check.cmake)
|
1
Tests/RunCMake/Ninja/ShowIncludes-437-ClangCl-stdout.txt
Normal file
1
Tests/RunCMake/Ninja/ShowIncludes-437-ClangCl-stdout.txt
Normal file
@ -0,0 +1 @@
|
||||
-- showIncludes='Note: including file: '
|
3
Tests/RunCMake/Ninja/ShowIncludes-437-ClangCl.cmake
Normal file
3
Tests/RunCMake/Ninja/ShowIncludes-437-ClangCl.cmake
Normal file
@ -0,0 +1,3 @@
|
||||
set(CODEPAGE 437)
|
||||
set(VSLANG "clang-cl") # Special case for test, not a real VS value.
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ShowIncludes.cmake)
|
@ -28,6 +28,14 @@ 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) {
|
||||
if (cp == 437 || cp == 65001) {
|
||||
printf("Note: including file: ./foo.h\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// German.
|
||||
if (strcmp(vslang, "1031") == 0) {
|
||||
if (cp == 437 || cp == 65001) {
|
||||
|
Loading…
Reference in New Issue
Block a user