Skip to content

Commit 061cfbd

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 d3b2bda commit 061cfbd

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 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_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)