Skip to content

Commit 9a84c62

Browse files
authored
[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
1 parent a7b58e7 commit 9a84c62

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

llvm/cmake/modules/LLVMProcessSources.cmake

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,19 @@ function(llvm_process_sources OUT_VAR)
5858
set(sources ${ARG_UNPARSED_ARGUMENTS})
5959
llvm_check_source_file_list(${sources})
6060

61-
foreach(fn ${sources})
62-
get_filename_component(suf ${fn} EXT)
63-
if("${suf}" STREQUAL ".cpp" OR "${suf}" STREQUAL ".c")
64-
get_filename_component(short_name ${fn} NAME)
65-
set_property(
66-
SOURCE ${fn}
67-
APPEND
68-
PROPERTY COMPILE_DEFINITIONS __SHORT_FILE__="${short_name}")
69-
endif()
70-
endforeach()
61+
# Don't generate __SHORT_FILE__ on VS builds as it can prevent build parallelisation.
62+
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio")
63+
foreach(fn ${sources})
64+
get_filename_component(suf ${fn} EXT)
65+
if("${suf}" STREQUAL ".cpp" OR "${suf}" STREQUAL ".c")
66+
get_filename_component(short_name ${fn} NAME)
67+
set_property(
68+
SOURCE ${fn}
69+
APPEND
70+
PROPERTY COMPILE_DEFINITIONS __SHORT_FILE__="${short_name}")
71+
endif()
72+
endforeach()
73+
endif()
7174

7275

7376
# This adds .td and .h files to the Visual Studio solution:

0 commit comments

Comments
 (0)