From cfa12e2abdfc5d447dbf507cd7a6005acf607807 Mon Sep 17 00:00:00 2001
From: Slávek Banko <slavek.banko@axis.cz>
Date: Sun, 16 Nov 2025 18:42:46 +0100
Subject: Allow ACL detection without pkgconfig file. Allow building with POSIX
 ACL without a separate ACL library.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This solves firstly building on older distributions where there is no
pkgconfig file, but there is an acl library supporting extended ACL,
and secondly it solves building on systems where POSIX ACLs are part
of the standard library and a separate acl library is not present.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
---
 ConfigureChecks.cmake | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index d50e00b..de74220 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -50,6 +50,21 @@ endif( )
 
 if( WITH_ACL )
   pkg_search_module( ACL libacl )
+  if( NOT ACL_FOUND )
+    find_file( HAVE_ACL_H "sys/acl.h" )
+    if( HAVE_ACL_H )
+      find_library( HAVE_ACL_LIB NAMES acl )
+      if( HAVE_ACL_LIB )
+        set( ACL_LIBRARIES "${HAVE_ACL_LIB}" CACHE INTERNAL "Extended ACL library" FORCE )
+      endif( )
+      tde_save_and_set( CMAKE_REQUIRED_LIBRARIES "${ACL_LIBRARIES}" )
+      check_symbol_exists( acl_free "${HAVE_ACL_H}" HAVE_ACL )
+      tde_restore( CMAKE_REQUIRED_LIBRARIES )
+      if( HAVE_ACL )
+        set( ACL_FOUND 1 CACHE INTERNAL "Posix ACL found" FORCE )
+      endif()
+    endif()
+  endif( )
   if( NOT ACL_FOUND )
     tde_message_fatal( "ACL support was requested, but not found on your system" )
   endif( )
-- 
cgit v1.2.3

