Skip to content

Commit ddcbecf

Browse files
Copilotdamyanp
andcommitted
Auto-derive hctgen target names from mode + output extension
Instead of a special-purpose TARGET_NAME parameter, the CMake target name is now automatically derived as "${mode}_${extension}" (e.g. DxilCounters_h, DxilCounters_cpp). This resolves the DxilCounters name conflict between the .h and .cpp targets without any caller-visible special-casing. Update the one external reference (DxilIntrinsicTables → DxilIntrinsicTables_h) in tools/clang/lib/Sema/CMakeLists.txt. Co-authored-by: damyanp <[email protected]> Agent-Logs-Url: https://github.com/damyanp/DirectXShaderCompiler/sessions/9de1b168-12bd-407d-b2e7-e83f2480dc9d
1 parent 04b7714 commit ddcbecf

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

cmake/modules/HCT.cmake

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,9 @@ endif()
3838
function(add_hlsl_hctgen mode)
3939
cmake_parse_arguments(ARG
4040
"BUILD_DIR;CODE_TAG"
41-
"OUTPUT;TARGET_NAME"
41+
"OUTPUT"
4242
""
4343
${ARGN})
44-
if (NOT ARG_TARGET_NAME)
45-
set(ARG_TARGET_NAME ${mode})
46-
endif()
4744

4845
if (NOT ARG_OUTPUT)
4946
message(FATAL_ERROR "add_hlsl_hctgen requires OUTPUT argument")
@@ -70,6 +67,8 @@ function(add_hlsl_hctgen mode)
7067
${opcodes_json})
7168

7269
get_filename_component(output_extension ${full_output} LAST_EXT)
70+
string(SUBSTRING ${output_extension} 1 -1 output_extension_no_dot)
71+
set(target_name "${mode}_${output_extension_no_dot}")
7372

7473
if (CLANG_FORMAT_EXE AND output_extension MATCHES "\.h|\.cpp|\.inl")
7574
set(format_cmd COMMAND ${CLANG_FORMAT_EXE} -i ${temp_output})
@@ -135,8 +134,8 @@ function(add_hlsl_hctgen mode)
135134
DEPENDS ${output}
136135
COMMENT "Verifying clang-format results...")
137136

138-
add_custom_target(${ARG_TARGET_NAME}
137+
add_custom_target(${target_name}
139138
DEPENDS ${temp_output}.stamp)
140139

141-
add_dependencies(HCTGen ${ARG_TARGET_NAME})
140+
add_dependencies(HCTGen ${target_name})
142141
endfunction()

lib/DXIL/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is distributed under the University of Illinois Open Source License.
33
# See LICENSE.TXT for details.
44

5-
add_hlsl_hctgen(DxilCounters OUTPUT DxilCounters.cpp CODE_TAG TARGET_NAME DxilCountersCpp)
5+
add_hlsl_hctgen(DxilCounters OUTPUT DxilCounters.cpp CODE_TAG)
66
add_hlsl_hctgen(DxilOperations OUTPUT DxilOperations.cpp CODE_TAG)
77
add_hlsl_hctgen(DxilShaderModel OUTPUT DxilShaderModel.cpp CODE_TAG)
88
add_hlsl_hctgen(DxilMetadata OUTPUT DxilMetadataHelper.cpp CODE_TAG)

tools/clang/lib/Sema/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(LLVM_LINK_COMPONENTS
66
# HLSL Change Begin
77
add_hlsl_hctgen(DxilIntrinsicTables BUILD_DIR OUTPUT gen_intrin_main_tables_15.h)
88
include_directories(${CMAKE_CURRENT_BINARY_DIR})
9-
list(APPEND LLVM_COMMON_DEPENDS DxilIntrinsicTables)
9+
list(APPEND LLVM_COMMON_DEPENDS DxilIntrinsicTables_h)
1010
# HLSL Change End
1111

1212
add_clang_library(clangSema

0 commit comments

Comments
 (0)