$NetBSD$

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	2019-02-23 04:38:47.000000000 +1300
+++ CMakeLists.txt	2022-01-19 22:51:36.000000000 +1300
@@ -4,7 +4,7 @@
 #
 cmake_minimum_required (VERSION 2.8.7)
 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")
 
@@ -226,7 +226,9 @@
 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)
@@ -237,7 +239,7 @@
     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")
+        #message(FATAL_ERROR "clock_gettime not found")
     else(NOT HAVE_CLOCK_GETTIME)
         list(APPEND ZM_BIN_LIBS "-lrt")
     endif(NOT HAVE_CLOCK_GETTIME)
@@ -733,7 +735,7 @@
 endif(zmconfgen_result EQUAL 0)
 
 # Install zm.conf
-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zm.conf" DESTINATION "${ZM_CONFIG_DIR}")
+#install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zm.conf" DESTINATION "${ZM_CONFIG_DIR}")
 
 # Uninstall target
 configure_file(
