summaryrefslogtreecommitdiff
path: root/meta-openembedded/meta-networking/recipes-support/wireshark/files/0001-CMake-Fix-a-try_run-test-when-cross-compiling.patch
blob: 0d51ce1b8f94730b9e37fe170232733605f7934b (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
60
61
62
63
64
65
66
From b4f29807225cf3744c2f4f971902fbdd7486fc19 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= <j@v6e.pt>
Date: Fri, 26 May 2023 13:29:23 +0100
Subject: [PATCH] CMake: Fix a try_run() test when cross-compiling

Upstream-Status: Backport
Signed-off-by: Armin Kuster <akuster808@gmail.com>

---
 ConfigureChecks.cmake | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index dd8268e077..d8bca54115 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -122,26 +122,30 @@ check_type_size("ssize_t"       SSIZE_T)
 # Check if the libc vsnprintf() conforms to C99. If this fails we may
 # need to fall-back on GLib I/O.
 #
-check_c_source_runs("
-	#include <stdio.h>
-	int main(void)
-	{
-		/* Check that snprintf() and vsnprintf() don't return
-		 * -1 if the buffer is too small. C99 says this value
-		 * is the length that would be written not including
-		 * the nul byte. */
-		char buf[3];
-		return snprintf(buf, sizeof(buf), \"%s\", \"ABCDEF\") > 0 ? 0 : 1;
-	}"
-	HAVE_C99_VSNPRINTF
-)
-if (NOT HAVE_C99_VSNPRINTF)
-	message(FATAL_ERROR
+# If cross-compiling we can't check so just assume this requirement is met.
+#
+if(NOT CMAKE_CROSSCOMPILING)
+	check_c_source_runs("
+		#include <stdio.h>
+		int main(void)
+		{
+			/* Check that snprintf() and vsnprintf() don't return
+			* -1 if the buffer is too small. C99 says this value
+			* is the length that would be written not including
+			* the nul byte. */
+			char buf[3];
+			return snprintf(buf, sizeof(buf), \"%s\", \"ABCDEF\") > 0 ? 0 : 1;
+		}"
+		HAVE_C99_VSNPRINTF
+	)
+	if (NOT HAVE_C99_VSNPRINTF)
+		message(FATAL_ERROR
 "Building Wireshark requires a C99 compliant vsnprintf() and this \
 target does not meet that requirement. Compiling for ${CMAKE_SYSTEM} \
 using ${CMAKE_C_COMPILER_ID}. Please report this issue to the Wireshark \
 developers at wireshark-dev@wireshark.org."
-	)
+		)
+	endif()
 endif()
 
 #
-- 
2.25.1