Skip to content

Commit

Permalink
Use vku with vcpkg overlays.
Browse files Browse the repository at this point in the history
  • Loading branch information
stripe2933 committed Jul 21, 2024
1 parent 50eb89c commit 97ae723
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 14 deletions.
12 changes: 1 addition & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,7 @@ include(${CMAKE_CURRENT_BINARY_DIR}/CPM.cmake)

find_package(glfw3 CONFIG REQUIRED)
find_package(glm CONFIG REQUIRED)

if (USE_VCPKG)
set(VCPKG_PATCH_FILE "${CMAKE_CURRENT_BINARY_DIR}/_deps/vku-src/vcpkg-deps.patch")
endif()
CPMAddPackage(
NAME vku
GITHUB_REPOSITORY stripe2933/vku
GIT_TAG module
PATCHES ${VCPKG_PATCH_FILE} # Apply patch if USE_VCPKG enabled.
OPTIONS "VKU_USE_STD_MODULE ON"
)
find_package(vku CONFIG REQUIRED)

# ----------------
# Module configurations for external dependencies.
Expand Down
3 changes: 1 addition & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"inherits": "default",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_OVERLAY_PORTS": "${sourceDir}/overlays",
"USE_VCPKG": "ON"
"VCPKG_OVERLAY_PORTS": "${sourceDir}/overlays"
}
}
]
Expand Down
26 changes: 26 additions & 0 deletions overlays/vku/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO stripe2933/vku
REF v0.1.0-test5
SHA512 e4aa0b0195886dca6ae5a718ab68e1901b014bd430e31dae166fd7ca1308b1eebc041d0b8a261e9aee993e16ee91ac7b1c15910a9cfbfafc179191dfbbbf67a0
HEAD_REF module
PATCHES vcpkg-deps.patch
)

# Module project doesn't use header files.
set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)

vcpkg_cmake_configure(SOURCE_PATH "${SOURCE_PATH}")
vcpkg_cmake_install()

file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/share)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/cmake/vku ${CURRENT_PACKAGES_DIR}/debug/share/vku)
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share)
file(RENAME ${CURRENT_PACKAGES_DIR}/cmake/vku ${CURRENT_PACKAGES_DIR}/share/vku)

vcpkg_cmake_config_fixup(PACKAGE_NAME "vku")

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/cmake" "${CURRENT_PACKAGES_DIR}/debug/cmake")

file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
configure_file("${CMAKE_CURRENT_LIST_DIR}/usage" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" COPYONLY)
4 changes: 4 additions & 0 deletions overlays/vku/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vku provides CMake targets:

find_package(vku CONFIG REQUIRED)
target_link_libraries(main PRIVATE vku::vku)
44 changes: 44 additions & 0 deletions overlays/vku/vcpkg-deps.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Subject: [PATCH] vcpkg-based dependency management.
---
Index: extlibs/module-ports/vk_mem_alloc.cppm
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/extlibs/module-ports/vk_mem_alloc.cppm b/extlibs/module-ports/vk_mem_alloc.cppm
--- a/extlibs/module-ports/vk_mem_alloc.cppm (revision 9ce74395ceab83fe55a4ae8ee8a6b8020e832542)
+++ b/extlibs/module-ports/vk_mem_alloc.cppm (date 1721481973172)
@@ -1,6 +1,6 @@
module;
#define VMA_IMPLEMENTATION
-#include <vk_mem_alloc.hpp>
+#include <vulkan-memory-allocator-hpp/vk_mem_alloc.hpp>
export module vk_mem_alloc_hpp;

export namespace VMA_HPP_NAMESPACE {
Index: CMakeLists.txt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt (revision 9ce74395ceab83fe55a4ae8ee8a6b8020e832542)
+++ b/CMakeLists.txt (date 1721481973176)
@@ -14,7 +14,7 @@

find_package(Vulkan 1.3.256 REQUIRED)
find_package(VulkanMemoryAllocator CONFIG REQUIRED)
-find_package(VulkanMemoryAllocator-Hpp CONFIG REQUIRED)
+find_package(unofficial-vulkan-memory-allocator-hpp CONFIG REQUIRED)

# ----------------
# Module configurations for the external dependencies.
@@ -50,7 +50,7 @@
target_link_libraries(VulkanMemoryAllocator-Hpp_module PUBLIC
Vulkan::Vulkan
GPUOpen::VulkanMemoryAllocator
- VulkanMemoryAllocator-Hpp::VulkanMemoryAllocator-Hpp
+ unofficial::VulkanMemoryAllocator-Hpp::VulkanMemoryAllocator-Hpp
)

add_library(VulkanMemoryAllocator-Hpp::module ALIAS VulkanMemoryAllocator-Hpp_module)
18 changes: 18 additions & 0 deletions overlays/vku/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "vku",
"version": "0.1.0",
"homepage": "https://github.com/stripe2933/vku",
"description": "Vulkan simplifications.",
"license": "MIT",
"dependencies": [
{
"name" : "vcpkg-cmake",
"host" : true
},
{
"name" : "vcpkg-cmake-config",
"host" : true
},
"vulkan-memory-allocator-hpp"
]
}
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"dependencies": [
"glfw3",
"glm",
"vulkan-memory-allocator-hpp"
"vku"
]
}

0 comments on commit 97ae723

Please sign in to comment.