Skip to content

Commit

Permalink
Add Vulkan loader.
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianGro committed Dec 14, 2024
1 parent e18d481 commit 11ad496
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmake/ports/hifi-client-deps/CONTROL
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Source: hifi-client-deps
Version: 0.1
Description: Collected dependencies for High Fidelity applications
Build-Depends: hifi-deps, aristo (windows), glslang, liblo (windows), nlohmann-json, openvr ((linux&!arm)|windows), quazip (!android), sdl2 (!android), spirv-cross (!android), spirv-tools (!android), sranipal (windows), vulkanmemoryallocator, vulkan-headers, vulkan-validationlayers, discord-rpc (!android)
Build-Depends: hifi-deps, aristo (windows), glslang, liblo (windows), nlohmann-json, openvr ((linux&!arm)|windows), quazip (!android), sdl2 (!android), spirv-cross (!android), spirv-tools (!android), sranipal (windows), vulkanmemoryallocator, vulkan, vulkan-validationlayers, discord-rpc (!android)
42 changes: 42 additions & 0 deletions cmake/ports/vulkan-loader/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
set(VCPKG_LIBRARY_LINKAGE dynamic)

vcpkg_download_distfile(ARM_COMMENT_SYNTAX_FIX
URLS https://github.com/KhronosGroup/Vulkan-Loader/commit/ce3a4db90513c2dd10fbe56a21207945fbc9339f.patch?full_index=1
SHA512 e08d0be965f2430a5353a30339e1c29e5074d5b751f7894bdfec8c2031916b0e4d39fff1dad0e5ec94e4f2f296fac230dbfcb9a04af4b2d1ad51dffe270d232a
FILENAME vulkan-loader-arm-comment-syntax-ce3a4db90513c2dd10fbe56a21207945fbc9339f.patch
)

vcpkg_download_distfile(NINJA_CLANG_CL_WORKAROUND
URLS https://github.com/KhronosGroup/Vulkan-Loader/commit/4b043de5655d41cee12ef73d986cb7f7a7dbc239.patch?full_index=1
SHA512 327ce23dc1a4e68ef31a02e9847c7aa740f0a81cd62d3fecf5e7efd84149909f2377e031064346ecb6aa2c5ec094413627a3f4b34c674d8713fc1ca01f88fc22
FILENAME vulkan-loader-clang-cl-workaround-4b043de5655d41cee12ef73d986cb7f7a7dbc239.patch
)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO KhronosGroup/Vulkan-Loader
REF "vulkan-sdk-${VERSION}"
SHA512 535b7f324348e9edf44ff6a6a6e9eabe6e3a4bfad79bef789d1dc0cbbe3de36b6495a05236323d155631b081b89c18bb8668c79d1f735b59fc85ebee555aa682
HEAD_REF main
PATCHES
"${ARM_COMMENT_SYNTAX_FIX}"
"${NINJA_CLANG_CL_WORKAROUND}"
)

vcpkg_find_acquire_program(PYTHON3)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DBUILD_TESTS:BOOL=OFF
-DPython3_EXECUTABLE=${PYTHON3}
)
vcpkg_cmake_install()
vcpkg_fixup_pkgconfig()
vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/VulkanLoader" PACKAGE_NAME VulkanLoader)

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")

set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)

configure_file("${CMAKE_CURRENT_LIST_DIR}/usage" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" @ONLY)
2 changes: 2 additions & 0 deletions cmake/ports/vulkan-loader/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The package @PORT@ provides the vulkan loader.
Please be aware of https://github.com/KhronosGroup/Vulkan-Loader/blob/main/docs/LoaderApplicationInterface.md#bundling-the-loader-with-an-application
19 changes: 19 additions & 0 deletions cmake/ports/vulkan-loader/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "vulkan-loader",
"version": "1.3.296.0",
"description": "Vulkan Development Tools",
"homepage": "https://github.com/KhronosGroup/Vulkan-Loader",
"license": null,
"supports": "!android",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
},
"vulkan-headers"
]
}
12 changes: 12 additions & 0 deletions cmake/ports/vulkan/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.25)

project(FIND_VULKAN LANGUAGES C)

find_package(Vulkan ${VCPKG_VULKAN_VERSION} ${VCPKG_VULKAN_COMPONENTS})
if(NOT Vulkan_FOUND)
set(CMAKE_FIND_DEBUG_MODE ON)
find_package(Vulkan ${VCPKG_VULKAN_VERSION} ${VCPKG_VULKAN_COMPONENTS})
endif()

set(OUTFILE "${CMAKE_CURRENT_BINARY_DIR}/vulkan-result.cmake" CACHE FILEPATH "")
configure_file("vulkan-result.cmake.in" "${OUTFILE}" @ONLY ESCAPE_QUOTES)
31 changes: 31 additions & 0 deletions cmake/ports/vulkan/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)

set(vulkan_result_file "${CURRENT_BUILDTREES_DIR}/vulkan-${TARGET_TRIPLET}.cmake.log")
vcpkg_cmake_configure(
SOURCE_PATH "${CMAKE_CURRENT_LIST_DIR}"
OPTIONS_RELEASE
"-DOUTFILE=${vulkan_result_file}"
)

include("${vulkan_result_file}")
if(DETECTED_Vulkan_FOUND)
message(STATUS "Found Vulkan ${DETECTED_Vulkan_VERSION} (${DETECTED_Vulkan_LIBRARIES})")
else()
set(message "Vulkan wasn't found.")
if(VCPKG_TARGET_IS_ANDROID AND DETECTED_ANDROID_NATIVE_API_LEVEL AND DETECTED_ANDROID_NATIVE_API_LEVEL LESS "24")
string(APPEND message " Vulkan support from the Android NDK requires API level 24 (found: ${DETECTED_ANDROID_NATIVE_API_LEVEL})")
endif()
message(FATAL_ERROR "${message}")
endif()

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt"
"${CMAKE_CURRENT_LIST_DIR}/vulkan-result.cmake.in"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}/detect-vulkan"
)

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(WRITE "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" [[
This is a stub package. Copyright and license information
is provided with Vulkan headers and loader.
For Android, the loader is provided by the NDK.
]])
5 changes: 5 additions & 0 deletions cmake/ports/vulkan/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
vulkan is compatible with built-in CMake targets:

# https://cmake.org/cmake/help/latest/module/FindVulkan.html
find_package(Vulkan REQUIRED)
target_link_libraries(main PRIVATE Vulkan::Vulkan)
21 changes: 21 additions & 0 deletions cmake/ports/vulkan/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "vulkan",
"version-date": "2023-12-17",
"description": [
"A stub package that ensures that Vulkan headers and a loader are available.",
"On Android, the NDK provides a loader at API level 24 or higher."
],
"license": null,
"supports": "!uwp & !xbox",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
"vulkan-headers",
{
"name": "vulkan-loader",
"platform": "!android"
}
]
}
5 changes: 5 additions & 0 deletions cmake/ports/vulkan/vulkan-result.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(DETECTED_Vulkan_FOUND "@Vulkan_FOUND@")
set(DETECTED_Vulkan_VERSION "@Vulkan_VERSION@")
set(DETECTED_Vulkan_INCLUDE_DIRS "@Vulkan_INCLUDE_DIRS@")
set(DETECTED_Vulkan_LIBRARIES "@Vulkan_LIBRARIES@")
set(DETECTED_ANDROID_NATIVE_API_LEVEL "@ANDROID_NATIVE_API_LEVEL@")

0 comments on commit 11ad496

Please sign in to comment.