From 0846d826e111e74ca532215b4661432178194f4c Mon Sep 17 00:00:00 2001
From: Dmitry Ivanov <ivadmi5@gmail.com>
Date: Fri, 21 Jul 2023 12:26:03 +0300
Subject: [PATCH] fix: Add extra byproducts to bundled ldap & sasl

This is needed to fix Ninja, which requires them to
build a dependency graph.

NO_DOC=picodata internal patch
NO_CHANGELOG=picodata internal patch
NO_TEST=picodata internal patch
---
 .gitlab-ci.yml        | 1 +
 cmake/BuildLDAP.cmake | 7 +++++++
 cmake/BuildSASL.cmake | 7 +++++++
 3 files changed, 15 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2e0d3e1e21..2eb8ff146b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -68,6 +68,7 @@ coverage:
       TEST_TIMEOUT: 420
       NO_OUTPUT_TIMEOUT: 440
     script:
+      - export PATH="$PATH:$PWD" # for GLAuth (CMake will download it)
       - make -f .test.mk test-coverage
 
 .pack:
diff --git a/cmake/BuildLDAP.cmake b/cmake/BuildLDAP.cmake
index e64ad6dbd8..28dd356879 100644
--- a/cmake/BuildLDAP.cmake
+++ b/cmake/BuildLDAP.cmake
@@ -45,6 +45,7 @@ macro(ldap_build)
 
     ExternalProject_Get_Property(bundled-ldap install_dir)
     set(LDAP_INSTALL_DIR ${install_dir})
+    unset(install_dir)
 
     # Unfortunately, we can't use find_library here,
     # since the package hasn't been built yet.
@@ -56,6 +57,9 @@ macro(ldap_build)
         ${LDAP_INSTALL_DIR}/lib/liblber.a
     )
 
+    ExternalProject_Add_Step(bundled-ldap byproducts
+        BYPRODUCTS ${LDAP_LIBRARIES})
+
     # On OS X we may also need to link libresolv.dylib.
     # However, note that newer OS X releases don't have that file;
     # instead, it's provided via a built-in dynamic linker cache.
@@ -69,4 +73,7 @@ macro(ldap_build)
             set(LDAP_LIBRARIES ${LDAP_LIBRARIES} ${RESOLV_LIBRARIES})
         endif()
     endif()
+
+    message(STATUS "Found LDAP includes: ${LDAP_INCLUDE_DIR}")
+    message(STATUS "Found LDAP libraries: ${LDAP_LIBRARIES}")
 endmacro()
diff --git a/cmake/BuildSASL.cmake b/cmake/BuildSASL.cmake
index 6154b165e1..f5fbb6d3f2 100644
--- a/cmake/BuildSASL.cmake
+++ b/cmake/BuildSASL.cmake
@@ -50,6 +50,7 @@ macro(sasl_build)
 
     ExternalProject_Get_Property(bundled-sasl install_dir)
     set(SASL_INSTALL_DIR ${install_dir})
+    unset(install_dir)
 
     # Unfortunately, we can't use find_library here,
     # since the package hasn't been built yet.
@@ -65,4 +66,10 @@ macro(sasl_build)
         ${SASL_INSTALL_DIR}/lib/sasl2/libplain.a
         ${SASL_INSTALL_DIR}/lib/sasl2/libscram.a
     )
+
+    ExternalProject_Add_Step(bundled-sasl byproducts
+        BYPRODUCTS ${SASL_LIBRARIES})
+
+    message(STATUS "Found SASL includes: ${SASL_INCLUDE_DIR}")
+    message(STATUS "Found SASL libraries: ${SASL_LIBRARIES}")
 endmacro()
-- 
GitLab