summaryrefslogtreecommitdiff
path: root/net-misc/sunshine/files/sunshine-cross-cbs.patch
blob: e6173597e47646489e2e20cd6973ec3711fa4dd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
From 40654399bd090dda20750b184eb6b15bc615a5dc Mon Sep 17 00:00:00 2001
From: James Le Cuirot <chewi@gentoo.org>
Date: Sun, 25 Feb 2024 16:24:25 +0000
Subject: [PATCH] Fix cross-compiling and don't treat x86 as the default case

If you set arch-specific CFLAGS, then ffmpeg's configure script may
fail when it tries to use these flags against the build host's compiler.

Also use CMAKE_SYSTEM_PROCESSOR to set up cross-compiling without
relying on any custom variables. ffmpeg normalises its --arch option and
will accept just about any string that you'll likely throw at it.

diff --git a/cmake/ffmpeg_cbs.cmake b/cmake/ffmpeg_cbs.cmake
index 573bec0..4a75e1a 100644
--- a/cmake/ffmpeg_cbs.cmake
+++ b/cmake/ffmpeg_cbs.cmake
@@ -30,23 +30,30 @@ if (WIN32)
     set(LEADING_SH_COMMAND sh)
 endif ()
 
-if (CROSS_COMPILE_ARM)
-    set(FFMPEG_EXTRA_CONFIGURE
-            --arch=aarch64
-            --enable-cross-compile)
+string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} arch)
+
+if (${arch} STREQUAL "aarch64" OR ${arch} STREQUAL "arm64")
     set(CBS_ARCH_PATH arm)
-elseif (CROSS_COMPILE_PPC)
-    set(FFMPEG_EXTRA_CONFIGURE
-            --arch=powerpc64le
-            --enable-cross-compile)
+elseif (${arch} STREQUAL "ppc64le")
     set(CBS_ARCH_PATH ppc)
-else ()
+elseif (${arch} STREQUAL "amd64" OR ${arch} STREQUAL "x86_64")
     set(CBS_ARCH_PATH x86)
+else ()
+    message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR})
+endif ()
+
+if (CMAKE_CROSSCOMPILING)
+    set(FFMPEG_EXTRA_CONFIGURE --arch=${arch} --enable-cross-compile)
 endif ()
 
 # The generated config.h needs to have `CONFIG_CBS_` flags enabled (from `--enable-bsfs`)
 execute_process(
         COMMAND ${LEADING_SH_COMMAND} ./configure
+            --cc=${CMAKE_C_COMPILER}
+            --cxx=${CMAKE_CXX_COMPILER}
+            --ar=${CMAKE_AR}
+            --ranlib=${CMAKE_RANLIB}
+            --optflags=${CMAKE_C_FLAGS}
             --disable-all
             --disable-autodetect
             --disable-iconv
-- 
2.43.2