Skip to content

Commit

Permalink
Add vkd3d to deps
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr committed Oct 28, 2024
1 parent bb8c737 commit 02b4865
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 13 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ jobs:
version: 3-head
sdl-test: true
shell: ${{ matrix.platform.shell }}
- name: Install Linux requirements
if: ${{ runner.os == 'Linux' }}
run: |
# patchelf is needed to fix the runpath of libSDL3.so.0
wget https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-x86_64.tar.gz
tar xf patchelf-0.18.0-x86_64.tar.gz ./bin/patchelf
echo "$PWD/bin" >>$GITHUB_PATH
# libxrandr-dev is needed by vulkan-loader
sudo apt-get update -y
sudo apt-get install -y patchelf libxrandr-dev
- name: Install macOS requirements
if: ${{ runner.os == 'macOS' }}
run: |
# bison is needed by vkd3d
brew install bison
echo "/opt/homebrew/opt/bison/bin" >>$GITHUB_PATH
- name: Configure (CMake)
run: |
Expand Down
75 changes: 62 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -228,22 +228,22 @@ set(DXC_WINDOWS_X86_X64_ARM64_HASH "SHA256=e2627f004f0f9424d8c71ea1314d04f38c5a5

if(ENABLE_INSTALL_DEPS)
set(chmod_0755 OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
if(APPLE)
set(rpath_origin "@executable_path")
else()
set(rpath_origin "\$ORIGIN")
endif()

if(TARGET shadercross)
file(RELATIVE_PATH bin_to_lib "${CMAKE_INSTALL_FULL_BINDIR}" "${CMAKE_INSTALL_FULL_LIBDIR}")
if(APPLE)
set_property(TARGET shadercross PROPERTY INSTALL_RPATH "@executable_path/${bin_to_lib}")
else()
set_property(TARGET shadercross APPEND PROPERTY INSTALL_RPATH "\$ORIGIN/${bin_to_lib}")
endif()
set_property(TARGET shadercross PROPERTY INSTALL_RPATH "${rpath_origin}/${bin_to_lib}")
endif()

# Install SDL3
if(BUILD_CLI AND NOT BUILD_CLI_STATIC)
if(WIN32)
install(FILES $<TARGET_FILE:SDL3::SDL3-shared> DESTINATION "${CMAKE_INSTALL_BINDIR}" PERMISSIONS ${chmod_0755})
else()
install(FILES $<TARGET_FILE:SDL3::SDL3-shared> $<TARGET_SONAME_FILE:SDL3::SDL3-shared> DESTINATION "${CMAKE_INSTALL_LIBDIR}" PERMISSIONS ${chmod_0755})
install(IMPORTED_RUNTIME_ARTIFACTS SDL3::SDL3-shared RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
if(NOT WIN32)
install(CODE "find_program(PATCHELF_BIN NAMES \"patchelf\")\n if(PATCHELF_BIN)\n message(STATUS \"Adding \\\"\$ORIGIN\\\" to RPATH of $<TARGET_FILE_NAME:SDL3::SDL3-shared>\")\n execute_process(COMMAND \${PATCHELF_BIN} \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/$<TARGET_FILE_NAME:SDL3::SDL3-shared>\" --add-rpath \"\$ORIGIN\")\n endif()\n")
endif()
endif()

Expand Down Expand Up @@ -284,10 +284,10 @@ if(ENABLE_INSTALL_DEPS)

# Download, configure, build and install spirv-cross
ExternalProject_Add(spirv_cross
GIT_REPOSITORY "https://github.com/KhronosGroup/SPIRV-Cross.git"
GIT_TAG "main"
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release" "-DSPIRV_CROSS_SHARED=ON" "-DSPIRV_CROSS_STATIC=OFF" "-DSPIRV_CROSS_CLI=OFF" "-DSPIRV_CROSS_ENABLE_TESTS=OFF" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_BINDIR=bin" "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
BUILD_COMMAND "${CMAKE_COMMAND}" "--build" "<BINARY_DIR>" --config "Release"
GIT_REPOSITORY "https://github.com/KhronosGroup/SPIRV-Cross.git"
GIT_TAG "main"
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release" "-DSPIRV_CROSS_SHARED=ON" "-DSPIRV_CROSS_STATIC=OFF" "-DSPIRV_CROSS_CLI=OFF" "-DSPIRV_CROSS_ENABLE_TESTS=OFF" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_BINDIR=bin" "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
BUILD_COMMAND "${CMAKE_COMMAND}" "--build" "<BINARY_DIR>" --config "Release"
INSTALL_COMMAND "${CMAKE_COMMAND}" "--install" "<BINARY_DIR>" --config "Release"
)
ExternalProject_Get_property(spirv_cross INSTALL_DIR)
Expand All @@ -296,4 +296,53 @@ if(ENABLE_INSTALL_DEPS)
install(DIRECTORY "${INSTALL_DIR}/lib/" DESTINATION "${CMAKE_INSTALL_LIBDIR}" FILES_MATCHING PATTERN "*.so*" PERMISSIONS ${chmod_0755})
install(DIRECTORY "${INSTALL_DIR}/lib/" DESTINATION "${CMAKE_INSTALL_LIBDIR}" FILES_MATCHING PATTERN "*.dylib*" PERMISSIONS ${chmod_0755})
install(DIRECTORY "${INSTALL_DIR}/bin/" DESTINATION "${CMAKE_INSTALL_BINDIR}" FILES_MATCHING PATTERN "*.dll" PERMISSIONS ${chmod_0755})

if(NOT WIN32)
ExternalProject_Add(spirv_headers
GIT_REPOSITORY "https://github.com/KhronosGroup/SPIRV-Headers.git"
GIT_TAG "main"
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_BINDIR=bin" "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
BUILD_COMMAND "${CMAKE_COMMAND}" "--build" "<BINARY_DIR>" --config "Release"
INSTALL_COMMAND "${CMAKE_COMMAND}" "--install" "<BINARY_DIR>" --config "Release"
)
ExternalProject_Get_property(spirv_headers INSTALL_DIR)
set(spirv_headers_install_dir "${INSTALL_DIR}")

ExternalProject_Add(vulkan_headers
GIT_REPOSITORY "https://github.com/KhronosGroup/Vulkan-Headers"
GIT_TAG "main"
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_BINDIR=bin" "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
BUILD_COMMAND "${CMAKE_COMMAND}" "--build" "<BINARY_DIR>" --config "Release"
INSTALL_COMMAND "${CMAKE_COMMAND}" "--install" "<BINARY_DIR>" --config "Release"
)
ExternalProject_Get_property(vulkan_headers INSTALL_DIR)
set(vulkan_headers_install_dir "${INSTALL_DIR}")

ExternalProject_Add(vulkan_loader
DEPENDS spirv_headers vulkan_headers
GIT_REPOSITORY "https://github.com/KhronosGroup/Vulkan-Loader.git"
GIT_TAG "main"
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_BINDIR=bin" "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" "-DCMAKE_PREFIX_PATH=${vulkan_headers_install_dir}"
BUILD_COMMAND "${CMAKE_COMMAND}" "--build" "<BINARY_DIR>" --config "Release"
INSTALL_COMMAND "${CMAKE_COMMAND}" "--install" "<BINARY_DIR>" --config "Release"
)
ExternalProject_Get_property(vulkan_loader INSTALL_DIR)
set(vulkan_loader_install_dir "${INSTALL_DIR}")

find_package(BISON REQUIRED)
ExternalProject_Add(vkd3d
DEPENDS spirv_headers vulkan_headers vulkan_loader
URL "https://dl.winehq.org/vkd3d/source/vkd3d-1.13.tar.xz"
URL_HASH "SHA256=cf637873695fcc02fab308f68608f0bbb90481332a2ff0a9597c7c9fd97d363d"
DOWNLOAD_EXTRACT_TIMESTAMP "1"
CONFIGURE_COMMAND "sh" "<SOURCE_DIR>/configure" "--prefix=<INSTALL_DIR>" "--enable-tests=no" "--enable-demos=no" "--disable-doxygen-doc" "CFLAGS=-I${spirv_headers_install_dir}/include -I${vulkan_headers_install_dir}/include -I${vulkan_loader_install_dir}/include" "LDFLAGS=-L${vulkan_loader_install_dir}/lib" "BISON=${BISON_EXECUTABLE}"
BUILD_COMMAND "make"
INSTALL_COMMAND "make" "install"
)
ExternalProject_Get_property(vkd3d SOURCE_DIR)
ExternalProject_Get_property(vkd3d INSTALL_DIR)
install(DIRECTORY "${INSTALL_DIR}/lib/" DESTINATION "${CMAKE_INSTALL_LIBDIR}" FILES_MATCHING PATTERN "*.so*" PERMISSIONS ${chmod_0755})
install(DIRECTORY "${INSTALL_DIR}/lib/" DESTINATION "${CMAKE_INSTALL_LIBDIR}" FILES_MATCHING PATTERN "*.dylib*" PERMISSIONS ${chmod_0755})
install(FILES "${SOURCE_DIR}/COPYING" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/licenses/vkd3d")
endif()
endif()

0 comments on commit 02b4865

Please sign in to comment.