vcpkg/ports/shader-slang/portfile.cmake
2024-09-04 22:35:42 -07:00

131 lines
5.3 KiB
CMake

vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)
set(key NOTFOUND)
if(VCPKG_TARGET_IS_WINDOWS)
set(key "windows-${VCPKG_TARGET_ARCHITECTURE}")
elseif(VCPKG_TARGET_IS_OSX)
set(key "macosx-${VCPKG_TARGET_ARCHITECTURE}")
elseif(VCPKG_TARGET_IS_LINUX)
set(key "linux-${VCPKG_TARGET_ARCHITECTURE}")
endif()
set(ARCHIVE NOTFOUND)
# For convenient updates, use
# vcpkg install shader-slang --cmake-args=-DVCPKG_SHADER_SLANG_UPDATE=1
if(key STREQUAL "windows-x64" OR VCPKG_SHADER_SLANG_UPDATE)
vcpkg_download_distfile(
ARCHIVE
URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-windows-x86_64.zip"
FILENAME "slang-${VERSION}-windows-x86_64.zip"
SHA512 2eda55e14cdd701323cd1985c3789683153dc58451fe7a2aa54fbf6ec20ef61e18ca0b10a4a61fecc60ccecdedff4cbda8ef0682038d47fafb01777b2a719e0d
)
endif()
if(key STREQUAL "windows-arm64" OR VCPKG_SHADER_SLANG_UPDATE)
vcpkg_download_distfile(
ARCHIVE
URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-windows-aarch64.zip"
FILENAME "slang-${VERSION}-windows-aarch64.zip"
SHA512 b0e4c051c34e12f12c6990da2c304fd7a5d75a9a94ac5417e5ed8bb98dfc1348c03572a0350f58311f9a3a083c9041dfc3b41d1d7db430f8058a22f15472f11b
)
endif()
if(key STREQUAL "macosx-x64" OR VCPKG_SHADER_SLANG_UPDATE)
string(REPLACE "2024.1.33" "2024.1.32" VERSION "${VERSION}")
message(WARNING "${unavailable} is not available. Using ${VERSION} instead.")
vcpkg_download_distfile(
ARCHIVE
URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-macos-x86_64.zip"
FILENAME "slang-${VERSION}-macos-x86_64.zip"
SHA512 5761f44c0fb9c2da5b3f2457bda7b5f1a0f45cc5711f5c2c72df3a5743e6663996b6207834e0f6645ac99a655318b8ce96669b38ebc9f82daace8949010ff20b
)
set(VERSION "${unavailable_for_x64}")
endif()
if(key STREQUAL "macosx-arm64" OR VCPKG_SHADER_SLANG_UPDATE)
vcpkg_download_distfile(
ARCHIVE
URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-macos-aarch64.zip"
FILENAME "slang-${VERSION}-macos-aarch64.zip"
SHA512 8d0d4a5f97baf12c14e4ca66431a9538fce126922f8e1fca8e57e24bfaae8fbbea5212115c7645f0ce8b305a4740bf0c40201e2acf4c1ae3127960ea497035be
)
endif()
if(key STREQUAL "linux-x64" OR VCPKG_SHADER_SLANG_UPDATE)
vcpkg_download_distfile(
ARCHIVE
URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-linux-x86_64.zip"
FILENAME "slang-${VERSION}-linux-x86_64.zip"
SHA512 3b20f583a6643809098671c5972bb451a0617562ac231d3929dbf9025b1517952854869483166988f9a43cd5bb35edb017be427d9ce4d2cac99cc0a50be57979
)
endif()
if(key STREQUAL "linux-arm64" OR VCPKG_SHADER_SLANG_UPDATE)
vcpkg_download_distfile(
ARCHIVE
URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-linux-aarch64.zip"
FILENAME "slang-${VERSION}-linux-aarch64.zip"
SHA512 298c89aeb0d4ff739bcf7f98ef2abf612bde5727679c63c65d0172e8527b7b51f0fb7731d5d106f3b5a68b9c0078b7f77c2e87ee779283d143b21f02c30070cb
)
endif()
if(NOT ARCHIVE)
message(FATAL_ERROR "Unsupported platform. Please implement me!")
endif()
vcpkg_extract_source_archive(
BINDIST_PATH
ARCHIVE "${ARCHIVE}"
NO_REMOVE_ONE_LEVEL
)
if(VCPKG_SHADER_SLANG_UPDATE)
message(STATUS "All downloads are up-to-date.")
message(FATAL_ERROR "Stopping due to VCPKG_SHADER_SLANG_UPDATE being enabled.")
endif()
file(GLOB libs
"${BINDIST_PATH}/lib/*.lib"
"${BINDIST_PATH}/lib/*.dylib"
"${BINDIST_PATH}/lib/*.so"
)
file(INSTALL ${libs} DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(GLOB dyn_libs
"${BINDIST_PATH}/lib/*.dylib"
"${BINDIST_PATH}/lib/*.so"
)
if(VCPKG_TARGET_IS_WINDOWS)
file(GLOB dlls "${BINDIST_PATH}/bin/*.dll")
list(APPEND dyn_libs ${dlls})
file(INSTALL ${dlls} DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
endif()
if(NOT VCPKG_BUILD_TYPE)
file(INSTALL "${CURRENT_PACKAGES_DIR}/lib" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
if(VCPKG_TARGET_IS_WINDOWS)
file(INSTALL "${CURRENT_PACKAGES_DIR}/bin" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
endif()
# Must manually copy some tool dependencies since vcpkg can't copy them automagically for us
file(INSTALL ${dyn_libs} DESTINATION "${CURRENT_PACKAGES_DIR}/tools/shader-slang/")
vcpkg_copy_tools(TOOL_NAMES slangc slangd SEARCH_DIR "${BINDIST_PATH}/bin")
file(GLOB headers "${BINDIST_PATH}/include/*.h")
file(INSTALL ${headers} DESTINATION "${CURRENT_PACKAGES_DIR}/include")
vcpkg_install_copyright(
FILE_LIST "${BINDIST_PATH}/LICENSE"
COMMENT #[[ from README ]] [[
The Slang code itself is under the MIT license.
Builds of the core Slang tools depend on the following projects, either automatically or optionally, which may have their own licenses:
* [`glslang`](https://github.com/KhronosGroup/glslang) (BSD)
* [`lz4`](https://github.com/lz4/lz4) (BSD)
* [`miniz`](https://github.com/richgel999/miniz) (MIT)
* [`spirv-headers`](https://github.com/KhronosGroup/SPIRV-Headers) (Modified MIT)
* [`spirv-tools`](https://github.com/KhronosGroup/SPIRV-Tools) (Apache 2.0)
* [`ankerl::unordered_dense::{map, set}`](https://github.com/martinus/unordered_dense) (MIT)
Slang releases may include [slang-llvm](https://github.com/shader-slang/slang-llvm) which includes [LLVM](https://github.com/llvm/llvm-project) under the license:
* [`llvm`](https://llvm.org/docs/DeveloperPolicy.html#new-llvm-project-license-framework) (Apache 2.0 License with LLVM exceptions)
]])