[cmake] Don't generate per-file "__SHORT_FILE__" defines on visual studio builds (#151167)

As reported on #150677 - this is preventing msbuild parallelization as cmake is repeatedly being updated
This commit is contained in:
Simon Pilgrim 2025-07-30 17:10:23 +01:00 committed by GitHub
parent a7b58e74a0
commit 9a84c62da4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -58,16 +58,19 @@ function(llvm_process_sources OUT_VAR)
set(sources ${ARG_UNPARSED_ARGUMENTS}) set(sources ${ARG_UNPARSED_ARGUMENTS})
llvm_check_source_file_list(${sources}) llvm_check_source_file_list(${sources})
foreach(fn ${sources}) # Don't generate __SHORT_FILE__ on VS builds as it can prevent build parallelisation.
get_filename_component(suf ${fn} EXT) if(NOT CMAKE_GENERATOR MATCHES "Visual Studio")
if("${suf}" STREQUAL ".cpp" OR "${suf}" STREQUAL ".c") foreach(fn ${sources})
get_filename_component(short_name ${fn} NAME) get_filename_component(suf ${fn} EXT)
set_property( if("${suf}" STREQUAL ".cpp" OR "${suf}" STREQUAL ".c")
SOURCE ${fn} get_filename_component(short_name ${fn} NAME)
APPEND set_property(
PROPERTY COMPILE_DEFINITIONS __SHORT_FILE__="${short_name}") SOURCE ${fn}
endif() APPEND
endforeach() PROPERTY COMPILE_DEFINITIONS __SHORT_FILE__="${short_name}")
endif()
endforeach()
endif()
# This adds .td and .h files to the Visual Studio solution: # This adds .td and .h files to the Visual Studio solution: