Skip to content

Commit

Permalink
[CMake] Add an option to disable source generation
Browse files Browse the repository at this point in the history
This change adds a new CMake configuration option
`HLSL_DISABLE_SOURCE_GENERATION` which allows a user to disable
generating the in-tree sources which contributte to DXC's source
releases. This option should only be used by users building DXC and not
modifying it.

Resolves microsoft#6728
  • Loading branch information
llvm-beanz committed Jun 27, 2024
1 parent 206133c commit 861e959
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmake/modules/HCT.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
option(HLSL_COPY_GENERATED_SOURCES "Copy generated sources if different" Off)
option(HLSL_DISABLE_SOURCE_GENERATION "Disable generation of in-tree sources" Off)
mark_as_advanced(HLSL_DISABLE_SOURCE_GENERATION)

add_custom_target(HCTGen)

Expand Down Expand Up @@ -43,6 +45,10 @@ function(add_hlsl_hctgen mode)
if (NOT ARG_OUTPUT)
message(FATAL_ERROR "add_hlsl_hctgen requires OUTPUT argument")
endif()

if (HLSL_DISABLE_SOURCE_GENERATION AND NOT ARG_BUILD_DIR)
return()
endif()

set(temp_output ${CMAKE_CURRENT_BINARY_DIR}/tmp/${ARG_OUTPUT})
set(full_output ${CMAKE_CURRENT_SOURCE_DIR}/${ARG_OUTPUT})
Expand Down Expand Up @@ -101,7 +107,7 @@ function(add_hlsl_hctgen mode)
endif()

add_custom_command(OUTPUT ${temp_output}
COMMAND ${Python3_EXECUTABLE}
COMMAND ${PYTHON_EXECUTABLE}
${hctgen} ${force_lf}
${mode} --output ${temp_output} ${input_flag}
${format_cmd}
Expand Down

0 comments on commit 861e959

Please sign in to comment.