[PATCH] D134693: [CMake] Add `CLANG_ENABLE_HLSL` CMake option

Chris Bieneman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 26 19:47:05 PDT 2022


beanz created this revision.
beanz added reviewers: phosek, smeenai, compnerd.
Herald added a subscriber: Anastasia.
Herald added a project: All.
beanz requested review of this revision.
Herald added a project: clang.

The HLSL support in clang is in proress and not fully functioning. As
such we don't want to install the related optional build components by
default (yet), but we do need an option to build and install them
locally for testing and for some key users.

This adds the `CLANG_ENABLE_HLSL` option which is off by default and can
be enabled to install the HLSL clang headers and the clang-dxc symlink.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134693

Files:
  clang/CMakeLists.txt
  clang/cmake/caches/HLSL.cmake
  clang/lib/Headers/CMakeLists.txt
  clang/tools/driver/CMakeLists.txt


Index: clang/tools/driver/CMakeLists.txt
===================================================================
--- clang/tools/driver/CMakeLists.txt
+++ 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()
 
Index: clang/lib/Headers/CMakeLists.txt
===================================================================
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -548,10 +548,14 @@
   EXCLUDE_FROM_ALL
   COMPONENT x86-resource-headers)
 
+if(NOT CLANG_ENABLE_HLSL)
+  set(EXCLUDE_HLSL EXCLUDE_FROM_ALL)
+endif()
+
 install(
   FILES ${hlsl_files}
   DESTINATION ${header_install_dir}
-  EXCLUDE_FROM_ALL
+  ${EXCLUDE_HLSL}
   COMPONENT hlsl-resource-headers)
 
 install(
Index: clang/cmake/caches/HLSL.cmake
===================================================================
--- clang/cmake/caches/HLSL.cmake
+++ 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 "")
Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ 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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134693.463079.patch
Type: text/x-patch
Size: 1868 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220927/9cecdbbd/attachment.bin>


More information about the cfe-commits mailing list