diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -482,6 +482,10 @@ "Generate build targets for the Clang unit tests." ${LLVM_INCLUDE_TESTS}) +option(CLANG_ENABLE_HLSL "Include HLSL build products" Off) +# While HLSL support is experimental this should stay hidden. +mark_as_advanced(CLANG_ENABLE_HLSL) + add_subdirectory(utils/TableGen) # Export CLANG_TABLEGEN_EXE for use by flang docs. diff --git a/clang/cmake/caches/HLSL.cmake b/clang/cmake/caches/HLSL.cmake --- a/clang/cmake/caches/HLSL.cmake +++ b/clang/cmake/caches/HLSL.cmake @@ -9,3 +9,5 @@ # HLSL support is currently limted to clang, eventually it will expand to # clang-tools-extra too. set(LLVM_ENABLE_PROJECTS "clang" CACHE STRING "") + +set(CLANG_ENABLE_HLSL On CACHE BOOL "") diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt --- a/clang/lib/Headers/CMakeLists.txt +++ b/clang/lib/Headers/CMakeLists.txt @@ -62,11 +62,15 @@ __clang_hip_runtime_wrapper.h ) -set(hlsl_files - hlsl.h +set(hlsl_h hlsl.h) +set(hlsl_subdir_files hlsl/hlsl_basic_types.h hlsl/hlsl_intrinsics.h ) +set(hlsl_files + ${hlsl_h} + ${hlsl_subdir_files} + ) set(mips_msa_files msa.h @@ -548,10 +552,20 @@ EXCLUDE_FROM_ALL COMPONENT x86-resource-headers) +if(NOT CLANG_ENABLE_HLSL) + set(EXCLUDE_HLSL EXCLUDE_FROM_ALL) +endif() + install( - FILES ${hlsl_files} + FILES ${hlsl_h} DESTINATION ${header_install_dir} - EXCLUDE_FROM_ALL + ${EXCLUDE_HLSL} + COMPONENT hlsl-resource-headers) + +install( + FILES ${hlsl_subdir_files} + DESTINATION ${header_install_dir}/hlsl + ${EXCLUDE_HLSL} COMPONENT hlsl-resource-headers) install( diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -61,7 +61,11 @@ set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp) endif() -foreach(link ${CLANG_LINKS_TO_CREATE}) +if (CLANG_ENABLE_HLSL) + set(HLSL_LINK clang-dxc) +endif() + +foreach(link ${CLANG_LINKS_TO_CREATE} ${HLSL_LINK}) add_clang_symlink(${link} clang) endforeach()