From c2702a2b2747785dfada7dd427a327b2665fac3a Mon Sep 17 00:00:00 2001
From: Tobias Frisch <tfrisch@uni-koblenz.de>
Date: Thu, 9 Jun 2022 01:46:06 +0200
Subject: [PATCH] Forwarded the option to link statically or dynamically to VMA

Signed-off-by: Tobias Frisch <tfrisch@uni-koblenz.de>
---
 config/lib/VulkanMemoryAllocator.cmake | 13 +++++++++++--
 config/lib/vma/CMakeLists.txt          |  6 +++++-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/config/lib/VulkanMemoryAllocator.cmake b/config/lib/VulkanMemoryAllocator.cmake
index 3d5b0937..6dc61dd1 100644
--- a/config/lib/VulkanMemoryAllocator.cmake
+++ b/config/lib/VulkanMemoryAllocator.cmake
@@ -13,8 +13,17 @@ if (${vma_hpp_status})
 	
 	set(VMA_RECORDING_ENABLED OFF CACHE INTERNAL "")
 	set(VMA_USE_STL_CONTAINERS OFF CACHE INTERNAL "")
-	set(VMA_STATIC_VULKAN_FUNCTIONS ON CACHE INTERNAL "")
-	set(VMA_DYNAMIC_VULKAN_FUNCTIONS OFF CACHE INTERNAL "")
+	
+	string(COMPARE EQUAL "${vkcv_build_attribute}" "SHARED" VMA_USE_DYNAMIC_LINKING)
+	
+	if (${VMA_USE_DYNAMIC_LINKING})
+		set(VMA_STATIC_VULKAN_FUNCTIONS OFF CACHE INTERNAL "")
+		set(VMA_DYNAMIC_VULKAN_FUNCTIONS ON CACHE INTERNAL "")
+	else()
+		set(VMA_STATIC_VULKAN_FUNCTIONS ON CACHE INTERNAL "")
+		set(VMA_DYNAMIC_VULKAN_FUNCTIONS OFF CACHE INTERNAL "")
+	endif()
+	
 	set(VMA_DEBUG_ALWAYS_DEDICATED_MEMORY OFF CACHE INTERNAL "")
 	set(VMA_DEBUG_INITIALIZE_ALLOCATIONS OFF CACHE INTERNAL "")
 	set(VMA_DEBUG_GLOBAL_MUTEX OFF CACHE INTERNAL "")
diff --git a/config/lib/vma/CMakeLists.txt b/config/lib/vma/CMakeLists.txt
index a656c6f5..8b177fdc 100644
--- a/config/lib/vma/CMakeLists.txt
+++ b/config/lib/vma/CMakeLists.txt
@@ -30,7 +30,11 @@ message(STATUS "VMA_DEBUG_INITIALIZE_ALLOCATIONS = ${VMA_DEBUG_INITIALIZE_ALLOCA
 message(STATUS "VMA_DEBUG_GLOBAL_MUTEX = ${VMA_DEBUG_GLOBAL_MUTEX}")
 message(STATUS "VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT = ${VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT}")
 
-add_library(VulkanMemoryAllocator vma.cpp)
+if (${VMA_STATIC_VULKAN_FUNCTIONS})
+	add_library(VulkanMemoryAllocator STATIC vma.cpp)
+else()
+	add_library(VulkanMemoryAllocator SHARED vma.cpp)
+endif()
 
 set_target_properties(
 		VulkanMemoryAllocator PROPERTIES
-- 
GitLab