From 02b48659387c084cf28cc986c4b25336ac3ba231 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Mon, 28 Oct 2024 17:07:58 +0100 Subject: [PATCH] Add vkd3d to deps --- .github/workflows/main.yml | 17 +++++++++ CMakeLists.txt | 75 +++++++++++++++++++++++++++++++------- 2 files changed, 79 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 540acb0..df6a16e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e9ea3e..cee08f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 $ DESTINATION "${CMAKE_INSTALL_BINDIR}" PERMISSIONS ${chmod_0755}) - else() - install(FILES $ $ 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 $\")\n execute_process(COMMAND \${PATCHELF_BIN} \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/$\" --add-rpath \"\$ORIGIN\")\n endif()\n") endif() endif() @@ -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=" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" - BUILD_COMMAND "${CMAKE_COMMAND}" "--build" "" --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=" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" + BUILD_COMMAND "${CMAKE_COMMAND}" "--build" "" --config "Release" INSTALL_COMMAND "${CMAKE_COMMAND}" "--install" "" --config "Release" ) ExternalProject_Get_property(spirv_cross INSTALL_DIR) @@ -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=" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" + BUILD_COMMAND "${CMAKE_COMMAND}" "--build" "" --config "Release" + INSTALL_COMMAND "${CMAKE_COMMAND}" "--install" "" --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=" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" + BUILD_COMMAND "${CMAKE_COMMAND}" "--build" "" --config "Release" + INSTALL_COMMAND "${CMAKE_COMMAND}" "--install" "" --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=" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" "-DCMAKE_PREFIX_PATH=${vulkan_headers_install_dir}" + BUILD_COMMAND "${CMAKE_COMMAND}" "--build" "" --config "Release" + INSTALL_COMMAND "${CMAKE_COMMAND}" "--install" "" --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" "/configure" "--prefix=" "--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()