Skip to content

Commit e646f6d

Browse files
CMake: use Vulkan-Headers target instead of DILIGENT_VULKAN_HEADERS_DIR variable (DiligentGraphics/DiligentEngine#40)
1 parent bfec34c commit e646f6d

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

Graphics/Archiver/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,10 @@ if(D3D12_SUPPORTED)
112112
endif()
113113

114114
if(VULKAN_SUPPORTED)
115-
target_link_libraries(Diligent-Archiver-static PRIVATE Diligent-GraphicsEngineVk-static)
115+
target_link_libraries(Diligent-Archiver-static PRIVATE Diligent-GraphicsEngineVk-static Vulkan-Headers)
116116
target_include_directories(Diligent-Archiver-static
117117
PRIVATE
118118
../GraphicsEngineVulkan/include
119-
${DILIGENT_VULKAN_HEADERS_DIR}/include
120119
)
121120
endif()
122121

Graphics/GraphicsEngineVulkan/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ target_include_directories(Diligent-GraphicsEngineVk-static
165165
PRIVATE
166166
include
167167
${DILIGENT_VOLK_DIR}
168-
${DILIGENT_VULKAN_HEADERS_DIR}/include
169168
)
170169

171170
set(PRIVATE_DEPENDENCIES
@@ -174,6 +173,7 @@ set(PRIVATE_DEPENDENCIES
174173
Diligent-TargetPlatform
175174
Diligent-GraphicsEngineNextGenBase
176175
Diligent-ShaderTools
176+
Vulkan-Headers
177177
)
178178

179179
if (${DILIGENT_NO_HLSL})

Tests/GPUTestFramework/CMakeLists.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,9 @@ if(PLATFORM_LINUX)
9999
endif()
100100

101101
if(VULKAN_SUPPORTED)
102-
target_include_directories(Diligent-GPUTestFramework
103-
PUBLIC
104-
${DILIGENT_VOLK_DIR}
105-
${DILIGENT_VULKAN_HEADERS_DIR}/include
106-
)
107-
102+
target_include_directories(Diligent-GPUTestFramework PUBLIC ${DILIGENT_VOLK_DIR})
103+
target_link_libraries(Diligent-GPUTestFramework PUBLIC Vulkan-Headers)
104+
108105
if(PLATFORM_LINUX)
109106
target_link_libraries(Diligent-GPUTestFramework
110107
PUBLIC

ThirdParty/CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ if (VULKAN_SUPPORTED OR METAL_SUPPORTED)
2929
endif()
3030
install(FILES "${SPIRV-Headers_SOURCE_DIR}/LICENSE" DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME SPIRV-Headers-License.txt)
3131

32-
if (NOT DILIGENT_VULKAN_HEADERS_DIR)
33-
set(DILIGENT_VULKAN_HEADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Vulkan-Headers" CACHE PATH "Vulkan-Headers source directory")
32+
if (NOT TARGET Vulkan-Headers)
33+
# Manually add the Vulkan-Headers target as this is all we need and the
34+
# project's CMake creates unnecessary targets
35+
add_library(Vulkan-Headers INTERFACE)
36+
# Vulkan-Headers_SOURCE_DIR variable is normally created by project(Vulkan-Headers)
37+
set(Vulkan-Headers_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Vulkan-Headers")
38+
target_include_directories(Vulkan-Headers INTERFACE "${Vulkan-Headers_SOURCE_DIR}/include")
3439
endif()
35-
if (NOT EXISTS "${DILIGENT_VULKAN_HEADERS_DIR}/include/vulkan/vulkan.h")
36-
message(FATAL_ERROR "${DILIGENT_VULKAN_HEADERS_DIR}/include/vulkan/vulkan.h does not exist. This indicates that Vulkan-Headers submodule is not checked out or DILIGENT_VULKAN_HEADERS_DIR variable contains invalid path.")
37-
endif()
38-
install(FILES "${DILIGENT_VULKAN_HEADERS_DIR}/LICENSE.txt" DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME Vulkan-Headers-License.txt)
40+
install(FILES "${Vulkan-Headers_SOURCE_DIR}/LICENSE.txt" DESTINATION "Licenses/ThirdParty/${DILIGENT_CORE_DIR}" RENAME Vulkan-Headers-License.txt)
3941

4042
option(DILIGENT_NO_GLSLANG "Do NOT build glslang compiler" OFF)
4143
option(DILIGENT_IMPROVE_SPIRV_TOOLS_DEBUG_PERF "Enable some optimizations for SPIRV-Tools, glslang, SPIRV-Cross and related projects in debug build to improve performance" ON)

0 commit comments

Comments
 (0)