git: a7b9121226b5 - main - net/libyang2: Fix building with CMake 4

From: Olivier Cochard <olivier_at_FreeBSD.org>
Date: Fri, 18 Sep 2026 14:57:23 UTC
The branch main has been updated by olivier:

URL: https://cgit.FreeBSD.org/ports/commit/?id=a7b9121226b58b21e52ba01e5981ea84d33d6fcb

commit a7b9121226b58b21e52ba01e5981ea84d33d6fcb
Author:     Olivier Cochard <olivier@FreeBSD.org>
AuthorDate: 2026-09-18 14:49:33 +0000
Commit:     Olivier Cochard <olivier@FreeBSD.org>
CommitDate: 2026-09-18 14:54:38 +0000

    net/libyang2: Fix building with CMake 4
    
    PR:             298622
    Reported by:    arrowd
---
 net/libyang2/Makefile                   |  2 +-
 net/libyang2/files/patch-CMakeLists.txt | 11 ++++++-
 net/pimd/files/patch-src_main.c         | 56 +++++++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/net/libyang2/Makefile b/net/libyang2/Makefile
index 252d2da1f7b4..cd4184c804af 100644
--- a/net/libyang2/Makefile
+++ b/net/libyang2/Makefile
@@ -14,7 +14,7 @@ LICENSE_FILE=	${WRKSRC}/LICENSE
 LIB_DEPENDS=	libpcre2-8.so:devel/pcre2
 TEST_DEPENDS=	cmocka>0:sysutils/cmocka
 
-USES=	cmake compiler:c++11-lang pkgconfig
+USES=	cmake compiler:c++11-lang localbase:ldflags pkgconfig
 USE_LDCONFIG=	yes
 
 USE_GITHUB=	yes
diff --git a/net/libyang2/files/patch-CMakeLists.txt b/net/libyang2/files/patch-CMakeLists.txt
index 727e627c9a7e..23f118c0688c 100644
--- a/net/libyang2/files/patch-CMakeLists.txt
+++ b/net/libyang2/files/patch-CMakeLists.txt
@@ -1,5 +1,14 @@
---- CMakeLists.txt.orig	2022-05-06 06:57:14 UTC
+--- CMakeLists.txt.orig	2024-01-11 08:52:00 UTC
 +++ CMakeLists.txt
+@@ -1,7 +1,7 @@ else()
+ if(WIN32)
+     cmake_minimum_required(VERSION 3.22.0)
+ else()
+-    cmake_minimum_required(VERSION 2.8.12)
++    cmake_minimum_required(VERSION 2.8.12...3.28.1)
+ endif()
+ 
+ # force out-of-source build
 @@ -31,7 +31,7 @@ if ("${BUILD_TYPE_UPPER}" STREQUAL "RELEASE")
  string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_UPPER)
  if ("${BUILD_TYPE_UPPER}" STREQUAL "RELEASE")
diff --git a/net/pimd/files/patch-src_main.c b/net/pimd/files/patch-src_main.c
new file mode 100644
index 000000000000..df9ab9d89d0d
--- /dev/null
+++ b/net/pimd/files/patch-src_main.c
@@ -0,0 +1,56 @@
+--- src/main.c.orig	2026-09-18 05:38:16 UTC
++++ src/main.c
+@@ -362,9 +362,31 @@ int main(int argc, char *argv[])
+     }
+ 
+     if (!foreground) {
+-	if (fork())
++	pid_t pid;
++
++	pid = fork();
++	if (pid == -1)
++	    err(1, "Failed forking to the background");
++	if (pid)
+ 	    exit(0);
+ 
++	/*
++	 * Leave the session, the controlling terminal and the process
++	 * group of whoever started us, before the standard descriptors
++	 * go to /dev/null, so that a failure can still be reported.
++	 *
++	 * setsid() is the portable primitive for this.  The TIOCNOTTY
++	 * ioctl that used to be preferred here cannot do it: the kernel
++	 * refuses it to anyone but a session leader, which the child of
++	 * a fork() never is, and pimd threw the error away.  A daemon
++	 * started from an rc script on a console was left in the
++	 * terminal's foreground process group, where an INTR character
++	 * typed on that console killed it.  setpgrp(), taken on Linux,
++	 * left the session and the terminal attached for their part.
++	 */
++	if (setsid() == -1)
++	    perror("setsid");
++
+ 	close(STDIN_FILENO);
+ 	close(STDOUT_FILENO);
+ 	close(STDERR_FILENO);
+@@ -376,20 +398,6 @@ int main(int argc, char *argv[])
+ 	    dup2(fd, STDERR_FILENO);
+ 	    close(fd);
+ 	}
+-#if defined(SYSV) || defined(__linux__)
+-	setpgrp();
+-#else
+-#ifdef TIOCNOTTY
+-	fd = open("/dev/tty", 2);
+-	if (fd >= 0) {
+-	    (void)ioctl(fd, TIOCNOTTY, NULL);
+-	    close(fd);
+-	}
+-#else
+-	if (setsid() < 0)
+-	    perror("setsid");
+-#endif
+-#endif
+     }
+ 
+     /*