From 9a2f23ee30ca22278f6919eee6c7e983ab7a7c48 Mon Sep 17 00:00:00 2001 From: Mingyuan Li <2560359315@qq.com> Date: Thu, 19 Mar 2026 20:57:24 +0800 Subject: [PATCH] cmake: Add detection for getopt and getopt.h Add CMake checks for the getopt function and getopt.h header to prepare for a bundled getopt fallback on platforms that lack it (e.g. MSVC). Signed-off-by: Mingyuan Li <2560359315@qq.com> Reviewed-by: Jakub Jelen --- ConfigureChecks.cmake | 2 ++ config.h.cmake | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 4e32ea53..46dd90f7 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -65,6 +65,8 @@ check_include_file(byteswap.h HAVE_BYTESWAP_H) check_include_file(glob.h HAVE_GLOB_H) check_include_file(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H) check_include_file(ifaddrs.h HAVE_IFADDRS_H) +check_include_file(getopt.h HAVE_GETOPT_H) +check_function_exists(getopt HAVE_GETOPT) if (WIN32) check_include_file(io.h HAVE_IO_H) diff --git a/config.h.cmake b/config.h.cmake index 14e1031c..42870016 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -67,6 +67,12 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_IFADDRS_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_GETOPT_H 1 + +/* Define to 1 if you have the `getopt' function. */ +#cmakedefine HAVE_GETOPT 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_OPENSSL_AES_H 1