$NetBSD: patch-CMakeLists.txt,v 1.2 2024/12/01 13:49:47 gdt Exp $

Don't have a file called "version", to avoid conflict with C++20 <version>.

CMake will detect the MacOS 6-argument sendfile() support and configure
HAVE_SENDFILE, but the code itself doesn't support this interface.  So don't
probe for HAVE_SENDFILE if we HAVE_SENDFILE6_SUPPORT.

Just because librt doesn't exist does not mean that clock_gettime() doesn't
exist, so don't insist on librt being present.  Fixes the build on MacOS.

Let Pkgsrc be responsible for zm.conf into examples, rather than overwriting
the existing configuration file.

--- CMakeLists.txt.orig	2023-02-23 21:44:01.000000000 +0000
+++ CMakeLists.txt
@@ -4,7 +4,7 @@
 #
 cmake_minimum_required(VERSION 3.5.0)
 project(zoneminder)
-file(STRINGS "version" zoneminder_VERSION)
+file(STRINGS "version.txt" zoneminder_VERSION)
 # make API version a minor of ZM version
 set(zoneminder_API_VERSION "${zoneminder_VERSION}.1")
 
@@ -267,7 +267,9 @@ check_include_file("ucontext.h" HAVE_UCO
 check_include_file("sys/sendfile.h" HAVE_SYS_SENDFILE_H)
 check_include_file("sys/syscall.h" HAVE_SYS_SYSCALL_H)
 check_function_exists("syscall" HAVE_SYSCALL)
+if(NOT HAVE_SENDFILE6_SUPPORT)
 check_function_exists("sendfile" HAVE_SENDFILE)
+endif(NOT HAVE_SENDFILE6_SUPPORT)
 check_function_exists("posix_memalign" HAVE_POSIX_MEMALIGN)
 check_type_size("siginfo_t" HAVE_SIGINFO_T)
 check_type_size("ucontext_t" HAVE_UCONTEXT_T)
@@ -278,7 +280,8 @@ if(UNIX)
   include(CheckLibraryExists)
   CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
   if(NOT HAVE_CLOCK_GETTIME)
-    message(FATAL_ERROR "clock_gettime not found")
+    # \todo Explain why just skipping this is ok.
+    #message(FATAL_ERROR "clock_gettime not found")
   else()
     list(APPEND ZM_BIN_LIBS "-lrt")
   endif()
@@ -863,8 +866,8 @@ else()
 endif()
 
 # Install zm.conf
-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zm.conf" DESTINATION "${ZM_CONFIG_DIR}")
-install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/conf.d/" DESTINATION "${ZM_CONFIG_SUBDIR}" PATTERN "*.in" EXCLUDE)
+#install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zm.conf" DESTINATION "${ZM_CONFIG_DIR}")
+#install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/conf.d/" DESTINATION "${ZM_CONFIG_SUBDIR}" PATTERN "*.in" EXCLUDE)
 
 # Uninstall target
 configure_file(
