Skip to content

Commit

Permalink
CMakeLists.txt: Copy OpenCLDebugInfo100.h to new dir
Browse files Browse the repository at this point in the history
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 KhronosGroup/SPIRV-Headers#137 is addressed.

Bug: b/145351270
Change-Id: Ib9205e04d32e2d8e0a6516449ec9114a3ff6dd94
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/40090
Reviewed-by: Nicolas Capens <[email protected]>
Tested-by: Ben Clayton <[email protected]>
  • Loading branch information
ben-clayton committed Jan 13, 2020
1 parent 6b7f515 commit 815b4d8
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 815b4d8

Please sign in to comment.