Skip to content

Commit

Permalink
WIP: Experiment with vcpkg
Browse files Browse the repository at this point in the history
  • Loading branch information
mikes-lunarg committed Oct 24, 2023
1 parent d8bcd52 commit 65ae947
Show file tree
Hide file tree
Showing 15 changed files with 318 additions and 0 deletions.
54 changes: 54 additions & 0 deletions ports/glslang/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO KhronosGroup/glslang
REF "be564292f00c5bf0d7251c11f1c9618eb1117762"
SHA512 b581f404d7b5a6ee07650c45cc2493f1b200b50d4c504d397644a2dd7e88574f608532be21557eccc84fff727ad84b500476d565859e94ffbac11f647b156ad0
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
tools ENABLE_GLSLANG_BINARIES
rtti ENABLE_RTTI
)

if (ENABLE_GLSLANG_BINARIES)
vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON_PATH ${PYTHON3} DIRECTORY)
vcpkg_add_to_path("${PYTHON_PATH}")
endif ()

if (WIN32)
set(PLATFORM_OPTIONS "-DOVERRIDE_MSVCCRT=OFF")
endif ()

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DBUILD_EXTERNAL=OFF
-DENABLE_CTEST=OFF
-DSKIP_GLSLANG_INSTALL=OFF
-DENABLE_OPT=0
${FEATURE_OPTIONS}
${PLATFORM_OPTIONS}
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/glslang DO_NOT_DELETE_PARENT_CONFIG_PATH)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/${PORT}/glslang-config.cmake"
"${PACKAGE_PREFIX_DIR}/lib/cmake/glslang/glslang-targets.cmake"
"${PACKAGE_PREFIX_DIR}/share/${PORT}/glslang-targets.cmake"
)

vcpkg_copy_pdbs()

if (ENABLE_GLSLANG_BINARIES)
vcpkg_copy_tools(TOOL_NAMES glslangValidator spirv-remap AUTO_CLEAN)
endif ()

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

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")
4 changes: 4 additions & 0 deletions ports/glslang/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
glslang provides CMake targets:

find_package(glslang CONFIG REQUIRED)
target_link_libraries(main PRIVATE glslang::OSDependent glslang::glslang glslang::MachineIndependent glslang::GenericCodeGen glslang::glslang-default-resource-limits glslang::OGLCompiler glslang::SPVRemapper glslang::SPIRV glslang::HLSL)
26 changes: 26 additions & 0 deletions ports/glslang/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "glslang",
"version-string": "main",
"description": "Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.",
"homepage": "https://github.com/KhronosGroup/glslang",
"license": "Apache-2.0 AND BSD-3-Clause AND MIT AND GPL-3.0-or-later",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"rtti": {
"description": "Build with dynamic typeinfo"
},
"tools": {
"description": "Build the glslangValidator and spirv-remap binaries",
"supports": "!ios"
}
}
}
21 changes: 21 additions & 0 deletions ports/spirv-headers/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO KhronosGroup/SPIRV-Headers
REF e867c06631767a2d96424cbec530f9ee5e78180f
SHA512 b7cdedac508995defc1142947300bf699a511b2f3df80e63acc5783829df82ae2b40f9ccb32c1eb5d56b42728a34d0112bbe78ad1474d28efec707db8c4d94d6
HEAD_REF master
)

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

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

vcpkg_fixup_pkgconfig()

# Handle copyright
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
17 changes: 17 additions & 0 deletions ports/spirv-headers/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "spirv-headers",
"version": "1.3.231.1",
"port-version": 1,
"description": "Machine-readable files for the SPIR-V Registry",
"homepage": "https://github.com/KhronosGroup/SPIRV-Headers",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
55 changes: 55 additions & 0 deletions ports/spirv-tools/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO KhronosGroup/SPIRV-Tools
REF 360d469b9eac54d6c6e20f609f9ec35e3a5380ad
SHA512 026ee8477347a67443e3610e7988f9ec39f92ee2246d03e71915b582e079c467ebce0b8a99b66f881e7196150ba646a9062bfde1b3d30ef8e35c331a014ea1af
)

vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
vcpkg_add_to_path("${PYTHON3_DIR}")

vcpkg_check_features(
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
INVERTED_FEATURES
tools SPIRV_SKIP_EXECUTABLES
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
"-DSPIRV-Headers_SOURCE_DIR=${CURRENT_INSTALLED_DIR}"
-DSPIRV_SKIP_TESTS=ON
-DSPIRV_TOOLS_BUILD_STATIC=ON
-DSPIRV_WERROR=OFF
OPTIONS_DEBUG
-DSPIRV_SKIP_EXECUTABLES=ON
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools PACKAGE_NAME spirv-tools DO_NOT_DELETE_PARENT_CONFIG_PATH)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools-link PACKAGE_NAME spirv-tools-link DO_NOT_DELETE_PARENT_CONFIG_PATH)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools-lint PACKAGE_NAME spirv-tools-lint DO_NOT_DELETE_PARENT_CONFIG_PATH)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools-opt PACKAGE_NAME spirv-tools-opt DO_NOT_DELETE_PARENT_CONFIG_PATH)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/SPIRV-Tools-reduce PACKAGE_NAME spirv-tools-reduce) # now delete
vcpkg_fixup_pkgconfig()

if("tools" IN_LIST FEATURES)
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
file(RENAME "${CURRENT_PACKAGES_DIR}/bin/spirv-lesspipe.sh" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/spirv-lesspipe.sh")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/spirv-lesspipe.sh")
set(tools spirv-as spirv-cfg spirv-dis spirv-link spirv-lint spirv-opt spirv-val)
if(NOT VCPKG_TARGET_IS_IOS)
list(APPEND tools spirv-reduce)
endif()
vcpkg_copy_tools(TOOL_NAMES ${tools} AUTO_CLEAN)
endif()

file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share"
)

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
22 changes: 22 additions & 0 deletions ports/spirv-tools/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
spirv-tools provides CMake targets:

find_package(SPIRV-Tools CONFIG REQUIRED)
# The static libary is always available.
# It offers full public symbol visibility.
target_link_libraries(main PRIVATE SPIRV-Tools-static)
# In triplets with dynamic library linkage, there is also a shared libary.
target_link_libraries(main PRIVATE SPIRV-Tools-shared)

# The following libraries are static and depend on SPIRV-Tools-static.

find_package(SPIRV-Tools-link CONFIG REQUIRED)
target_link_libraries(main PRIVATE SPIRV-Tools-link)

find_package(SPIRV-Tools-lint CONFIG REQUIRED)
target_link_libraries(main PRIVATE SPIRV-Tools-lint)

find_package(SPIRV-Tools-opt CONFIG REQUIRED)
target_link_libraries(main PRIVATE SPIRV-Tools-opt)

find_package(SPIRV-Tools-reduce CONFIG REQUIRED)
target_link_libraries(main PRIVATE SPIRV-Tools-reduce)
24 changes: 24 additions & 0 deletions ports/spirv-tools/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "spirv-tools",
"version": "2022.4",
"port-version": 1,
"description": "API and commands for processing SPIR-V modules",
"homepage": "https://github.com/KhronosGroup/SPIRV-Tools",
"license": "Apache-2.0",
"dependencies": [
"spirv-headers",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"tools": {
"description": "Build tools."
}
}
}
14 changes: 14 additions & 0 deletions ports/vulkan-headers/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO KhronosGroup/Vulkan-Headers
REF "v${VERSION}"
SHA512 74c99232bb5f23656621cf4c138fdb9e081d723b80d361674e00cd8e707d658daf24fec751d00927a1e1c4d3d5bd334a43da79cb038abb673af3ee76bb2750fb
HEAD_REF main
)

set(VCPKG_BUILD_TYPE release) # header-only port

vcpkg_cmake_configure(SOURCE_PATH "${SOURCE_PATH}")
vcpkg_cmake_install()
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
4 changes: 4 additions & 0 deletions ports/vulkan-headers/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Vulkan-Headers provides official find_package support:

find_package(VulkanHeaders CONFIG)
target_link_libraries(main PRIVATE Vulkan::Headers)
18 changes: 18 additions & 0 deletions ports/vulkan-headers/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "vulkan-headers",
"version": "1.3.269",
"description": "Vulkan header files and API registry",
"homepage": "https://github.com/KhronosGroup/Vulkan-Headers",
"license": "Apache-2.0 OR MIT",
"supports": "!uwp & !xbox",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
12 changes: 12 additions & 0 deletions ports/vulkan-utility-libraries/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO KhronosGroup/Vulkan-Utility-Libraries
REF "v${VERSION}"
SHA512 b02a80b2f5ade91ede0364b2854d8f8d3dc6914e8ead3817014beee8e061a34b2ed7a897e536adfda3dee952526bb4925af175ab2c98f0c01145969440b1cf2f
HEAD_REF main
)

vcpkg_cmake_configure(SOURCE_PATH "${SOURCE_PATH}")
vcpkg_cmake_install()
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
4 changes: 4 additions & 0 deletions ports/vulkan-utility-libraries/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Vulkan-Headers provides official find_package support:

find_package(VulkanHeaders CONFIG)
target_link_libraries(main PRIVATE Vulkan::Headers)
18 changes: 18 additions & 0 deletions ports/vulkan-utility-libraries/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "vulkan-utility-libraries",
"version": "1.3.269",
"description": "VUL",
"homepage": "https://github.com/KhronosGroup/Vulkan-Utility-Libraries",
"license": "Apache-2.0 OR MIT",
"supports": "!uwp & !xbox",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
25 changes: 25 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "vulkan-validationlayers",
"version": "1.3.269",
"dependencies": [
"vulkan-headers",
"vulkan-utility-libraries",
"spirv-headers",
"spirv-tools",
"glslang",
"robin-hood-hashing"
],
"builtin-baseline": "3265c187c74914aa5569b75355badebfdbab7987",
"overrides": [
{
"name": "robin-hood-hashing",
"version": "3.11.5"
}
],
"vcpkg-configuration": {
"overlay-ports": [
"./ports"
]
}
}

0 comments on commit 65ae947

Please sign in to comment.