Skip to content

Commit ebd9838

Browse files
feat(packaging/linux): enable cuda support for homebrew
1 parent c313851 commit ebd9838

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

packaging/sunshine.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
require "language/node"
22

33
class Sunshine < Formula
4+
CUDA_VERSION = "13.1".freeze
5+
CUDA_FORMULA = "cuda@#{CUDA_VERSION}".freeze
46
GCC_VERSION = "14".freeze
57
GCC_FORMULA = "gcc@#{GCC_VERSION}".freeze
68
IS_UPSTREAM_REPO = ENV.fetch("GITHUB_REPOSITORY", "") == "LizardByte/Sunshine"
@@ -56,6 +58,7 @@ class Sunshine < Formula
5658

5759
on_linux do
5860
depends_on GCC_FORMULA => [:build, :test]
61+
depends_on "lizardbyte/homebrew/#{CUDA_FORMULA}" => [:build, :recommended]
5962
depends_on "at-spi2-core"
6063
depends_on "avahi"
6164
depends_on "ayatana-ido"
@@ -163,7 +166,21 @@ def install
163166
ohai "Linking against ICU libraries at: #{icu4c_lib_path}"
164167
end
165168

166-
args << "-DCUDA_FAIL_ON_MISSING=OFF" if OS.linux?
169+
if OS.linux?
170+
if build.with?(CUDA_FORMULA)
171+
cuda_path = Formula["lizardbyte/homebrew/#{CUDA_FORMULA}"]
172+
nvcc_path = "#{cuda_path.opt_bin}/nvcc"
173+
gcc_path = Formula[GCC_FORMULA]
174+
175+
args << "-DSUNSHINE_ENABLE_CUDA=ON"
176+
args << "-DCMAKE_CUDA_COMPILER:PATH=#{nvcc_path}"
177+
args << "-DCMAKE_CUDA_HOST_COMPILER=#{gcc_path.opt_bin}/gcc-#{GCC_VERSION}"
178+
ohai "CUDA enabled with nvcc at: #{nvcc_path}"
179+
else
180+
args << "-DSUNSHINE_ENABLE_CUDA=OFF"
181+
ohai "CUDA disabled"
182+
end
183+
end
167184

168185
system "cmake", "-S", ".", "-B", "build", "-G", "Unix Makefiles",
169186
*std_cmake_args,

0 commit comments

Comments
 (0)