@@ -491,56 +491,60 @@ else(STDLIBS_HAVE_GETSERVENT)
491
491
endif (STDLIBS_HAVE_GETSERVENT )
492
492
cmake_pop_check_state ()
493
493
494
- #
495
- # Require a proof of suitable snprintf(3), same as in Autoconf.
496
- #
497
- include (CheckCSourceRuns )
498
- check_c_source_runs ("
499
- #include <stdio.h>
500
- #include <string.h>
501
- #include <inttypes.h>
502
- #include <sys/types.h>
503
-
504
- int main()
505
- {
506
- char buf[100];
507
- uint64_t t = (uint64_t)1 << 32;
508
-
509
- snprintf(buf, sizeof(buf), \" %zu\" , sizeof(buf));
510
- if (strncmp(buf, \" 100\" , sizeof(buf)))
511
- return 1;
512
-
513
- snprintf(buf, sizeof(buf), \" %zd\" , -sizeof(buf));
514
- if (strncmp(buf, \" -100\" , sizeof(buf)))
515
- return 2;
516
-
517
- snprintf(buf, sizeof(buf), \" %\" PRId64, -t);
518
- if (strncmp(buf, \" -4294967296\" , sizeof(buf)))
519
- return 3;
520
-
521
- snprintf(buf, sizeof(buf), \" 0o%\" PRIo64, t);
522
- if (strncmp(buf, \" 0o40000000000\" , sizeof(buf)))
523
- return 4;
524
-
525
- snprintf(buf, sizeof(buf), \" 0x%\" PRIx64, t);
526
- if (strncmp(buf, \" 0x100000000\" , sizeof(buf)))
527
- return 5;
528
-
529
- snprintf(buf, sizeof(buf), \" %\" PRIu64, t);
530
- if (strncmp(buf, \" 4294967296\" , sizeof(buf)))
531
- return 6;
532
-
533
- return 0;
534
- }
535
-
536
- "
537
- SUITABLE_SNPRINTF
538
- )
539
- if (NOT SUITABLE_SNPRINTF )
540
- message (FATAL_ERROR
494
+ if (NOT CMAKE_CROSSCOMPILING )
495
+ #
496
+ # Require a proof of suitable snprintf(3), same as in Autoconf.
497
+ #
498
+ include (CheckCSourceRuns )
499
+ check_c_source_runs ("
500
+ #include <stdio.h>
501
+ #include <string.h>
502
+ #include <inttypes.h>
503
+ #include <sys/types.h>
504
+
505
+ int main()
506
+ {
507
+ char buf[100];
508
+ uint64_t t = (uint64_t)1 << 32;
509
+
510
+ snprintf(buf, sizeof(buf), \" %zu\" , sizeof(buf));
511
+ if (strncmp(buf, \" 100\" , sizeof(buf)))
512
+ return 1;
513
+
514
+ snprintf(buf, sizeof(buf), \" %zd\" , -sizeof(buf));
515
+ if (strncmp(buf, \" -100\" , sizeof(buf)))
516
+ return 2;
517
+
518
+ snprintf(buf, sizeof(buf), \" %\" PRId64, -t);
519
+ if (strncmp(buf, \" -4294967296\" , sizeof(buf)))
520
+ return 3;
521
+
522
+ snprintf(buf, sizeof(buf), \" 0o%\" PRIo64, t);
523
+ if (strncmp(buf, \" 0o40000000000\" , sizeof(buf)))
524
+ return 4;
525
+
526
+ snprintf(buf, sizeof(buf), \" 0x%\" PRIx64, t);
527
+ if (strncmp(buf, \" 0x100000000\" , sizeof(buf)))
528
+ return 5;
529
+
530
+ snprintf(buf, sizeof(buf), \" %\" PRIu64, t);
531
+ if (strncmp(buf, \" 4294967296\" , sizeof(buf)))
532
+ return 6;
533
+
534
+ return 0;
535
+ }
536
+
537
+ "
538
+ SUITABLE_SNPRINTF
539
+ )
540
+ if (NOT SUITABLE_SNPRINTF )
541
+ message (FATAL_ERROR
541
542
"The snprintf(3) implementation in this libc is not suitable,
542
543
tcpdump would not work correctly even if it managed to compile."
543
- )
544
+ )
545
+ endif ()
546
+ else ()
547
+ message (STATUS "Skipped SUITABLE_SNPRINTF because cross-compiling." )
544
548
endif ()
545
549
546
550
check_function_exists (getopt_long HAVE_GETOPT_LONG )
0 commit comments