]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
CMake: Don't check for optreset if using replacement getopt_long
authorLasse Collin <lasse.collin@tukaani.org>
Sat, 12 Apr 2025 12:31:01 +0000 (15:31 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Thu, 17 Apr 2025 15:36:54 +0000 (18:36 +0300)
If <getopt.h> had optreset but not getopt_long, xz used optreset while
the replacement getopt_long doesn't support optreset. I'm not aware of
any relevant system where bug is possible. Autotools build didn't have
this bug.

Fixes: af66cd585902 ("CMake: Add support for replacement getopt_long (lib/getopt*).")
CMakeLists.txt

index 32506cdd5611899d5cbd01870057935fbee7734d..a4a379565490a3d237ccccc490d79ee8d2e62c66 100644 (file)
@@ -2171,8 +2171,10 @@ this many MiB of RAM if xz cannot determine the amount at runtime")
     tuklib_progname(xz)
     tuklib_mbstr(xz)
 
-    check_symbol_exists(optreset getopt.h HAVE_OPTRESET)
-    tuklib_add_definition_if(xz HAVE_OPTRESET)
+    if(HAVE_GETOPT_LONG)
+        check_symbol_exists(optreset getopt.h HAVE_OPTRESET)
+        tuklib_add_definition_if(xz HAVE_OPTRESET)
+    endif()
 
     check_symbol_exists(posix_fadvise fcntl.h HAVE_POSIX_FADVISE)
     tuklib_add_definition_if(xz HAVE_POSIX_FADVISE)