vcpkg/ports/shader-slang/portfile.cmake
Daniel Johansson bf6a6ce711
[slang] Adding a package for the Slang shading language (#24914)
* slang port - initial commit

* added x64-linux target and removed dependency on cmake

* [slang] adding some expected failing platforms

* formatted manifest file

* added license

* added expected failing win64-static platform

* added version

* sort alphabetically

* changing error message

* updated version

* [slang] adding "supports" field for vcpkg.json

* [slang] removing platform exclusion rules

* [slang] update version

* [slang] fixed deprecation warning

* [slang] update version database

* rename slang to shader-slang

* update version database

* Use builtin VERSION and dos2unix.

* remove unused empty folder policy

* set version

* update version

* Remove unnecessary set(VERSION

Co-authored-by: Billy O'Neal <bion@microsoft.com>
2022-10-31 13:48:20 -07:00

82 lines
4.1 KiB
CMake

vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)
if (VCPKG_TARGET_IS_WINDOWS)
set(SLANG_EXE_SUFFIX ".exe")
set(SLANG_LIB_PREFIX "")
set(SLANG_LIB_SUFFIX ".lib")
set(SLANG_DYNLIB_SUFFIX ".dll")
if (VCPKG_TARGET_ARCHITECTURE MATCHES "x64")
vcpkg_download_distfile(
ARCHIVE
URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-win64.zip"
FILENAME "slang-${VERSION}-win64.zip"
SHA512 b7fb926426ee4ccd9e38ce1cb1b54b3034eeefbd38dbfba56d1559f9ff286521b4029ef411ecc8190ba426def2e775c4b747fb3eb8491bf7118d167185f65bbc
)
set(SLANG_BIN_PATH "bin/windows-x64/release")
elseif (VCPKG_TARGET_ARCHITECTURE MATCHES "x86")
vcpkg_download_distfile(
ARCHIVE
URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-win32.zip"
FILENAME "slang-${VERSION}-win32.zip"
SHA512 a42639e500e63a8fb9e18074c5d04671f6a2d871db03d2e99b48ec0bb46f6a80a75a8bf6fc3a8eed2b72505311b665dcd55e99b5305baedcc2a0f212ca32b770
)
set(SLANG_BIN_PATH "bin/windows-x86/release")
else()
message(FATAL_ERROR "Unsupported platform. Please implement me!")
endif()
elseif(VCPKG_TARGET_IS_LINUX)
set(SLANG_EXE_SUFFIX "")
set(SLANG_LIB_PREFIX "lib")
set(SLANG_LIB_SUFFIX ".a")
set(SLANG_DYNLIB_SUFFIX ".so")
if (VCPKG_TARGET_ARCHITECTURE MATCHES "x64")
vcpkg_download_distfile(
ARCHIVE
URLS "https://github.com/shader-slang/slang/releases/download/v${VERSION}/slang-${VERSION}-linux-x86_64.tar.gz"
FILENAME "slang-${VERSION}-linux-x86_64.tar.gz"
SHA512 77806dc15131d9360cf80c7cc274637fe54cf0147482ba6ac1e49094c05d7ad91716fd6fdcc2fe2e02265913b0b8bc72137d1e8092f4341eff61758f88291c38
)
set(SLANG_BIN_PATH "bin/linux-x64/release")
else()
message(FATAL_ERROR "Unsupported platform. Please implement me!")
endif()
else()
message(FATAL_ERROR "Unsupported platform. Please implement me!")
endif()
vcpkg_extract_source_archive(
BINDIST_PATH
ARCHIVE "${ARCHIVE}"
NO_REMOVE_ONE_LEVEL
)
file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/${SLANG_LIB_PREFIX}slang${SLANG_DYNLIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/${SLANG_LIB_PREFIX}slang${SLANG_DYNLIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/${SLANG_LIB_PREFIX}slang-llvm${SLANG_DYNLIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/${SLANG_LIB_PREFIX}slang-llvm${SLANG_DYNLIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/${SLANG_LIB_PREFIX}slang-glslang${SLANG_DYNLIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/${SLANG_LIB_PREFIX}slang-glslang${SLANG_DYNLIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/slangc${SLANG_EXE_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
if (VCPKG_TARGET_IS_WINDOWS)
file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/${SLANG_LIB_PREFIX}slang${SLANG_LIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/${SLANG_LIB_PREFIX}slang${SLANG_LIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/gfx${SLANG_LIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/lib")
file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/gfx${SLANG_LIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib")
file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/gfx${SLANG_DYNLIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
file(INSTALL "${BINDIST_PATH}/${SLANG_BIN_PATH}/gfx${SLANG_DYNLIB_SUFFIX}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
file(GLOB HEADERS "${BINDIST_PATH}/*.h")
file(INSTALL ${HEADERS} DESTINATION "${CURRENT_PACKAGES_DIR}/include")
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO shader-slang/slang
REF v${VERSION}
SHA512 d02e166c694c46df8402f94b3f117d04494465ffa2cf636913ddced6f6a614547032c78408d87b79eb5d9de14b97cf8d17087a41c7d038c546b9a294e7a1f3d7
HEAD_REF master
)
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)