---
 cmake/modules/FindACL.cmake | 65 ++++++++++++++++++++++++-------------
 config-acl.h.cmake          | 12 ++++---
 2 files changed, 51 insertions(+), 26 deletions(-)

diff --git a/cmake/modules/FindACL.cmake b/cmake/modules/FindACL.cmake
index 7b198340..8e8f85b7 100644
--- a/cmake/modules/FindACL.cmake
+++ b/cmake/modules/FindACL.cmake
@@ -27,33 +27,60 @@ find_library(ACL_LIBRARIES
 if(ACL_INCLUDES AND ACL_LIBRARIES)
     include(CMakePushCheckState)
     include(CheckSymbolExists)
+    include(CheckCXXSourceCompiles)
     cmake_reset_check_state()
     set(CMAKE_REQUIRED_INCLUDES ${ACL_INCLUDES})
     set(CMAKE_REQUIRED_LIBRARIES ${ACL_LIBRARIES})
-    # two implementations are checked for, both are non-portable stuff
-    check_symbol_exists("acl_from_mode" "acl/libacl.h" HAVE_LIBACL_FROM_MODE)
-    check_symbol_exists("acl_from_mode_np" "sys/acl.h" HAVE_NP_FROM_MODE)
-    check_symbol_exists("acl_cmp" "acl/libacl.h" HAVE_LIBACL_CMP)
-    check_symbol_exists("acl_cmp_np" "sys/acl.h" HAVE_NP_CMP)
-    check_symbol_exists("acl_equiv_mode" "acl/libacl.h" HAVE_LIBACL_EQUIV_MODE)
-    check_symbol_exists("acl_equiv_mode_np" "sys/acl.h" HAVE_NP_EQUIV_MODE)
-    check_symbol_exists("acl_get_perm" "acl/libacl.h" HAVE_LIBACL_GET_PERM)
-    check_symbol_exists("acl_get_perm_np" "sys/acl.h" HAVE_NP_GET_PERM)
-    check_symbol_exists("acl_extended_file" "acl/libacl.h" HAVE_LIBACL_EXTENDED_FILE)
-    check_symbol_exists("acl_extended_file_np" "sys/acl.h" HAVE_NP_EXTENDED_FILE)
-    cmake_reset_check_state()

-    if(NOT HAVE_LIBACL_FROM_MODE AND NOT HAVE_NP_FROM_MODE)
-        set(ACL_FOUND FALSE)
-    elseif(NOT HAVE_LIBACL_CMP AND NOT HAVE_NP_CMP)
-        set(ACL_FOUND FALSE)
-    elseif(NOT HAVE_LIBACL_EQUIV_MODE AND NOT HAVE_NP_EQUIV_MODE)
-        set(ACL_FOUND FALSE)
-    elseif(NOT HAVE_LIBACL_GET_PERM AND NOT HAVE_NP_GET_PERM)
-        set(ACL_FOUND FALSE)
-    elseif(NOT HAVE_LIBACL_EXTENDED_FILE AND NOT HAVE_NP_EXTENDED_FILE)
-        set(ACL_FOUND FALSE)
+    # First check if this is a POSIX.1e ACL implementation by verifying required constants
+    # macOS has sys/acl.h but uses NFSv4 ACLs, not POSIX.1e, so it lacks these
+    check_cxx_source_compiles("
+        #include <sys/types.h>
+        #include <sys/acl.h>
+        int main() {
+            acl_tag_t tags[] = { ACL_USER_OBJ, ACL_GROUP_OBJ, ACL_OTHER, ACL_USER, ACL_GROUP, ACL_MASK };
+            acl_perm_t perms[] = { ACL_READ, ACL_WRITE, ACL_EXECUTE };
+            (void)tags; (void)perms;
+            return 0;
+        }
+    " HAVE_POSIX_ACL_CONSTANTS)
+
+    if(HAVE_POSIX_ACL_CONSTANTS)
+        # two implementations are checked for, both are non-portable stuff
+        check_symbol_exists("acl_from_mode" "acl/libacl.h" HAVE_LIBACL_FROM_MODE)
+        check_symbol_exists("acl_from_mode_np" "sys/acl.h" HAVE_NP_FROM_MODE)
+        check_symbol_exists("acl_cmp" "acl/libacl.h" HAVE_LIBACL_CMP)
+        check_symbol_exists("acl_cmp_np" "sys/acl.h" HAVE_NP_CMP)
+        check_symbol_exists("acl_equiv_mode" "acl/libacl.h" HAVE_LIBACL_EQUIV_MODE)
+        check_symbol_exists("acl_equiv_mode_np" "sys/acl.h" HAVE_NP_EQUIV_MODE)
+        check_symbol_exists("acl_get_perm" "acl/libacl.h" HAVE_LIBACL_GET_PERM)
+        check_symbol_exists("acl_get_perm_np" "sys/acl.h" HAVE_NP_GET_PERM)
+        check_symbol_exists("acl_extended_file" "acl/libacl.h" HAVE_LIBACL_EXTENDED_FILE)
+        check_symbol_exists("acl_extended_file_np" "sys/acl.h" HAVE_NP_EXTENDED_FILE)
+
+        if(NOT HAVE_LIBACL_FROM_MODE AND NOT HAVE_NP_FROM_MODE)
+            unset(ACL_INCLUDES)
+            unset(ACL_LIBRARIES)
+        elseif(NOT HAVE_LIBACL_CMP AND NOT HAVE_NP_CMP)
+            unset(ACL_INCLUDES)
+            unset(ACL_LIBRARIES)
+        elseif(NOT HAVE_LIBACL_EQUIV_MODE AND NOT HAVE_NP_EQUIV_MODE)
+            unset(ACL_INCLUDES)
+            unset(ACL_LIBRARIES)
+        elseif(NOT HAVE_LIBACL_GET_PERM AND NOT HAVE_NP_GET_PERM)
+            unset(ACL_INCLUDES)
+            unset(ACL_LIBRARIES)
+        elseif(NOT HAVE_LIBACL_EXTENDED_FILE AND NOT HAVE_NP_EXTENDED_FILE)
+            unset(ACL_INCLUDES)
+            unset(ACL_LIBRARIES)
+        endif()
+    else()
+        # Not a POSIX.1e ACL implementation (e.g., macOS with NFSv4 ACLs)
+        unset(ACL_INCLUDES)
+        unset(ACL_LIBRARIES)
     endif()
+
+    cmake_reset_check_state()
 endif()

 include(FindPackageHandleStandardArgs)
diff --git a/config-acl.h.cmake b/config-acl.h.cmake
index dd280f4a..349c6fc8 100644
--- a/config-acl.h.cmake
+++ b/config-acl.h.cmake
@@ -1,6 +1,3 @@
-/* Defined if system has POSIX ACL support. */
-#cmakedefine HAVE_POSIX_ACL 1
-
 /* Defined if acl/libacl.h symbols exist */
 #cmakedefine HAVE_LIBACL_FROM_MODE 1
 #cmakedefine HAVE_LIBACL_CMP 1
@@ -16,18 +13,21 @@
 #cmakedefine HAVE_NP_EXTENDED_FILE 1

 #if defined(HAVE_LIBACL_FROM_MODE) && defined(HAVE_LIBACL_CMP) && defined(HAVE_LIBACL_EQUIV_MODE) && defined(HAVE_LIBACL_GET_PERM) && defined(HAVE_LIBACL_EXTENDED_FILE)
+   /* libacl implementation (Linux) */
 #  include <acl/libacl.h>
 #  define KACL_FROM_MODE acl_from_mode
 #  define KACL_CMP acl_cmp
 #  define KACL_EQUIV_MODE acl_equiv_mode
 #  define KACL_GET_PERM acl_get_perm
 #  define KACL_EXTENDED_FILE acl_extended_file
+#  define HAVE_POSIX_ACL 1
 #elif defined(HAVE_NP_FROM_MODE) && defined(HAVE_NP_CMP) && defined(HAVE_NP_EQUIV_MODE) && defined(HAVE_NP_GET_PERM) && defined(HAVE_NP_EXTENDED_FILE)
+   /* *_np implementation (FreeBSD, etc.) */
 #  define KACL_FROM_MODE acl_from_mode_np
 #  define KACL_CMP acl_cmp_np
 #  define KACL_EQUIV_MODE acl_equiv_mode_np
 #  define KACL_GET_PERM acl_get_perm_np
 #  define KACL_EXTENDED_FILE acl_extended_file_np
-#elif defined(HAVE_POSIX_ACL)
-#  error "Neither supported implementation is available"
+#  define HAVE_POSIX_ACL 1
 #endif
+/* If neither implementation is available, HAVE_POSIX_ACL remains undefined */
