CMakeLists.txt: Copy OpenCLDebugInfo100.h to new dir

SPIRV-Tools generates extension header files into the the project's intermediate build directory. SpirvShader needs to include `OpenCLDebugInfo100.h`, so copy this out to a "clean room" include directory and add this directory to the vk_swiftshader INCLUDE_DIRECTORIES.

All of this smell should go away once https://github.com/KhronosGroup/SPIRV-Headers/issues/137 is addressed.

Bug: b/145351270
Change-Id: Ib9205e04d32e2d8e0a6516449ec9114a3ff6dd94
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/40090
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 56f517c..dd7fdc4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2084,15 +2084,29 @@
 endif(BUILD_CPPDAP)
 
 if(SWIFTSHADER_BUILD_VULKAN)
+    add_library(vk_swiftshader SHARED ${VULKAN_LIST})
+
     if (NOT TARGET SPIRV-Tools)
         # This variable is also used by SPIRV-Tools to locate SPIRV-Headers
         set(SPIRV-Headers_SOURCE_DIR "${THIRD_PARTY_DIR}/SPIRV-Headers")
         list(APPEND VULKAN_INCLUDE_DIR "${SPIRV-Headers_SOURCE_DIR}/include")
 
         add_subdirectory(third_party/SPIRV-Tools)
-    endif()
 
-    add_library(vk_swiftshader SHARED ${VULKAN_LIST})
+        # Copy the OpenCLDebugInfo100.h header that's generated by SPIRV-Tools
+        # out to a separate directory that can be added to the include path.
+        # Ideally, this header would just be pre-built and part of SPIRV-Headers.
+        # See: https://github.com/KhronosGroup/SPIRV-Headers/issues/137
+        set(SPIRV_TOOLS_EXT_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/spirv-tools-ext/include)
+        add_custom_target(spirv_tools_ext_includes
+            DEPENDS spirv-tools-header-OpenCLDebugInfo100
+            COMMAND ${CMAKE_COMMAND} -E copy
+                ${spirv-tools_BINARY_DIR}/OpenCLDebugInfo100.h
+                ${SPIRV_TOOLS_EXT_INC_DIR}/spirv-tools/ext/OpenCLDebugInfo100.h
+        )
+        list(APPEND VULKAN_INCLUDE_DIR "${SPIRV_TOOLS_EXT_INC_DIR}")
+        add_dependencies(vk_swiftshader spirv_tools_ext_includes)
+    endif()
 
     set_target_properties(vk_swiftshader PROPERTIES
         INCLUDE_DIRECTORIES "${VULKAN_INCLUDE_DIR}"