Ninja: Record showIncludes detection in configure log

Also avoid running the detection multiple times.
This commit is contained in:
Brad King
2023-01-26 14:43:58 -05:00
parent 7ac338be98
commit a9d97492fd

View File

@@ -219,6 +219,9 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
AND MSVC_${lang}_ARCHITECTURE_ID)
foreach(userflags "${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}" "")
CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX(${lang} "${userflags}")
if(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX)
break()
endif()
endforeach()
else()
set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "")
@@ -1140,9 +1143,12 @@ function(CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX lang userflags)
RESULT_VARIABLE res
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]*:[ \t]*)")
set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "${CMAKE_MATCH_2}" PARENT_SCOPE)
string(APPEND msg "\nFound prefix \"${CMAKE_MATCH_2}\"")
else()
set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "" PARENT_SCOPE)
endif()
message(CONFIGURE_LOG "Detecting ${lang} compiler /showIncludes prefix:\n${msg}\n")
endfunction()