From: Lakshmi-Surekha Date: Thu, 27 Nov 2025 13:19:22 +0000 (-0600) Subject: apps: use CMake check for getopt.h X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a7b34a299b5e8fe6e0e4047a14da36085966112e;p=thirdparty%2Fjson-c.git 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. --- 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