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 <jjelen@redhat.com>
This commit is contained in:
Mingyuan Li
2026-03-19 20:57:24 +08:00
committed by Jakub Jelen
parent 729a44e121
commit 9a2f23ee30
2 changed files with 8 additions and 0 deletions

View File

@@ -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)

View File

@@ -67,6 +67,12 @@
/* Define to 1 if you have the <ifaddrs.h> header file. */
#cmakedefine HAVE_IFADDRS_H 1
/* Define to 1 if you have the <getopt.h> 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 <openssl/aes.h> header file. */
#cmakedefine HAVE_OPENSSL_AES_H 1