Skip to content

Commit

Permalink
Simplified to used unified1/spirv.h out of the box
Browse files Browse the repository at this point in the history
  • Loading branch information
Hai Nguyen committed Aug 2, 2018
1 parent bece5c7 commit 5598462
Show file tree
Hide file tree
Showing 5 changed files with 1,078 additions and 37 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "third_party/SPIRV-Headers"]
path = third_party/SPIRV-Headers
url = https://github.com/KhronosGroup/SPIRV-Headers
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://github.com/google/googletest
32 changes: 0 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,6 @@ set(CMAKE_CXX_STANDARD 14)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")

set(VULKAN_DIR_FOUND FALSE)
if (NOT VULKAN_DIR)
set(VULKAN_DIR $ENV{VULKAN_SDK})
endif()
if (NOT "${VULKAN_DIR}" STREQUAL "")
message(STATUS "Using Vulkan found at ${VULKAN_DIR}")
set(VULKAN_DIR_FOUND TRUE)
endif()

# Figure out where the spirv.h header is located. Prefer the unified1 dir in the SPIRV-Headers submodule,
# and allow parent proejcts to override the location if they wish, and fall back on the Vulkan SDK if all
# else fails.
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/SPIRV-Headers)
add_subdirectory(third_party/SPIRV-Headers)
endif()
if (DEFINED SPIRV-Headers_SOURCE_DIR)
set(SPIRV_REFLECT_SPIRV_HEADERS_DIR ${SPIRV-Headers_SOURCE_DIR}/include/spirv/unified1)
else()
message(STATUS "SPIRV-Headers directory not found; falling back on Vulkan SDK")
if(NOT ${VULKAN_DIR_FOUND})
message(FATAL_ERROR "VULKAN_DIR not set, use -DVULKAN_DIR=<path> or set VULKAN_SDK environment variable")
endif()
set(SPIRV_REFLECT_SPIRV_HEADERS_DIR ${VULKAN_DIR}/include/vulkan)
endif()
message(STATUS "Building with spirv.h from ${SPIRV_REFLECT_SPIRV_HEADERS_DIR}")
include_directories(${SPIRV_REFLECT_SPIRV_HEADERS_DIR})

add_executable(spirv-reflect ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/spirv_reflect.h
${CMAKE_CURRENT_SOURCE_DIR}/spirv_reflect.c
Expand Down Expand Up @@ -81,9 +54,4 @@ if (SPIRV_REFLECT_BUILD_TESTS)
add_custom_command(TARGET test-spirv-reflect POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/tests ${CMAKE_CURRENT_BINARY_DIR}/tests)
if (${VULKAN_DIR_FOUND})
target_compile_definitions(test-spirv-reflect PRIVATE SPIRV_REFLECT_HAS_VULKAN_H)
target_include_directories(test-spirv-reflect PRIVATE ${VULKAN_DIR}/include)
endif()

endif()
Loading

0 comments on commit 5598462

Please sign in to comment.