Skip to content

Commit 8080a63

Browse files
committed
[cmake] Don't generate per-file "__SHORT_FILE__" defines on MSVC builds
As reported on llvm#150677 - this prevents build parallelisation as cmake is repeatedly updating the cache
1 parent 73245b0 commit 8080a63

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

llvm/cmake/modules/LLVMProcessSources.cmake

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,16 @@ 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_source_files_properties(${fn} PROPERTIES COMPILE_DEFINITIONS "__SHORT_FILE__=\"${short_name}\"")
66-
endif()
67-
endforeach()
68-
61+
# Don't generate __SHORT_FILE__ on MSVC builds as it can force repeated cache regeneration.
62+
if(NOT MSVC)
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_source_files_properties(${fn} PROPERTIES COMPILE_DEFINITIONS "__SHORT_FILE__=\"${short_name}\"")
68+
endif()
69+
endforeach()
70+
endif()
6971

7072
# This adds .td and .h files to the Visual Studio solution:
7173
add_td_sources(sources)

0 commit comments

Comments
 (0)