From a7b34a299b5e8fe6e0e4047a14da36085966112e Mon Sep 17 00:00:00 2001 From: Lakshmi-Surekha Date: Thu, 27 Nov 2025 07:19:22 -0600 Subject: [PATCH] apps: use CMake check for getopt.h 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 | 3 +++ apps/json_parse.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 87bb4c9..52a039b 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -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) diff --git a/apps/json_parse.c b/apps/json_parse.c index c6c7728..3f8ef00 100644 --- a/apps/json_parse.c +++ b/apps/json_parse.c @@ -1,7 +1,9 @@ #include #include #include +#ifdef HAVE_GETOPT_H #include +#endif #include #include #include -- 2.47.3