]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
apps: use CMake check for getopt.h 904/head
authorLakshmi-Surekha <Lakshmi.Kovvuri@ibm.com>
Thu, 27 Nov 2025 13:19:22 +0000 (07:19 -0600)
committerLakshmi-Surekha <Lakshmi.Kovvuri@ibm.com>
Sat, 29 Nov 2025 07:32:10 +0000 (01:32 -0600)
Add CMake detection for getopt.h and update json_parse.c to include it
only when HAVE_GETOPT_H is defined. Fixes AIX build failure.

apps/CMakeLists.txt
apps/json_parse.c

index 87bb4c9d461d59f0f4364edb28eaf450028882f8..52a039bea082f1c2324d93edcb93697726bba799 100644 (file)
@@ -94,6 +94,9 @@ endif() # end "standalone mode" block
 
 # ---------------------------------
 
+# Check whether getopt.h exists
+check_include_file(getopt.h HAVE_GETOPT_H)
+
 check_include_file(sys/resource.h   HAVE_SYS_RESOURCE_H) # for getrusage
 if (HAVE_SYS_RESOURCE_H)
     check_symbol_exists(getrusage   "sys/resource.h" HAVE_GETRUSAGE)
index c6c7728330e90946e912767acbc559d5a84ca121..3f8ef00339216c0ff4b806f362a5acec1afdc72b 100644 (file)
@@ -1,7 +1,9 @@
 #include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
+#ifdef HAVE_GETOPT_H 
 #include <getopt.h>
+#endif
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>