Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ option_if_not_defined(GPGMM_ENABLE_D3D12 "Enable compilation of the D3D12 backen
option_if_not_defined(GPGMM_ENABLE_VK "Enable compilation of the Vulkan backend" ${ENABLE_VK})
option_if_not_defined(GPGMM_ENABLE_VK_STATIC_FUNCTIONS "Links Vulkan functions by statically importing them" ON)
option_if_not_defined(GPGMM_ENABLE_VK_LOADER "Enables compilation of Vulkan loader" ${ENABLE_VK_LOADER})
option_if_not_defined(GPGMM_ENABLE_VK_USE_SDK "Enable compilation of the Vulkan backend by using the installed Vulkan SDK." OFF)

set_if_not_defined(GPGMM_THIRD_PARTY_DIR "${GPGMM_SOURCE_DIR}/third_party" "Directory in which to find third-party dependencies.")
set_if_not_defined(GPGMM_VK_DEPS_DIR "${GPGMM_THIRD_PARTY_DIR}/vulkan-deps" "Directory in which to find vulkan-deps")
set_if_not_defined(GPGMM_VK_HEADERS_DIR "${GPGMM_VK_DEPS_DIR}/vulkan-headers/src" "Directory in which to find Vulkan-Headers")
set_if_not_defined(GPGMM_VK_TOOLS_DIR "${GPGMM_VK_DEPS_DIR}/vulkan-tools/src" "Directory in which to find Vulkan-Tools")

option_if_not_defined(GPGMM_ALWAYS_ASSERT "Enable assertions on all build types" OFF)
option_if_not_defined(GPGMM_FORCE_TRACING "Enables event tracing even in release builds" OFF)
Expand Down
19 changes: 14 additions & 5 deletions src/gpgmm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,22 @@ if (GPGMM_ENABLE_VK)
)

if (GPGMM_ENABLE_VK_LOADER)
target_link_libraries(gpgmm PRIVATE
Vulkan::Vulkan
)
if (GPGMM_ENABLE_VK_USE_SDK)
target_link_libraries(gpgmm PRIVATE
${GPGMM_VK_LIBRARIES_DIR}
)
else()
target_link_libraries(gpgmm PRIVATE
Vulkan::Vulkan
)
endif()
endif()

target_link_libraries(gpgmm PUBLIC Vulkan-Headers)
target_include_directories(gpgmm PRIVATE ${GPGMM_VK_TOOLS_DIR})
if (GPGMM_ENABLE_VK_USE_SDK)
target_include_directories(gpgmm PUBLIC ${GPGMM_VK_INCLUDE_DIR})
else()
target_link_libraries(gpgmm PUBLIC Vulkan-Headers)
endif()

endif()

Expand Down
4 changes: 0 additions & 4 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ if (GPGMM_ENABLE_VK)
"VKTest.h"
"end2end/VKResourceAllocatorTests.cpp"
)

target_link_libraries(gpgmm_end2end_tests PRIVATE
Vulkan::Vulkan
)
endif()

target_link_libraries(gpgmm_end2end_tests PRIVATE
Expand Down
41 changes: 27 additions & 14 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,32 @@ if (GPGMM_ENABLE_TESTS)
endif() # GPGMM_ENABLE_TESTS

if (GPGMM_ENABLE_VK)
FetchContent_Declare(
vulkan-headers
GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers.git
GIT_TAG ${GPGMM_VULKAN_HEADERS_REVISION}
)
FetchContent_MakeAvailable(vulkan-headers)
if (GPGMM_ENABLE_VK_USE_SDK)
message(INFO "Using installed Vulkan SDK")
find_package(Vulkan REQUIRED)

set(GPGMM_VK_INCLUDE_DIR ${Vulkan_INCLUDE_DIRS} CACHE STRING "" FORCE)
set(GPGMM_VK_LIBRARIES_DIR ${Vulkan_LIBRARIES} CACHE STRING "" FORCE)
message(INFO "Using Vulkan include directory: ${GPGMM_VK_INCLUDE_DIR}")
message(INFO "Using Vulkan library directory: ${GPGMM_VK_LIBRARIES_DIR}")

else()
FetchContent_Declare(
vulkan-headers
GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers.git
GIT_TAG ${GPGMM_VULKAN_HEADERS_REVISION}
)
FetchContent_MakeAvailable(vulkan-headers)

if (GPGMM_ENABLE_VK_LOADER)
FetchContent_Declare(
vulkan-loader
GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Loader.git
GIT_TAG ${GPGMM_VULKAN_LOADER_REVISION}
)
FetchContent_MakeAvailable(vulkan-loader)

endif() # GPGMM_ENABLE_VK_LOADER
endif() # GPGMM_ENABLE_VK_USE_SDK

if (GPGMM_ENABLE_VK_LOADER)
FetchContent_Declare(
vulkan-loader
GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Loader.git
GIT_TAG ${GPGMM_VULKAN_LOADER_REVISION}
)
FetchContent_MakeAvailable(vulkan-loader)
endif() # GPGMM_ENABLE_VK_LOADER
endif() # GPGMM_ENABLE_VK