Skip to content

Commit afd0da3

Browse files
committed
cmake: Optimize tablegen invocation.
1 parent 059f0b0 commit afd0da3

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

cmake/AddVAST.cmake

+14-4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ function(vast_tablegen ofn)
5959
)
6060
endif()
6161

62+
if (CMAKE_GENERATOR MATCHES "Visual Studio")
63+
# Visual Studio has problems with llvm-tblgen's native --write-if-changed
64+
# behavior. Since it doesn't do restart optimizations anyway, just don't
65+
# pass --write-if-changed there.
66+
set(vast_tblgen_change_flag)
67+
else()
68+
set(vast_tblgen_change_flag "--write-if-changed")
69+
endif()
70+
6271
# We need both _TABLEGEN_TARGET and _TABLEGEN_EXE in the DEPENDS list
6372
# (both the target and the file) to have .inc files rebuilt on
6473
# a tablegen change, as cmake does not propagate file-level dependencies
@@ -75,19 +84,20 @@ function(vast_tablegen ofn)
7584
list(REMOVE_ITEM vast_tablegen_includes "")
7685
list(TRANSFORM vast_tablegen_includes PREPEND -I)
7786

78-
set(tablegen_exe ${VAST_TABLEGEN_EXE})
79-
set(tablegen_depends ${VAST_TABLEGEN_TARGET} ${tablegen_exe})
87+
set(vast_tablegen_exe ${VAST_TABLEGEN_EXE})
88+
set(vast_tablegen_depends ${VAST_TABLEGEN_TARGET} ${vast_tablegen_exe})
8089

8190
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
82-
COMMAND ${tablegen_exe} ${ARG_UNPARSED_ARGUMENTS} -I ${CMAKE_CURRENT_SOURCE_DIR}
91+
COMMAND ${vast_tablegen_exe} ${ARG_UNPARSED_ARGUMENTS} -I ${CMAKE_CURRENT_SOURCE_DIR}
8392
${vast_tablegen_includes}
8493
${VAST_TABLEGEN_FLAGS}
8594
${VAST_TARGET_DEFINITIONS_ABSOLUTE}
95+
${vast_tblgen_change_flag}
8696
${additional_cmdline}
8797
# The file in VAST_TARGET_DEFINITIONS may be not in the current
8898
# directory and local_tds may not contain it, so we must
8999
# explicitly list it here:
90-
DEPENDS ${ARG_DEPENDS} ${tablegen_depends}
100+
DEPENDS ${ARG_DEPENDS} ${vast_tablegen_depends}
91101
${local_tds} ${global_tds}
92102
${VAST_TARGET_DEFINITIONS_ABSOLUTE}
93103
${VAST_TARGET_DEPENDS}

0 commit comments

Comments
 (0)