From 815b4d88b6b1b116be07657d8880f6ce8393db06 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 13 Jan 2020 16:52:12 +0000 Subject: [PATCH] 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 Tested-by: Ben Clayton --- CMakeLists.txt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56f517cc93d..dd7fdc4e314 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2084,15 +2084,29 @@ if(BUILD_CPPDAP) 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}"