From b558d42cdce60aef79f6701b3ca7a31d044610a9 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Wed, 9 Oct 2013 15:41:14 +0300 Subject: [PATCH 01/29] Improvements to cmake: Better support for CMAKE_PREFIX_PATH enviroment variable (and similar ones), added ZM_PERL_SUBPREFIX and ZM_PERL_USE_PATH options and improved detection of libraries and headers --- CMakeLists.txt | 186 +++++++++++------- INSTALL | 2 + .../CheckPrototypeDefinition_fixed.cmake | 98 +++++++++ scripts/ZoneMinder/CMakeLists.txt | 2 +- 4 files changed, 221 insertions(+), 67 deletions(-) create mode 100644 cmake/Modules/CheckPrototypeDefinition_fixed.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f27cd9376..9b1d1d61e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,15 +9,15 @@ # For more information and installation, see the INSTALL file # cmake_minimum_required (VERSION 2.6) -project (ZoneMinder) -# ZoneMinder version -set(ZoneMinder_VERSION "1.26.4") +project (zoneminder) +set(zoneminder_VERSION "1.26.4") + # Default build type. To change the build type, use the CMAKE_BUILD_TYPE configuration option. if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Release or Debug" FORCE) endif(NOT CMAKE_BUILD_TYPE) -# Can make finding problems easier when troubleshooting. +# Can assist in troubleshooting #set(CMAKE_VERBOSE_MAKEFILE ON) #set(CMAKE_INSTALL_ALWAYS ON) @@ -28,25 +28,24 @@ set(CMAKE_C_FLAGS_DEBUG "-Wall -D__STDC_CONSTANT_MACROS -g") set(CMAKE_CXX_FLAGS_DEBUG "-Wall -D__STDC_CONSTANT_MACROS -g") set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") + # Modules that we need: include (GNUInstallDirs) include (CheckIncludeFile) include (CheckIncludeFiles) include (CheckFunctionExists) -include (CheckPrototypeDefinition) +include (CheckPrototypeDefinition_fixed) include (CheckTypeSize) include (CheckStructHasMember) -# Default variables for some configuration options -mark_as_advanced(FORCE ZM_EXTRA_LIBS ZM_MYSQL_ENGINE ZM_NO_MMAP CMAKE_INSTALL_FULL_BINDIR) +# Configuration options +mark_as_advanced(FORCE ZM_EXTRA_LIBS ZM_MYSQL_ENGINE ZM_NO_MMAP CMAKE_INSTALL_FULL_BINDIR ZM_PERL_SUBPREFIX ZM_PERL_USE_PATH) set(ZM_RUNDIR "/var/run/zm" CACHE PATH "Location of transient process files, default: /var/run/zm") set(ZM_TMPDIR "/tmp/zm" CACHE PATH "Location of temporary files, default: /tmp/zm") set(ZM_LOGDIR "/var/log/zm" CACHE PATH "Location of generated log files, default: /var/log/zm") set(ZM_WEBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/zoneminder/www" CACHE PATH "Location of the web files, default: /${CMAKE_INSTALL_DATADIR}/zoneminder/www") set(ZM_CGIDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBEXECDIR}/zoneminder/cgi-bin" CACHE PATH "Location of the cgi-bin files, default: /${CMAKE_INSTALL_LIBEXECDIR}/zoneminder/cgi-bin") set(ZM_CONTENTDIR "/var/lib/zoneminder" CACHE PATH "Location of dynamic content (events and images), default: /var/lib/zoneminder") -# This one is not needed anymore. we do automatic detection of whats available, let ZM know and have ZM decide -#set(ZM_SSL_LIB "openssl" CACHE STRING "Library to use for ssl functions, default: openssl") set(ZM_DB_HOST "localhost" CACHE STRING "Hostname where ZoneMinder database located, default: localhost") set(ZM_DB_NAME "zm" CACHE STRING "Name of ZoneMinder database, default: zm") set(ZM_DB_USER "zmuser" CACHE STRING "Name of ZoneMinder database user, default: zmuser") @@ -57,17 +56,19 @@ set(ZM_WEB_GROUP "" CACHE STRING "The group apache or the local web server runs set(ZM_EXTRA_LIBS "" CACHE STRING "A list of optional libraries, separated by semicolons, e.g. ssl;theora") set(ZM_MYSQL_ENGINE "InnoDB" CACHE STRING "MySQL engine to use with database, default: InnoDB") set(ZM_NO_MMAP "OFF" CACHE BOOL "Set to ON to not use mmap shared memory. Shouldn't be enabled unless you experience problems with the shared memory. default: OFF") +set(ZM_PERL_SUBPREFIX "${CMAKE_INSTALL_LIBDIR}/perl5" CACHE PATH "Use a different directory for the zm perl modules. NOTE: This is a subprefix, e.g. lib will be turned into /lib, default: ${CMAKE_INSTALL_LIBDIR}/perl5") +set(ZM_PERL_USE_PATH "${CMAKE_INSTALL_PREFIX}/${ZM_PERL_SUBPREFIX}" CACHE PATH "Override the include path for zm perl modules. Useful if you are moving the perl modules without using the ZM_PERL_SUBPREFIX option. default: /") # Only required for cmakecacheimport: set(CMAKE_INSTALL_FULL_BINDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" CACHE PATH "Override default binary directory") # Required for certain checks to work set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} stdio.h stdlib.h math.h signal.h) # Required for including headers from the this folder -include_directories("${CMAKE_CURRENT_BINARY_DIR}") +include_directories("${CMAKE_SOURCE_DIR}") # This is required to enable searching in lib64 (if exists), do not change set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) -# Check for misc required stuff +# System checks check_include_file("linux/videodev.h" HAVE_LINUX_VIDEODEV_H) check_include_file("linux/videodev2.h" HAVE_LINUX_VIDEODEV2_H) check_include_file("execinfo.h" HAVE_EXECINFO_H) @@ -91,6 +92,7 @@ if(ZLIB_FOUND) set(HAVE_LIBZLIB 1) list(APPEND ZM_BIN_LIBS ${ZLIB_LIBRARIES}) include_directories(${ZLIB_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIR}) check_include_file("zlib.h" HAVE_ZLIB_H) endif(ZLIB_FOUND) @@ -99,9 +101,13 @@ find_package(JPEG) if(JPEG_FOUND) set(HAVE_LIBJPEG 1) list(APPEND ZM_BIN_LIBS ${JPEG_LIBRARIES}) - include_directories(${JPEG_INCLUDE_DIR}) - check_include_files("stdio.h;jpeglib.h" HAVE_JPEGLIB_H) #link_directories(${JPEG_LIBRARY}) + include_directories(${JPEG_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${JPEG_INCLUDE_DIR}) + check_include_files("stdio.h;jpeglib.h" HAVE_JPEGLIB_H) + if(NOT HAVE_JPEGLIB_H) + message(FATAL_ERROR " zm requires libjpeg headers - check that libjpeg development packages are installed") + endif(NOT HAVE_JPEGLIB_H) else(JPEG_FOUND) message(FATAL_ERROR "zm requires jpeg but it was not found on your system") endif(JPEG_FOUND) @@ -110,102 +116,162 @@ endif(JPEG_FOUND) find_package(OpenSSL) if(OPENSSL_FOUND) set(HAVE_LIBOPENSSL 1) + set(HAVE_LIBCRYPTO 1) list(APPEND ZM_BIN_LIBS ${OPENSSL_LIBRARIES}) include_directories(${OPENSSL_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) check_include_file("openssl/md5.h" HAVE_OPENSSL_MD5_H) endif(OPENSSL_FOUND) -# crypto using find_library. -# This library should be a part of the OpenSSL package but just need to be sure -# In any case, we still need to define HAVE_LIBCRYPTO for zm if its available -find_library(CRYPTO_LIBRARIES crypto) -if(CRYPTO_LIBRARIES) - set(HAVE_LIBCRYPTO 1) - list(APPEND ZM_BIN_LIBS ${CRYPTO_LIBRARIES}) -endif(CRYPTO_LIBRARIES) -# pthread using find_library +# pthread (using find_library and find_path) find_library(PTHREAD_LIBRARIES pthread) if(PTHREAD_LIBRARIES) set(HAVE_LIBPTHREAD 1) list(APPEND ZM_BIN_LIBS ${PTHREAD_LIBRARIES}) + find_path(PTHREAD_INCLUDE_DIR pthread.h) + if(PTHREAD_INCLUDE_DIR) + include_directories(${PTHREAD_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${PTHREAD_INCLUDE_DIR}) + endif(PTHREAD_INCLUDE_DIR) + mark_as_advanced(FORCE PTHREAD_LIBRARIES PTHREAD_INCLUDE_DIR) check_include_file("pthread.h" HAVE_PTHREAD_H) + if(NOT HAVE_PTHREAD_H) + message(FATAL_ERROR " zm requires pthread headers - check that pthread development packages are installed") + endif(NOT HAVE_PTHREAD_H) else(PTHREAD_LIBRARIES) message(FATAL_ERROR "zm requires pthread but it was not found on your system") endif(PTHREAD_LIBRARIES) -# pcre using find_library +# pcre (using find_library and find_path) find_library(PCRE_LIBRARIES pcre) if(PCRE_LIBRARIES) set(HAVE_LIBPCRE 1) list(APPEND ZM_BIN_LIBS ${PCRE_LIBRARIES}) + find_path(PCRE_INCLUDE_DIR pcre.h) + if(PCRE_INCLUDE_DIR) + include_directories(${PCRE_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${PCRE_INCLUDE_DIR}) + endif(PCRE_INCLUDE_DIR) + mark_as_advanced(FORCE PCRE_LIBRARIES PCRE_INCLUDE_DIR) check_include_file("pcre.h" HAVE_PCRE_H) endif(PCRE_LIBRARIES) -# gcrypt using find_library +# gcrypt (using find_library and find_path) find_library(GCRYPT_LIBRARIES gcrypt) if(GCRYPT_LIBRARIES) set(HAVE_LIBGCRYPT 1) list(APPEND ZM_BIN_LIBS ${GCRYPT_LIBRARIES}) + find_path(GCRYPT_INCLUDE_DIR gcrypt.h) + if(GCRYPT_INCLUDE_DIR) + include_directories(${GCRYPT_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${GCRYPT_INCLUDE_DIR}) + endif(GCRYPT_INCLUDE_DIR) + mark_as_advanced(FORCE GCRYPT_LIBRARIES GCRYPT_INCLUDE_DIR) check_include_file("gcrypt.h" HAVE_GCRYPT_H) endif(GCRYPT_LIBRARIES) -# gnutls using find_library +# gnutls (using find_library and find_path) find_library(GNUTLS_LIBRARIES gnutls) if(GNUTLS_LIBRARIES) set(HAVE_LIBGNUTLS 1) list(APPEND ZM_BIN_LIBS ${GNUTLS_LIBRARIES}) + find_path(GNUTLS_INCLUDE_DIR gnutls/gnutls.h) + if(GNUTLS_INCLUDE_DIR) + include_directories(${GNUTLS_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${GNUTLS_INCLUDE_DIR}) + endif(GNUTLS_INCLUDE_DIR) + mark_as_advanced(FORCE GNUTLS_LIBRARIES GNUTLS_INCLUDE_DIR) check_include_file("gnutls/openssl.h" HAVE_GNUTLS_OPENSSL_H) check_include_file("gnutls/gnutls.h" HAVE_GNUTLS_GNUTLS_H) endif(GNUTLS_LIBRARIES) -# mysqlclient using find_library +# mysqlclient (using find_library and find_path) find_library(MYSQLCLIENT_LIBRARIES mysqlclient PATH_SUFFIXES mysql) if(MYSQLCLIENT_LIBRARIES) set(HAVE_LIBMYSQLCLIENT 1) - list(APPEND ZM_BIN_LIBS ${MYSQLCLIENT_LIBRARIES}) + list(APPEND ZM_BIN_LIBS ${MYSQLCLIENT_LIBRARIES}) + find_path(MYSQLCLIENT_INCLUDE_DIR mysql/mysql.h) + if(MYSQLCLIENT_INCLUDE_DIR) + include_directories(${MYSQLCLIENT_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${MYSQLCLIENT_INCLUDE_DIR}) + endif(MYSQLCLIENT_INCLUDE_DIR) + mark_as_advanced(FORCE MYSQLCLIENT_LIBRARIES MYSQLCLIENT_INCLUDE_DIR) check_include_file("mysql/mysql.h" HAVE_MYSQL_H) + if(NOT HAVE_MYSQL_H) + message(FATAL_ERROR "zm requires MySQL headers - check that MySQL development packages are installed") + endif(NOT HAVE_MYSQL_H) else(MYSQLCLIENT_LIBRARIES) message(FATAL_ERROR "zm requires mysqlclient but it was not found on your system") endif(MYSQLCLIENT_LIBRARIES) -# avformat using find_library +# avformat (using find_library and find_path) find_library(AVFORMAT_LIBRARIES avformat) if(AVFORMAT_LIBRARIES) set(HAVE_LIBAVFORMAT 1) - list(APPEND ZM_BIN_LIBS ${AVFORMAT_LIBRARIES}) + list(APPEND ZM_BIN_LIBS ${AVFORMAT_LIBRARIES}) + find_path(AVFORMAT_INCLUDE_DIR "libavformat/avformat.h") + if(AVFORMAT_INCLUDE_DIR) + include_directories(${AVFORMAT_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${AVFORMAT_INCLUDE_DIR}) + endif(AVFORMAT_INCLUDE_DIR) + mark_as_advanced(FORCE AVFORMAT_LIBRARIES AVFORMAT_INCLUDE_DIR) check_include_file("libavformat/avformat.h" HAVE_LIBAVFORMAT_AVFORMAT_H) endif(AVFORMAT_LIBRARIES) -# avcodec using find_library +# avcodec (using find_library and find_path) find_library(AVCODEC_LIBRARIES avcodec) if(AVCODEC_LIBRARIES) set(HAVE_LIBAVCODEC 1) - list(APPEND ZM_BIN_LIBS ${AVCODEC_LIBRARIES}) + list(APPEND ZM_BIN_LIBS ${AVCODEC_LIBRARIES}) + find_path(AVCODEC_INCLUDE_DIR "libavcodec/avcodec.h") + if(AVCODEC_INCLUDE_DIR) + include_directories(${AVCODEC_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${AVCODEC_INCLUDE_DIR}) + endif(AVCODEC_INCLUDE_DIR) + mark_as_advanced(FORCE AVCODEC_LIBRARIES AVCODEC_INCLUDE_DIR) check_include_file("libavcodec/avcodec.h" HAVE_LIBAVCODEC_AVCODEC_H) endif(AVCODEC_LIBRARIES) -# avdevice using find_library +# avdevice (using find_library and find_path) find_library(AVDEVICE_LIBRARIES avdevice) if(AVDEVICE_LIBRARIES) set(HAVE_LIBAVDEVICE 1) - list(APPEND ZM_BIN_LIBS ${AVDEVICE_LIBRARIES}) + list(APPEND ZM_BIN_LIBS ${AVDEVICE_LIBRARIES}) + find_path(AVDEVICE_INCLUDE_DIR "libavdevice/avdevice.h") + if(AVDEVICE_INCLUDE_DIR) + include_directories(${AVDEVICE_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${AVDEVICE_INCLUDE_DIR}) + endif(AVDEVICE_INCLUDE_DIR) + mark_as_advanced(FORCE AVDEVICE_LIBRARIES AVDEVICE_INCLUDE_DIR) check_include_file("libavdevice/avdevice.h" HAVE_LIBAVDEVICE_AVDEVICE_H) endif(AVDEVICE_LIBRARIES) -# avutil using find_library +# avutil (using find_library and find_path) find_library(AVUTIL_LIBRARIES avutil) if(AVUTIL_LIBRARIES) set(HAVE_LIBAVUTIL 1) - list(APPEND ZM_BIN_LIBS ${AVUTIL_LIBRARIES}) + list(APPEND ZM_BIN_LIBS ${AVUTIL_LIBRARIES}) + find_path(AVUTIL_INCLUDE_DIR "libavutil/avutil.h") + if(AVUTIL_INCLUDE_DIR) + include_directories(${AVUTIL_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${AVUTIL_INCLUDE_DIR}) + endif(AVUTIL_INCLUDE_DIR) + mark_as_advanced(FORCE AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIR) check_include_file("libavutil/avutil.h" HAVE_LIBAVUTIL_AVUTIL_H) check_include_file("libavutil/mathematics.h" HAVE_LIBAVUTIL_MATHEMATICS_H) endif(AVUTIL_LIBRARIES) -# swscale using find_library +# swscale (using find_library and find_path) find_library(SWSCALE_LIBRARIES swscale) if(SWSCALE_LIBRARIES) set(HAVE_LIBSWSCALE 1) - list(APPEND ZM_BIN_LIBS ${SWSCALE_LIBRARIES}) + list(APPEND ZM_BIN_LIBS ${SWSCALE_LIBRARIES}) + find_path(SWSCALE_INCLUDE_DIR "libswscale/swscale.h") + if(SWSCALE_INCLUDE_DIR) + include_directories(${SWSCALE_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${SWSCALE_INCLUDE_DIR}) + endif(SWSCALE_INCLUDE_DIR) + mark_as_advanced(FORCE SWSCALE_LIBRARIES SWSCALE_INCLUDE_DIR) check_include_file("libswscale/swscale.h" HAVE_LIBSWSCALE_SWSCALE_H) endif(SWSCALE_LIBRARIES) @@ -216,22 +282,7 @@ if((NOT HAVE_LIBCRYPTO) AND (NOT HAVE_LIBGNUTLS)) message(FATAL_ERROR " zm requires crypto or gnutls but none were found on your system") endif((NOT HAVE_LIBCRYPTO) AND (NOT HAVE_LIBGNUTLS)) -# Check for absolutely required headers: -if(NOT HAVE_MYSQL_H) - message(FATAL_ERROR "zm requires MySQL headers - check that MySQL development packages are installed") -endif(NOT HAVE_MYSQL_H) -if(NOT HAVE_JPEGLIB_H) - message(FATAL_ERROR " zm requires libjpeg headers - check that libjpeg development packages are installed") -endif(NOT HAVE_JPEGLIB_H) -if(NOT HAVE_PTHREAD_H) - message(FATAL_ERROR " zm requires pthread headers - check that pthread development packages are installed") -endif(NOT HAVE_PTHREAD_H) - # Check for V4L header files and enable ZM_HAS_V4L, ZM_HAS_V4L1, ZM_HAS_V4L2 accordingly -# Setting to zeros first is required because ZM uses #define for these -set(ZM_HAS_V4L 0) -set(ZM_HAS_V4L1 0) -set(ZM_HAS_V4L2 0) if(HAVE_LINUX_VIDEODEV_H) set(ZM_HAS_V4L 1) set(ZM_HAS_V4L1 1) @@ -244,20 +295,31 @@ if((NOT HAVE_LINUX_VIDEODEV_H) AND (NOT HAVE_LINUX_VIDEODEV2_H)) message(AUTHOR_WARNING " Video 4 Linux headers weren't found - Analog and USB camera support will not be available") endif((NOT HAVE_LINUX_VIDEODEV_H) AND (NOT HAVE_LINUX_VIDEODEV2_H)) # Check for PCRE and enable ZM_PCRE accordingly -set(ZM_PCRE 0) if(HAVE_LIBPCRE AND HAVE_PCRE_H) set(ZM_PCRE 1) endif(HAVE_LIBPCRE AND HAVE_PCRE_H) - +# Check for mmap enable in all components +set(ENABLE_MMAP no) +if(NOT ZM_NO_MMAP) + set(ZM_MEM_MAPPED 1) + set(ENABLE_MMAP yes) + set(ZM_MMAP_PERLPACKAGE "Sys::Mmap") +endif(NOT ZM_NO_MMAP) # Check for authenication functions if(HAVE_OPENSSL_MD5_H) + set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) + set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) check_prototype_definition(MD5 "unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md)" "NULL" "openssl/md5.h" HAVE_MD5_OPENSSL) endif(HAVE_OPENSSL_MD5_H) if(HAVE_GNUTLS_OPENSSL_H) + set(CMAKE_REQUIRED_LIBRARIES ${GNUTLS_LIBRARIES}) + set(CMAKE_REQUIRED_INCLUDES ${GNUTLS_INCLUDE_DIR}) check_prototype_definition(MD5 "unsigned char *MD5 (const unsigned char *buf, unsigned long len, unsigned char *md)" "NULL" "gnutls/openssl.h" HAVE_MD5_GNUTLS) endif(HAVE_GNUTLS_OPENSSL_H) if(HAVE_GNUTLS_GNUTLS_H) + set(CMAKE_REQUIRED_LIBRARIES ${GNUTLS_LIBRARIES}) + set(CMAKE_REQUIRED_INCLUDES ${GNUTLS_INCLUDE_DIR}) check_prototype_definition(gnutls_fingerprint "int gnutls_fingerprint (gnutls_digest_algorithm_t algo, const gnutls_datum_t * data, void *result, size_t * result_size)" "0" "stdlib.h;gnutls/gnutls.h" HAVE_DECL_GNUTLS_FINGERPRINT) endif(HAVE_GNUTLS_GNUTLS_H) if(HAVE_MD5_OPENSSL OR HAVE_MD5_GNUTLS) @@ -272,20 +334,12 @@ if(HAVE_LIBCRYPTO AND HAVE_OPENSSL_MD5_H AND HAVE_MD5_OPENSSL) set(HAVE_GNUTLS_OPENSSL_H 0) endif(HAVE_LIBCRYPTO AND HAVE_OPENSSL_MD5_H AND HAVE_MD5_OPENSSL) -# Enable mmap in all components -set(ZM_MEM_MAPPED 0) -set(ENABLE_MMAP no) -if(NOT ZM_NO_MMAP) - set(ZM_MEM_MAPPED 1) - set(ENABLE_MMAP yes) - set(ZM_MMAP_PERLPACKAGE "Sys::Mmap") -endif(NOT ZM_NO_MMAP) - -# Check for Perl. Version checking is removed because its ignored before CMake 2.8.8 and it seems that Perl is being detected as 5.16. instead of 5.6.0 ?? +# Check for Perl find_package(Perl) if(NOT PERL_FOUND) message(FATAL_ERROR "zm requires Perl 5.6.0 or newer but it was not found on your system") endif(NOT PERL_FOUND) + # Checking for perl modules requires FindPerlModules.cmake # Check all required modules at once # TODO: Add checking for the optional modules @@ -316,7 +370,7 @@ message(STATUS "Using web group: ${ZM_WEB_GROUP}") # Some variables that zm expects set(ZM_PID "${ZM_RUNDIR}/zm.pid") set(ZM_CONFIG "/${CMAKE_INSTALL_SYSCONFDIR}/zm.conf") -set(VERSION "${ZoneMinder_VERSION}") +set(VERSION "${zoneminder_VERSION}") set(PATH_BUILD "${PROJECT_SOURCE_DIR}") set(PKGDATADIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/zoneminder") set(TIME_BUILD "1000000") # Don't have a solution for this one yet @@ -327,7 +381,7 @@ set(WEB_PREFIX "${ZM_WEBDIR}") set(CGI_PREFIX "${ZM_CGIDIR}") set(WEB_USER "${ZM_WEB_USER}") set(WEB_GROUP "${ZM_WEB_GROUP}") -set(EXTRA_PERL_LIB "use lib '${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/perl5';") +set(EXTRA_PERL_LIB "use lib '${ZM_PERL_USE_PATH}';") # Generate files from the .in files configure_file(zoneminder-config.cmake config.h @ONLY) diff --git a/INSTALL b/INSTALL index 55ad695f8..be56312d1 100644 --- a/INSTALL +++ b/INSTALL @@ -48,6 +48,8 @@ Advanced: ZM_EXTRA_LIBS A list of optional libraries, separated by semicolons, e.g. ssl;theora ZM_MYSQL_ENGINE MySQL engine to use with database, default: InnoDB ZM_NO_MMAP Set to ON to not use mmap shared memory. Shouldn't be enabled unless you experience problems with the shared memory. default: OFF + ZM_PERL_SUBPREFIX Use a different directory for the zm perl modules. NOTE: This is a subprefix, e.g. lib will be turned into /lib, default: /perl5 + ZM_PERL_USE_PATH Override the include path for zm perl modules. Useful if you are moving the perl modules without using the ZM_PERL_SUBPREFIX option. default: / Useful configuration options provided by cmake: diff --git a/cmake/Modules/CheckPrototypeDefinition_fixed.cmake b/cmake/Modules/CheckPrototypeDefinition_fixed.cmake new file mode 100644 index 000000000..550bcaa50 --- /dev/null +++ b/cmake/Modules/CheckPrototypeDefinition_fixed.cmake @@ -0,0 +1,98 @@ +# - Check if the protoype we expect is correct. +# check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE) +# FUNCTION - The name of the function (used to check if prototype exists) +# PROTOTYPE- The prototype to check. +# RETURN - The return value of the function. +# HEADER - The header files required. +# VARIABLE - The variable to store the result. +# Example: +# check_prototype_definition(getpwent_r +# "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)" +# "NULL" +# "unistd.h;pwd.h" +# SOLARIS_GETPWENT_R) +# The following variables may be set before calling this macro to +# modify the way the check is run: +# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link + +#============================================================================= +# Copyright 2005-2009 Kitware, Inc. +# Copyright 2010-2011 Andreas Schneider +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) +# + + +get_filename_component(__check_proto_def_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) + + +function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE) + + if ("${_VARIABLE}" MATCHES "^${_VARIABLE}$") + set(CHECK_PROTOTYPE_DEFINITION_CONTENT "/* */\n") + + set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS}) + if (CMAKE_REQUIRED_LIBRARIES) + set(CHECK_PROTOTYPE_DEFINITION_LIBS + ${LINK_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES}) + else() + set(CHECK_PROTOTYPE_DEFINITION_LIBS) + endif() + if (CMAKE_REQUIRED_INCLUDES) + set(CMAKE_SYMBOL_EXISTS_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + else() + set(CMAKE_SYMBOL_EXISTS_INCLUDES) + endif() + + foreach(_FILE ${_HEADER}) + set(CHECK_PROTOTYPE_DEFINITION_HEADER + "${CHECK_PROTOTYPE_DEFINITION_HEADER}#include <${_FILE}>\n") + endforeach() + + set(CHECK_PROTOTYPE_DEFINITION_SYMBOL ${_FUNCTION}) + set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE}) + set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN}) + + configure_file("${__check_proto_def_dir}/CheckPrototypeDefinition.c.in" + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY) + + file(READ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c _SOURCE) + + try_compile(${_VARIABLE} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + ${CHECK_PROTOTYPE_DEFINITION_LIBS} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CHECK_PROTOTYPE_DEFINITION_FLAGS} + "${CMAKE_SYMBOL_EXISTS_INCLUDES}" + OUTPUT_VARIABLE OUTPUT) + + if (${_VARIABLE}) + set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}") + message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n" + "${OUTPUT}\n\n") + else () + message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False") + set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n" + "${OUTPUT}\n\n${_SOURCE}\n\n") + endif () + endif() + +endfunction() diff --git a/scripts/ZoneMinder/CMakeLists.txt b/scripts/ZoneMinder/CMakeLists.txt index 0c431dd8b..267c98041 100644 --- a/scripts/ZoneMinder/CMakeLists.txt +++ b/scripts/ZoneMinder/CMakeLists.txt @@ -7,7 +7,7 @@ configure_file(lib/ZoneMinder/Memory.pm.in ${CMAKE_CURRENT_SOURCE_DIR}/lib/ZoneM configure_file(lib/ZoneMinder/ConfigData.pm.in ${CMAKE_CURRENT_SOURCE_DIR}/lib/ZoneMinder/ConfigData.pm @ONLY) # Add build target for the perl modules -add_custom_target(zmperlmodules ALL perl Makefile.PL FIRST_MAKEFILE=MakefilePerl PREFIX=output LIB="output/${CMAKE_INSTALL_LIBDIR}/perl5" COMMAND make --makefile=MakefilePerl COMMAND make --makefile=MakefilePerl pure_install COMMENT "Building ZoneMinder perl modules") +add_custom_target(zmperlmodules ALL perl Makefile.PL FIRST_MAKEFILE=MakefilePerl PREFIX=output LIB="output/${ZM_PERL_SUBPREFIX}" COMMAND make --makefile=MakefilePerl COMMAND make --makefile=MakefilePerl pure_install COMMENT "Building ZoneMinder perl modules") # Add install target for the perl modules install(DIRECTORY output/ DESTINATION "${CMAKE_INSTALL_PREFIX}") From 49503891eb45897f96dded68d633d9e37e6eda95 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Wed, 9 Oct 2013 15:58:14 +0300 Subject: [PATCH 02/29] Added ZM_NO_FFMPEG option to skip ffmpeg checks and force building without ffmpeg --- CMakeLists.txt | 136 +++++++++++++++++++++++++------------------------ INSTALL | 1 + 2 files changed, 71 insertions(+), 66 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b1d1d61e..20433e588 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,7 @@ set(ZM_WEB_GROUP "" CACHE STRING "The group apache or the local web server runs set(ZM_EXTRA_LIBS "" CACHE STRING "A list of optional libraries, separated by semicolons, e.g. ssl;theora") set(ZM_MYSQL_ENGINE "InnoDB" CACHE STRING "MySQL engine to use with database, default: InnoDB") set(ZM_NO_MMAP "OFF" CACHE BOOL "Set to ON to not use mmap shared memory. Shouldn't be enabled unless you experience problems with the shared memory. default: OFF") +set(ZM_NO_FFMPEG "OFF" CACHE BOOL "Set to ON to skip ffmpeg checks and force building ZM without ffmpeg. default: OFF") set(ZM_PERL_SUBPREFIX "${CMAKE_INSTALL_LIBDIR}/perl5" CACHE PATH "Use a different directory for the zm perl modules. NOTE: This is a subprefix, e.g. lib will be turned into /lib, default: ${CMAKE_INSTALL_LIBDIR}/perl5") set(ZM_PERL_USE_PATH "${CMAKE_INSTALL_PREFIX}/${ZM_PERL_SUBPREFIX}" CACHE PATH "Override the include path for zm perl modules. Useful if you are moving the perl modules without using the ZM_PERL_SUBPREFIX option. default: /") # Only required for cmakecacheimport: @@ -204,76 +205,79 @@ else(MYSQLCLIENT_LIBRARIES) message(FATAL_ERROR "zm requires mysqlclient but it was not found on your system") endif(MYSQLCLIENT_LIBRARIES) -# avformat (using find_library and find_path) -find_library(AVFORMAT_LIBRARIES avformat) -if(AVFORMAT_LIBRARIES) - set(HAVE_LIBAVFORMAT 1) - list(APPEND ZM_BIN_LIBS ${AVFORMAT_LIBRARIES}) - find_path(AVFORMAT_INCLUDE_DIR "libavformat/avformat.h") - if(AVFORMAT_INCLUDE_DIR) - include_directories(${AVFORMAT_INCLUDE_DIR}) - set(CMAKE_REQUIRED_INCLUDES ${AVFORMAT_INCLUDE_DIR}) - endif(AVFORMAT_INCLUDE_DIR) - mark_as_advanced(FORCE AVFORMAT_LIBRARIES AVFORMAT_INCLUDE_DIR) - check_include_file("libavformat/avformat.h" HAVE_LIBAVFORMAT_AVFORMAT_H) -endif(AVFORMAT_LIBRARIES) +# Do not check for ffmpeg if ZM_NO_FFMPEG is on +if(NOT ZM_NO_FFMPEG) + # avformat (using find_library and find_path) + find_library(AVFORMAT_LIBRARIES avformat) + if(AVFORMAT_LIBRARIES) + set(HAVE_LIBAVFORMAT 1) + list(APPEND ZM_BIN_LIBS ${AVFORMAT_LIBRARIES}) + find_path(AVFORMAT_INCLUDE_DIR "libavformat/avformat.h") + if(AVFORMAT_INCLUDE_DIR) + include_directories(${AVFORMAT_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${AVFORMAT_INCLUDE_DIR}) + endif(AVFORMAT_INCLUDE_DIR) + mark_as_advanced(FORCE AVFORMAT_LIBRARIES AVFORMAT_INCLUDE_DIR) + check_include_file("libavformat/avformat.h" HAVE_LIBAVFORMAT_AVFORMAT_H) + endif(AVFORMAT_LIBRARIES) -# avcodec (using find_library and find_path) -find_library(AVCODEC_LIBRARIES avcodec) -if(AVCODEC_LIBRARIES) - set(HAVE_LIBAVCODEC 1) - list(APPEND ZM_BIN_LIBS ${AVCODEC_LIBRARIES}) - find_path(AVCODEC_INCLUDE_DIR "libavcodec/avcodec.h") - if(AVCODEC_INCLUDE_DIR) - include_directories(${AVCODEC_INCLUDE_DIR}) - set(CMAKE_REQUIRED_INCLUDES ${AVCODEC_INCLUDE_DIR}) - endif(AVCODEC_INCLUDE_DIR) - mark_as_advanced(FORCE AVCODEC_LIBRARIES AVCODEC_INCLUDE_DIR) - check_include_file("libavcodec/avcodec.h" HAVE_LIBAVCODEC_AVCODEC_H) -endif(AVCODEC_LIBRARIES) + # avcodec (using find_library and find_path) + find_library(AVCODEC_LIBRARIES avcodec) + if(AVCODEC_LIBRARIES) + set(HAVE_LIBAVCODEC 1) + list(APPEND ZM_BIN_LIBS ${AVCODEC_LIBRARIES}) + find_path(AVCODEC_INCLUDE_DIR "libavcodec/avcodec.h") + if(AVCODEC_INCLUDE_DIR) + include_directories(${AVCODEC_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${AVCODEC_INCLUDE_DIR}) + endif(AVCODEC_INCLUDE_DIR) + mark_as_advanced(FORCE AVCODEC_LIBRARIES AVCODEC_INCLUDE_DIR) + check_include_file("libavcodec/avcodec.h" HAVE_LIBAVCODEC_AVCODEC_H) + endif(AVCODEC_LIBRARIES) -# avdevice (using find_library and find_path) -find_library(AVDEVICE_LIBRARIES avdevice) -if(AVDEVICE_LIBRARIES) - set(HAVE_LIBAVDEVICE 1) - list(APPEND ZM_BIN_LIBS ${AVDEVICE_LIBRARIES}) - find_path(AVDEVICE_INCLUDE_DIR "libavdevice/avdevice.h") - if(AVDEVICE_INCLUDE_DIR) - include_directories(${AVDEVICE_INCLUDE_DIR}) - set(CMAKE_REQUIRED_INCLUDES ${AVDEVICE_INCLUDE_DIR}) - endif(AVDEVICE_INCLUDE_DIR) - mark_as_advanced(FORCE AVDEVICE_LIBRARIES AVDEVICE_INCLUDE_DIR) - check_include_file("libavdevice/avdevice.h" HAVE_LIBAVDEVICE_AVDEVICE_H) -endif(AVDEVICE_LIBRARIES) + # avdevice (using find_library and find_path) + find_library(AVDEVICE_LIBRARIES avdevice) + if(AVDEVICE_LIBRARIES) + set(HAVE_LIBAVDEVICE 1) + list(APPEND ZM_BIN_LIBS ${AVDEVICE_LIBRARIES}) + find_path(AVDEVICE_INCLUDE_DIR "libavdevice/avdevice.h") + if(AVDEVICE_INCLUDE_DIR) + include_directories(${AVDEVICE_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${AVDEVICE_INCLUDE_DIR}) + endif(AVDEVICE_INCLUDE_DIR) + mark_as_advanced(FORCE AVDEVICE_LIBRARIES AVDEVICE_INCLUDE_DIR) + check_include_file("libavdevice/avdevice.h" HAVE_LIBAVDEVICE_AVDEVICE_H) + endif(AVDEVICE_LIBRARIES) -# avutil (using find_library and find_path) -find_library(AVUTIL_LIBRARIES avutil) -if(AVUTIL_LIBRARIES) - set(HAVE_LIBAVUTIL 1) - list(APPEND ZM_BIN_LIBS ${AVUTIL_LIBRARIES}) - find_path(AVUTIL_INCLUDE_DIR "libavutil/avutil.h") - if(AVUTIL_INCLUDE_DIR) - include_directories(${AVUTIL_INCLUDE_DIR}) - set(CMAKE_REQUIRED_INCLUDES ${AVUTIL_INCLUDE_DIR}) - endif(AVUTIL_INCLUDE_DIR) - mark_as_advanced(FORCE AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIR) - check_include_file("libavutil/avutil.h" HAVE_LIBAVUTIL_AVUTIL_H) - check_include_file("libavutil/mathematics.h" HAVE_LIBAVUTIL_MATHEMATICS_H) -endif(AVUTIL_LIBRARIES) + # avutil (using find_library and find_path) + find_library(AVUTIL_LIBRARIES avutil) + if(AVUTIL_LIBRARIES) + set(HAVE_LIBAVUTIL 1) + list(APPEND ZM_BIN_LIBS ${AVUTIL_LIBRARIES}) + find_path(AVUTIL_INCLUDE_DIR "libavutil/avutil.h") + if(AVUTIL_INCLUDE_DIR) + include_directories(${AVUTIL_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${AVUTIL_INCLUDE_DIR}) + endif(AVUTIL_INCLUDE_DIR) + mark_as_advanced(FORCE AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIR) + check_include_file("libavutil/avutil.h" HAVE_LIBAVUTIL_AVUTIL_H) + check_include_file("libavutil/mathematics.h" HAVE_LIBAVUTIL_MATHEMATICS_H) + endif(AVUTIL_LIBRARIES) -# swscale (using find_library and find_path) -find_library(SWSCALE_LIBRARIES swscale) -if(SWSCALE_LIBRARIES) - set(HAVE_LIBSWSCALE 1) - list(APPEND ZM_BIN_LIBS ${SWSCALE_LIBRARIES}) - find_path(SWSCALE_INCLUDE_DIR "libswscale/swscale.h") - if(SWSCALE_INCLUDE_DIR) - include_directories(${SWSCALE_INCLUDE_DIR}) - set(CMAKE_REQUIRED_INCLUDES ${SWSCALE_INCLUDE_DIR}) - endif(SWSCALE_INCLUDE_DIR) - mark_as_advanced(FORCE SWSCALE_LIBRARIES SWSCALE_INCLUDE_DIR) - check_include_file("libswscale/swscale.h" HAVE_LIBSWSCALE_SWSCALE_H) -endif(SWSCALE_LIBRARIES) + # swscale (using find_library and find_path) + find_library(SWSCALE_LIBRARIES swscale) + if(SWSCALE_LIBRARIES) + set(HAVE_LIBSWSCALE 1) + list(APPEND ZM_BIN_LIBS ${SWSCALE_LIBRARIES}) + find_path(SWSCALE_INCLUDE_DIR "libswscale/swscale.h") + if(SWSCALE_INCLUDE_DIR) + include_directories(${SWSCALE_INCLUDE_DIR}) + set(CMAKE_REQUIRED_INCLUDES ${SWSCALE_INCLUDE_DIR}) + endif(SWSCALE_INCLUDE_DIR) + mark_as_advanced(FORCE SWSCALE_LIBRARIES SWSCALE_INCLUDE_DIR) + check_include_file("libswscale/swscale.h" HAVE_LIBSWSCALE_SWSCALE_H) + endif(SWSCALE_LIBRARIES) +endif(NOT ZM_NO_FFMPEG) # *** END OF LIBRARY CHECKS *** diff --git a/INSTALL b/INSTALL index be56312d1..dce0adbd1 100644 --- a/INSTALL +++ b/INSTALL @@ -48,6 +48,7 @@ Advanced: ZM_EXTRA_LIBS A list of optional libraries, separated by semicolons, e.g. ssl;theora ZM_MYSQL_ENGINE MySQL engine to use with database, default: InnoDB ZM_NO_MMAP Set to ON to not use mmap shared memory. Shouldn't be enabled unless you experience problems with the shared memory. default: OFF + ZM_NO_FFMPEG Set to ON to skip ffmpeg checks and force building ZM without ffmpeg. default: OFF ZM_PERL_SUBPREFIX Use a different directory for the zm perl modules. NOTE: This is a subprefix, e.g. lib will be turned into /lib, default: /perl5 ZM_PERL_USE_PATH Override the include path for zm perl modules. Useful if you are moving the perl modules without using the ZM_PERL_SUBPREFIX option. default: / From 7d6cca13b8dfd19ebf5b94714ad661f1676ab016 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Wed, 9 Oct 2013 16:05:56 +0300 Subject: [PATCH 03/29] Revert few changes that broke the cmake build in travis --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20433e588..bd0b5ecac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -287,6 +287,10 @@ if((NOT HAVE_LIBCRYPTO) AND (NOT HAVE_LIBGNUTLS)) endif((NOT HAVE_LIBCRYPTO) AND (NOT HAVE_LIBGNUTLS)) # Check for V4L header files and enable ZM_HAS_V4L, ZM_HAS_V4L1, ZM_HAS_V4L2 accordingly +# Setting to zeros first is required because ZM uses #define for these +set(ZM_HAS_V4L 0) +set(ZM_HAS_V4L1 0) +set(ZM_HAS_V4L2 0) if(HAVE_LINUX_VIDEODEV_H) set(ZM_HAS_V4L 1) set(ZM_HAS_V4L1 1) @@ -299,10 +303,12 @@ if((NOT HAVE_LINUX_VIDEODEV_H) AND (NOT HAVE_LINUX_VIDEODEV2_H)) message(AUTHOR_WARNING " Video 4 Linux headers weren't found - Analog and USB camera support will not be available") endif((NOT HAVE_LINUX_VIDEODEV_H) AND (NOT HAVE_LINUX_VIDEODEV2_H)) # Check for PCRE and enable ZM_PCRE accordingly +set(ZM_PCRE 0) if(HAVE_LIBPCRE AND HAVE_PCRE_H) set(ZM_PCRE 1) endif(HAVE_LIBPCRE AND HAVE_PCRE_H) -# Check for mmap enable in all components +# Check for mmap and enable in all components +set(ZM_MEM_MAPPED 0) set(ENABLE_MMAP no) if(NOT ZM_NO_MMAP) set(ZM_MEM_MAPPED 1) From 8cecadadc21b6d46c884b6cfcce8ee9d3aa1425e Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Thu, 10 Oct 2013 06:55:45 +0300 Subject: [PATCH 04/29] Fix rotation bug caused by commit 5a9364703c --- src/zm_image.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 82440aae6..18b93c57b 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -2352,10 +2352,10 @@ void Image::Rotate( int angle ) if ( colours == ZM_COLOUR_GRAY8 ) { unsigned char *d_ptr; - for ( unsigned int i = new_width-1; i >= 0; i-- ) + for ( unsigned int i = new_width; i > 0; i-- ) { - d_ptr = rotate_buffer+i; - for ( unsigned int j = new_height-1; j >= 0; j-- ) + d_ptr = rotate_buffer+(i-1); + for ( unsigned int j = new_height; j > 0; j-- ) { *d_ptr = *s_ptr++; d_ptr += line_bytes; @@ -2366,10 +2366,10 @@ void Image::Rotate( int angle ) { Rgb* s_rptr = (Rgb*)s_ptr; Rgb* d_rptr; - for ( unsigned int i = new_width-1; i >= 0; i-- ) + for ( unsigned int i = new_width; i > 0; i-- ) { - d_rptr = (Rgb*)(rotate_buffer+(i<<2)); - for ( unsigned int j = new_height-1; j >= 0; j-- ) + d_rptr = (Rgb*)(rotate_buffer+((i-1)<<2)); + for ( unsigned int j = new_height; j > 0; j-- ) { *d_rptr = *s_rptr++; d_rptr += new_width; @@ -2379,10 +2379,10 @@ void Image::Rotate( int angle ) else /* Assume RGB24 */ { unsigned char *d_ptr; - for ( unsigned int i = new_width-1; i >= 0; i-- ) + for ( unsigned int i = new_width; i > 0; i-- ) { - d_ptr = rotate_buffer+(3*i); - for ( unsigned int j = new_height-1; j >= 0; j-- ) + d_ptr = rotate_buffer+((i-1)*3); + for ( unsigned int j = new_height; j > 0; j-- ) { *d_ptr = *s_ptr++; *(d_ptr+1) = *s_ptr++; @@ -2439,10 +2439,10 @@ void Image::Rotate( int angle ) if ( colours == ZM_COLOUR_GRAY8 ) { unsigned char *d_ptr; - for ( unsigned int i = new_width-1; i >= 0; i-- ) + for ( unsigned int i = new_width; i > 0; i-- ) { - d_ptr = rotate_buffer+i; - for ( unsigned int j = new_height-1; j >= 0; j-- ) + d_ptr = rotate_buffer+(i-1); + for ( unsigned int j = new_height; j > 0; j-- ) { s_ptr--; *d_ptr = *s_ptr; @@ -2454,10 +2454,10 @@ void Image::Rotate( int angle ) { Rgb* s_rptr = (Rgb*)s_ptr; Rgb* d_rptr; - for ( int i = new_width-1; i >= 0; i-- ) + for ( unsigned int i = new_width; i > 0; i-- ) { - d_rptr = (Rgb*)(rotate_buffer+(i<<2)); - for ( int j = new_height-1; j >= 0; j-- ) + d_rptr = (Rgb*)(rotate_buffer+((i-1)<<2)); + for ( unsigned int j = new_height; j > 0; j-- ) { s_rptr--; *d_rptr = *s_rptr; @@ -2468,10 +2468,10 @@ void Image::Rotate( int angle ) else /* Assume RGB24 */ { unsigned char *d_ptr; - for ( unsigned int i = new_width-1; i >= 0; i-- ) + for ( unsigned int i = new_width; i > 0; i-- ) { - d_ptr = rotate_buffer+(3*i); - for ( unsigned int j = new_height-1; j >= 0; j-- ) + d_ptr = rotate_buffer+((i-1)*3); + for ( unsigned int j = new_height; j > 0; j-- ) { *(d_ptr+2) = *(--s_ptr); *(d_ptr+1) = *(--s_ptr); From 421d67e37905638b32440c0d241c8b7155bcc32b Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Thu, 10 Oct 2013 07:16:11 +0300 Subject: [PATCH 05/29] Improvements to zm_ffmpeg.h --- src/zm_ffmpeg.h | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/zm_ffmpeg.h b/src/zm_ffmpeg.h index d88e560a1..5fd3fe5b6 100644 --- a/src/zm_ffmpeg.h +++ b/src/zm_ffmpeg.h @@ -20,48 +20,56 @@ #ifndef ZM_FFMPEG_H #define ZM_FFMPEG_H #include -#if HAVE_LIBAVCODEC #ifdef __cplusplus extern "C" { #endif + +// AVUTIL #if HAVE_LIBAVUTIL_AVUTIL_H #include #include +#include #elif HAVE_FFMPEG_AVUTIL_H #include #include -/*#else -#error "No location for avutils.h found"*/ +#include #endif + +// AVCODEC #if HAVE_LIBAVCODEC_AVCODEC_H #include #elif HAVE_FFMPEG_AVCODEC_H #include -/*#else -#error "No location for avcodec.h found"*/ #endif + +// AVFORMAT #if HAVE_LIBAVFORMAT_AVFORMAT_H #include #elif HAVE_FFMPEG_AVFORMAT_H #include -/*#else -#error "No location for avformat.h found"*/ #endif -#if HAVE_LIBSWSCALE + +// AVDEVICE +#if HAVE_LIBAVDEVICE_AVDEVICE_H +#include +#elif HAVE_FFMPEG_AVDEVICE_H +#include +#endif + +// SWSCALE #if HAVE_LIBSWSCALE_SWSCALE_H #include -#include // this is a fix for error: 'av_rescale_q' was not declared in this scope #elif HAVE_FFMPEG_SWSCALE_H #include -/*#else -#error "No location for swscale.h found"*/ #endif -#endif // HAVE_LIBSWSCALE + #ifdef __cplusplus } #endif +#if ( HAVE_LIBAVUTIL_AVUTIL_H || HAVE_LIBAVCODEC_AVCODEC_H || HAVE_LIBAVFORMAT_AVFORMAT_H || HAVE_LIBAVDEVICE_AVDEVICE_H ) + #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 4, 0) #if defined(AVIO_WRONLY) #define AVIO_FLAG_WRITE AVIO_WRONLY @@ -87,7 +95,7 @@ extern "C" { #define SWS_CPU_CAPS_SSE2 0x02000000 #endif -#endif // HAVE_LIBAVCODEC +#endif // ( HAVE_LIBAVUTIL_AVUTIL_H || HAVE_LIBAVCODEC_AVCODEC_H || HAVE_LIBAVFORMAT_AVFORMAT_H || HAVE_LIBAVDEVICE_AVDEVICE_H ) #endif // ZM_FFMPEG_H From bb5b936ad3dcfeb0a6006e4ca82a29f7592f1bfb Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Thu, 10 Oct 2013 14:04:00 +0300 Subject: [PATCH 06/29] Fixed a bug with HAVE_LIBAVDEVICE_AVDEVICE_H in cmake --- zoneminder-config.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zoneminder-config.cmake b/zoneminder-config.cmake index 21b99abf4..a38f73d84 100644 --- a/zoneminder-config.cmake +++ b/zoneminder-config.cmake @@ -43,7 +43,7 @@ #cmakedefine HAVE_LIBAVCODEC 1 #cmakedefine HAVE_LIBAVCODEC_AVCODEC_H 1 #cmakedefine HAVE_LIBAVDEVICE 1 -#cmakedefine HAVE_LIBAVDEVICE_AVDEVICE_H +#cmakedefine HAVE_LIBAVDEVICE_AVDEVICE_H 1 #cmakedefine HAVE_LIBAVUTIL 1 #cmakedefine HAVE_LIBAVUTIL_AVUTIL_H 1 #cmakedefine HAVE_LIBAVUTIL_MATHEMATICS_H 1 From edcca74f95a72876fa024d760e6cbd4a1f4e9c78 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Mon, 14 Oct 2013 07:58:21 +0300 Subject: [PATCH 07/29] Add detection status in cmake for optional libraries --- CMakeLists.txt | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd0b5ecac..de8bffe76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,6 +95,9 @@ if(ZLIB_FOUND) include_directories(${ZLIB_INCLUDE_DIR}) set(CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIR}) check_include_file("zlib.h" HAVE_ZLIB_H) + set(optlibsfound "${optlibsfound} ZLIB") +else(ZLIB_FOUND) + set(optlibsnotfound "${optlibsnotfound} ZLIB") endif(ZLIB_FOUND) # jpeg @@ -122,6 +125,9 @@ if(OPENSSL_FOUND) include_directories(${OPENSSL_INCLUDE_DIR}) set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) check_include_file("openssl/md5.h" HAVE_OPENSSL_MD5_H) + set(optlibsfound "${optlibsfound} OPENSSL") +else(OPENSSL_FOUND) + set(optlibsnotfound "${optlibsnotfound} OPENSSL") endif(OPENSSL_FOUND) # pthread (using find_library and find_path) @@ -155,6 +161,9 @@ if(PCRE_LIBRARIES) endif(PCRE_INCLUDE_DIR) mark_as_advanced(FORCE PCRE_LIBRARIES PCRE_INCLUDE_DIR) check_include_file("pcre.h" HAVE_PCRE_H) + set(optlibsfound "${optlibsfound} PCRE") +else(PCRE_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} PCRE") endif(PCRE_LIBRARIES) # gcrypt (using find_library and find_path) @@ -169,6 +178,9 @@ if(GCRYPT_LIBRARIES) endif(GCRYPT_INCLUDE_DIR) mark_as_advanced(FORCE GCRYPT_LIBRARIES GCRYPT_INCLUDE_DIR) check_include_file("gcrypt.h" HAVE_GCRYPT_H) + set(optlibsfound "${optlibsfound} GCRYPT") +else(GCRYPT_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} GCRYPT") endif(GCRYPT_LIBRARIES) # gnutls (using find_library and find_path) @@ -184,6 +196,9 @@ if(GNUTLS_LIBRARIES) mark_as_advanced(FORCE GNUTLS_LIBRARIES GNUTLS_INCLUDE_DIR) check_include_file("gnutls/openssl.h" HAVE_GNUTLS_OPENSSL_H) check_include_file("gnutls/gnutls.h" HAVE_GNUTLS_GNUTLS_H) + set(optlibsfound "${optlibsfound} GNUTLS") +else(GNUTLS_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} GNUTLS") endif(GNUTLS_LIBRARIES) # mysqlclient (using find_library and find_path) @@ -219,6 +234,9 @@ if(NOT ZM_NO_FFMPEG) endif(AVFORMAT_INCLUDE_DIR) mark_as_advanced(FORCE AVFORMAT_LIBRARIES AVFORMAT_INCLUDE_DIR) check_include_file("libavformat/avformat.h" HAVE_LIBAVFORMAT_AVFORMAT_H) + set(optlibsfound "${optlibsfound} AVFORMAT") + else(AVFORMAT_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} AVFORMAT") endif(AVFORMAT_LIBRARIES) # avcodec (using find_library and find_path) @@ -233,6 +251,9 @@ if(NOT ZM_NO_FFMPEG) endif(AVCODEC_INCLUDE_DIR) mark_as_advanced(FORCE AVCODEC_LIBRARIES AVCODEC_INCLUDE_DIR) check_include_file("libavcodec/avcodec.h" HAVE_LIBAVCODEC_AVCODEC_H) + set(optlibsfound "${optlibsfound} AVCODEC") + else(AVCODEC_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} AVCODEC") endif(AVCODEC_LIBRARIES) # avdevice (using find_library and find_path) @@ -247,6 +268,9 @@ if(NOT ZM_NO_FFMPEG) endif(AVDEVICE_INCLUDE_DIR) mark_as_advanced(FORCE AVDEVICE_LIBRARIES AVDEVICE_INCLUDE_DIR) check_include_file("libavdevice/avdevice.h" HAVE_LIBAVDEVICE_AVDEVICE_H) + set(optlibsfound "${optlibsfound} AVDEVICE") + else(AVDEVICE_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} AVDEVICE") endif(AVDEVICE_LIBRARIES) # avutil (using find_library and find_path) @@ -262,6 +286,9 @@ if(NOT ZM_NO_FFMPEG) mark_as_advanced(FORCE AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIR) check_include_file("libavutil/avutil.h" HAVE_LIBAVUTIL_AVUTIL_H) check_include_file("libavutil/mathematics.h" HAVE_LIBAVUTIL_MATHEMATICS_H) + set(optlibsfound "${optlibsfound} AVUTIL") + else(AVUTIL_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} AVUTIL") endif(AVUTIL_LIBRARIES) # swscale (using find_library and find_path) @@ -276,6 +303,9 @@ if(NOT ZM_NO_FFMPEG) endif(SWSCALE_INCLUDE_DIR) mark_as_advanced(FORCE SWSCALE_LIBRARIES SWSCALE_INCLUDE_DIR) check_include_file("libswscale/swscale.h" HAVE_LIBSWSCALE_SWSCALE_H) + set(optlibsfound "${optlibsfound} SWSCALE") + else(SWSCALE_LIBRARIES) + set(optlibsnotfound "${optlibsnotfound} SWSCALE") endif(SWSCALE_LIBRARIES) endif(NOT ZM_NO_FFMPEG) @@ -406,6 +436,10 @@ add_subdirectory(db) add_subdirectory(misc) add_subdirectory(web) +# Print optional libraries detection status +message(STATUS "Optional libraries found:${optlibsfound}") +message(STATUS "Optional libraries not found:${optlibsnotfound}") + # Run ZM configuration generator message(STATUS "Running ZoneMinder configuration generator") execute_process(COMMAND perl ./zmconfgen.pl RESULT_VARIABLE zmconfgen_result) From b1c76ad0b60a80a25d5fe19e11d59249a29a4ca9 Mon Sep 17 00:00:00 2001 From: Andy Bauer Date: Sat, 19 Oct 2013 08:49:47 -0500 Subject: [PATCH 08/29] Cmake support files for fedora distro --- distros/fedora/CMakeLists.txt | 42 +++++++++++++++++++++++++++++++++++ distros/fedora/jscalendar.sh | 1 + distros/redhat/jscalendar.sh | 7 ++++++ 3 files changed, 50 insertions(+) create mode 100644 distros/fedora/CMakeLists.txt create mode 120000 distros/fedora/jscalendar.sh create mode 100755 distros/redhat/jscalendar.sh diff --git a/distros/fedora/CMakeLists.txt b/distros/fedora/CMakeLists.txt new file mode 100644 index 000000000..7409a2e39 --- /dev/null +++ b/distros/fedora/CMakeLists.txt @@ -0,0 +1,42 @@ +# CMakeLists.txt for the Fedora Target Distro. + +# Download jscalendar & move files into position +file(DOWNLOAD http://downloads.sourceforge.net/jscalendar/jscalendar-1.0.zip ${CMAKE_CURRENT_SOURCE_DIR}/jscalendar-1.0.zip STATUS download_jsc) +if(download_jsc EQUAL 0) +message(STATUS "Jscalander successfully downloaded. Installing...") +execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/jscalendar.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ERROR_VARIABLE unzip_jsc) +message(STATUS "Status of jscalender script was: ${unzip_jsc}") +else(download_jsc EQUAL 0) +message(STATUS "Unable to download optional jscalander. Skipping...") +endif(download_jsc EQUAL 0) + +# Create several empty folders +file(MAKE_DIRECTORY sock swap zoneminder zoneminder-upload events images temp) + +# Install the empty folders +#install(DIRECTORY run DESTINATION /var DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_WRITE GROUP_READ GROUP_EXECUTE WORLD_WRITE WORLD_READ WORLD_EXECUTE) +install(DIRECTORY sock swap DESTINATION /var/lib/zoneminder DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +install(DIRECTORY zoneminder DESTINATION /var/log DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +install(DIRECTORY zoneminder DESTINATION /run DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +install(DIRECTORY zoneminder-upload DESTINATION /var/spool DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +install(DIRECTORY events images temp DESTINATION /var/lib/zoneminder DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + +# Create symlinks +install(CODE "execute_process(COMMAND ln -sf ../../../../var/lib/zoneminder/events \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/events\")") +install(CODE "execute_process(COMMAND ln -sf ../../../../var/lib/zoneminder/images \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/images\")") +install(CODE "execute_process(COMMAND ln -sf ../../../../var/lib/zoneminder/temp \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/temp\")") + +# Fedora requires cambozola as a separate package so just link to it +install(CODE "execute_process(COMMAND ln -sf ../../java/cambozola.jar \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/cambozola.jar\")") + +# Install auxillary files required to run zoneminder on Fedora +install(FILES zoneminder.conf DESTINATION /etc/httpd/conf.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES zoneminder.logrotate DESTINATION /etc/logrotate.d RENAME zoneminder PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES zoneminder.tmpfiles DESTINATION /etc/tmpfiles.d RENAME zoneminder.conf PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +install(FILES redalert.wav DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/sounds PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +install(FILES zoneminder.service DESTINATION /usr/lib/systemd/system PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) + +# Install jscalendar +if(unzip_jsc STREQUAL "") +install(DIRECTORY jscalendar-1.0/ DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/tools/jscalendar) +endif(unzip_jsc STREQUAL "") diff --git a/distros/fedora/jscalendar.sh b/distros/fedora/jscalendar.sh new file mode 120000 index 000000000..0d12509bb --- /dev/null +++ b/distros/fedora/jscalendar.sh @@ -0,0 +1 @@ +../redhat/jscalendar.sh \ No newline at end of file diff --git a/distros/redhat/jscalendar.sh b/distros/redhat/jscalendar.sh new file mode 100755 index 000000000..80acaafec --- /dev/null +++ b/distros/redhat/jscalendar.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +unzip -o jscalendar-1.0.zip +mkdir -v jscalendar-doc +cd jscalendar-1.0 +mv -v *html *php doc/* README ../jscalendar-doc +rmdir -v doc From 54a22e7fe8206da9791d27d2e1d31ebea150f611 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sat, 19 Oct 2013 09:22:59 -0500 Subject: [PATCH 09/29] We need a toggle for x10 support --- CMakeLists.txt | 1 + scripts/CMakeLists.txt | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index de8bffe76..f2ec6ad5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,7 @@ set(ZM_EXTRA_LIBS "" CACHE STRING "A list of optional libraries, separated by se set(ZM_MYSQL_ENGINE "InnoDB" CACHE STRING "MySQL engine to use with database, default: InnoDB") set(ZM_NO_MMAP "OFF" CACHE BOOL "Set to ON to not use mmap shared memory. Shouldn't be enabled unless you experience problems with the shared memory. default: OFF") set(ZM_NO_FFMPEG "OFF" CACHE BOOL "Set to ON to skip ffmpeg checks and force building ZM without ffmpeg. default: OFF") +set(ZM_NO_X10 "OFF" CACHE BOOL "Set to ON to build ZoneMinder without X10 support") set(ZM_PERL_SUBPREFIX "${CMAKE_INSTALL_LIBDIR}/perl5" CACHE PATH "Use a different directory for the zm perl modules. NOTE: This is a subprefix, e.g. lib will be turned into /lib, default: ${CMAKE_INSTALL_LIBDIR}/perl5") set(ZM_PERL_USE_PATH "${CMAKE_INSTALL_PREFIX}/${ZM_PERL_SUBPREFIX}" CACHE PATH "Override the include path for zm perl modules. Useful if you are moving the perl modules without using the ZM_PERL_SUBPREFIX option. default: /") # Only required for cmakecacheimport: diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 67e8a0759..f736eca9f 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -14,11 +14,16 @@ configure_file(zmtrigger.pl.in ${CMAKE_CURRENT_SOURCE_DIR}/zmtrigger.pl @ONLY) configure_file(zmupdate.pl.in ${CMAKE_CURRENT_SOURCE_DIR}/zmupdate.pl @ONLY) configure_file(zmvideo.pl.in ${CMAKE_CURRENT_SOURCE_DIR}/zmvideo.pl @ONLY) configure_file(zmwatch.pl.in ${CMAKE_CURRENT_SOURCE_DIR}/zmwatch.pl @ONLY) +if(NOT ZM_NO_X10) configure_file(zmx10.pl.in ${CMAKE_CURRENT_SOURCE_DIR}/zmx10.pl @ONLY) +endif(NOT ZM_NO_X10) #configure_file(zmdbbackup.in ${CMAKE_CURRENT_SOURCE_DIR}/zmdbbackup @ONLY) #configure_file(zmdbrestore.in ${CMAKE_CURRENT_SOURCE_DIR}/zmdbrestore @ONLY) configure_file(zm.in ${CMAKE_CURRENT_SOURCE_DIR}/zm @ONLY) #configure_file(zmeventdump.in ${CMAKE_CURRENT_SOURCE_DIR}/zmeventdump @ONLY) # Install the perl scripts -install(FILES zmaudit.pl zmcontrol.pl zmdc.pl zmfilter.pl zmpkg.pl zmtrack.pl zmtrigger.pl zmupdate.pl zmvideo.pl zmwatch.pl zmx10.pl DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +install(FILES zmaudit.pl zmcontrol.pl zmdc.pl zmfilter.pl zmpkg.pl zmtrack.pl zmtrigger.pl zmupdate.pl zmvideo.pl zmwatch.pl DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +if(NOT ZM_NO_X10) +install(FILES zmx10.pl DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +endif(NOT ZM_NO_X10) From 539c760d3c1f35f40845efbae1ef3cb08fe8430c Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sat, 19 Oct 2013 09:38:58 -0500 Subject: [PATCH 10/29] Create ZM_TARGET_DISTRO --- CMakeLists.txt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index de8bffe76..ce82ea97f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,7 @@ set(ZM_NO_MMAP "OFF" CACHE BOOL "Set to ON to not use mmap shared memory. Should set(ZM_NO_FFMPEG "OFF" CACHE BOOL "Set to ON to skip ffmpeg checks and force building ZM without ffmpeg. default: OFF") set(ZM_PERL_SUBPREFIX "${CMAKE_INSTALL_LIBDIR}/perl5" CACHE PATH "Use a different directory for the zm perl modules. NOTE: This is a subprefix, e.g. lib will be turned into /lib, default: ${CMAKE_INSTALL_LIBDIR}/perl5") set(ZM_PERL_USE_PATH "${CMAKE_INSTALL_PREFIX}/${ZM_PERL_SUBPREFIX}" CACHE PATH "Override the include path for zm perl modules. Useful if you are moving the perl modules without using the ZM_PERL_SUBPREFIX option. default: /") +set(ZM_TARGET_DISTRO "" CACHE STRING "Build ZoneMinder for a specific distribution. Currently, valid names are: f19, el6") # Only required for cmakecacheimport: set(CMAKE_INSTALL_FULL_BINDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" CACHE PATH "Override default binary directory") @@ -423,6 +424,13 @@ set(WEB_USER "${ZM_WEB_USER}") set(WEB_GROUP "${ZM_WEB_GROUP}") set(EXTRA_PERL_LIB "use lib '${ZM_PERL_USE_PATH}';") +# Reassign some variables if a target distro has been specified +if((ZM_TARGET_DISTRO STREQUAL "f19") OR (ZM_TARGET_DISTRO STREQUAL "el6")) +set(ZM_RUNDIR "/var/run/zoneminder") +set(ZM_TMPDIR "/var/lib/zoneminder/temp") +set(ZM_LOGDIR "/var/log/zoneminder") +endif((ZM_TARGET_DISTRO STREQUAL "f19") OR (ZM_TARGET_DISTRO STREQUAL "el6")) + # Generate files from the .in files configure_file(zoneminder-config.cmake config.h @ONLY) configure_file(zm.conf.in zm.conf @ONLY) @@ -433,8 +441,14 @@ configure_file(zmlinkcontent.sh.in zmlinkcontent.sh @ONLY) add_subdirectory(src) add_subdirectory(scripts) add_subdirectory(db) -add_subdirectory(misc) add_subdirectory(web) +if(ZM_TARGET_DISTRO STREQUAL "f19") +add_subdirectory(distros/fedora) +elseif(ZM_TARGET_DISTRO STREQUAL "el6") +add_subdirectory(distros/redhat) +else(ZM_TARGET_DISTRO STREQUAL "el6") +add_subdirectory(misc) +endif(ZM_TARGET_DISTRO STREQUAL "f19") # Print optional libraries detection status message(STATUS "Optional libraries found:${optlibsfound}") From 72973ff7e74c2cdbb650081197da4224df94097b Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sat, 19 Oct 2013 12:14:43 -0500 Subject: [PATCH 11/29] Add new zoneminder cmake specfile --- distros/fedora/zoneminder.cmake.f19.spec | 181 ++++++----------------- 1 file changed, 48 insertions(+), 133 deletions(-) diff --git a/distros/fedora/zoneminder.cmake.f19.spec b/distros/fedora/zoneminder.cmake.f19.spec index 4b7c94e4b..89dd96450 100644 --- a/distros/fedora/zoneminder.cmake.f19.spec +++ b/distros/fedora/zoneminder.cmake.f19.spec @@ -1,61 +1,46 @@ -%define cambrev 0.931 -%define moorev 1.3.2 -%define jscrev 1.0 - %define zmuid $(id -un) %define zmgid $(id -gn) %define zmuid_final apache %define zmgid_final apache -Name: zoneminder -Version: 1.26.4 -Release: 1%{?dist} -Summary: A camera monitoring and analysis tool -Group: System Environment/Daemons -# jscalendar is LGPL (any version): http://www.dynarch.com/projects/calendar/ +Name: zoneminder +Version: 1.26.4 +Release: 1%{?dist} +Summary: A camera monitoring and analysis tool +Group: System Environment/Daemons +# jscalendar is LGPL (any version): http://www.dynarch.com/projects/calendar/ # Mootools is inder the MIT license: http://mootools.net/ -License: GPLv2+ and LGPLv2+ and MIT -URL: http://www.zoneminder.com/ +License: GPLv2+ and LGPLv2+ and MIT +URL: http://www.zoneminder.com/ -#Source: https://github.com/ZoneMinder/ZoneMinder/archive/v%{version}.tar.gz -Source: ZoneMinder-%{version}.tar.gz -Source2: jscalendar-%{jscrev}.zip -#Source2: http://downloads.sourceforge.net/jscalendar/jscalendar-%{jscrev}.zip +#Source: https://github.com/ZoneMinder/ZoneMinder/archive/v%{version}.tar.gz +Source: ZoneMinder-%{version}.tar.gz -# Need to unravel the proper mootools files to grab from upstream, since the -# number of them keeps multiplying. In the meantime, rely on the ones bundled -# with zoneminder. As these are javascript, there is no guideline violation -# here. -#Source3: http://mootools.net/download/get/mootools-core-%{moorev}-full-compat-yc.js - -#Patch1: zoneminder-1.26.4-dbinstall.patch -Patch2: zoneminder-1.24.3-runlevel.patch -Patch3: zoneminder-1.26.0-defaults.patch +Patch1: zoneminder-1.26.0-defaults.patch # Enable this patch to disable ffmpeg support -#Patch4: zoneminder-1.26.3-noffmpeg.patch +#Patch2: zoneminder-1.26.3-noffmpeg.patch -BuildRequires: cmake gnutls-devel systemd-units -BuildRequires: libtool bzip2-devel -BuildRequires: mysql-devel pcre-devel libjpeg-devel -BuildRequires: perl(Archive::Tar) perl(Archive::Zip) -BuildRequires: perl(Date::Manip) perl(DBD::mysql) -BuildRequires: perl(ExtUtils::MakeMaker) perl(LWP::UserAgent) -BuildRequires: perl(MIME::Entity) perl(MIME::Lite) -BuildRequires: perl(PHP::Serialization) perl(Sys::Mmap) -BuildRequires: perl(Time::HiRes) perl(Net::SFTP::Foreign) -BuildRequires: perl(Expect) -BuildRequires: gcc gcc-c++ +BuildRequires: cmake gnutls-devel systemd-units bzip2-devel +BuildRequires: community-mysql-devel pcre-devel libjpeg-turbo-devel +BuildRequires: perl(Archive::Tar) perl(Archive::Zip) +BuildRequires: perl(Date::Manip) perl(DBD::mysql) +BuildRequires: perl(ExtUtils::MakeMaker) perl(LWP::UserAgent) +BuildRequires: perl(MIME::Entity) perl(MIME::Lite) +BuildRequires: perl(PHP::Serialization) perl(Sys::Mmap) +BuildRequires: perl(Time::HiRes) perl(Net::SFTP::Foreign) +BuildRequires: perl(Expect) +BuildRequires: gcc gcc-c++ # Comment out for no ffmpeg -BuildRequires: ffmpeg-devel +BuildRequires: ffmpeg-devel # Uncomment for X10 support -#BuildRequires: perl(X10::ActiveHome) perl(Astro::SunTime) +#BuildRequires: perl(X10::ActiveHome) perl(Astro::SunTime) -Requires: httpd php php-mysql cambozola -Requires: libjpeg-turbo ffmpeg -Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) -Requires: perl(DBD::mysql) perl(Archive::Tar) perl(Archive::Zip) -Requires: perl(MIME::Entity) perl(MIME::Lite) perl(Net::SMTP) perl(Net::FTP) -Requires: perl(LWP::Protocol::https) +Requires: httpd php php-mysql cambozola +Requires: libjpeg-turbo ffmpeg +Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) +Requires: perl(DBD::mysql) perl(Archive::Tar) perl(Archive::Zip) +Requires: perl(MIME::Entity) perl(MIME::Lite) perl(Net::SMTP) perl(Net::FTP) +Requires: perl(LWP::Protocol::https) Requires(post): systemd-units systemd-sysv Requires(post): /usr/bin/gpasswd @@ -75,94 +60,21 @@ too much degradation of performance. %prep %setup -q -n ZoneMinder-%{version} -# Unpack jscalendar and move some files around -%setup -q -D -T -a 2 -n ZoneMinder-%{version} -mkdir jscalendar-doc -pushd jscalendar-1.0 -mv *html *php doc/* README ../jscalendar-doc -rmdir doc -popd - -#%patch1 -p0 -b .dbinstall -%patch2 -p0 -b .runlevel -%patch3 -p0 -b .defaults -#%patch4 -p0 -b .noffmpeg - -# verify this is needed -chmod -x src/zm_event.cpp src/zm_user.h +%patch1 -p0 -b .defaults +#%patch2 -p0 -b .noffmpeg %build -%cmake . +%cmake -DZM_TARGET_DISTRO="f19" -DZM_NO_X10=ON -DZM_NO_FFMPEG=ON -DZM_PERL_SUBPREFIX="%{perl_vendorlib}" . make %{?_smp_mflags} -# cmake does this for us -#%{__perl} -pi -e 's/(ZM_WEB_USER=).*$/${1}%{zmuid_final}/;' -# -e 's/(ZM_WEB_GROUP=).*$/${1}%{zmgid_final}/;' zm.conf - %install -# TO-DO move much of this section into CMakeLists.txt -install -d %{buildroot}/%{_localstatedir}/run - export DESTDIR=%{buildroot} -#export INSTALLDIRS=vendor make install -# rm -rf %{buildroot}/%{perl_vendorarch} %{buildroot}/%{perl_archlib} - -# Move perl files into rhel compliant locations -mkdir -p %{buildroot}/%{perl_vendorlib} -mv %{buildroot}%{perl_archlib}/ZoneMinder* %{buildroot}/%{perl_vendorlib} -rm -rf %{buildroot}%{_libdir} - -# Remove misc folder -rm -rf %{buildroot}/%{_datadir}/%{name}/misc - -# Comment out for x10 support -rm -f %{buildroot}/%{_bindir}/zmx10.pl - -install -m 755 -d %{buildroot}/var/log/zoneminder -for dir in events images temp -do - install -m 755 -d %{buildroot}/var/lib/zoneminder/$dir - if [ -d %{buildroot}/%{_datadir}/zoneminder/www/$dir ]; then - rmdir %{buildroot}/%{_datadir}/zoneminder/www/$dir - fi - ln -sf ../../../../var/lib/zoneminder/$dir %{buildroot}/%{_datadir}/zoneminder/www/$dir -done -install -m 755 -d %{buildroot}/var/lib/zoneminder/sock -install -m 755 -d %{buildroot}/var/lib/zoneminder/swap -install -m 755 -d %{buildroot}/var/spool/zoneminder-upload - -install -D -m 644 distros/fedora/zoneminder.conf %{buildroot}/etc/httpd/conf.d/zoneminder.conf -install -D -m 755 distros/fedora/redalert.wav %{buildroot}/%{_datadir}/zoneminder/www/sounds/redalert.wav -install -D -m 644 distros/fedora/zoneminder.service %{buildroot}/%{_unitdir}/zoneminder.service -install -D -m 644 distros/fedora/zoneminder.logrotate %{buildroot}/etc/logrotate.d/zoneminder - -# Install jscalendar - this really should be in its own package -install -d -m 755 %{buildroot}/%{_datadir}/%{name}/www/jscalendar -cp -rp jscalendar-1.0/* %{buildroot}/%{_datadir}/zoneminder/www/jscalendar - -# Set up cambozola -pushd %{buildroot}/%{_datadir}/zoneminder/www -ln -s ../../java/cambozola.jar -popd - -# Set up mootools -pushd %{buildroot}/%{_datadir}/%{name}/www -ln -f -s tools/mootools/mootools-core-%{moorev}-yc.js mootools-core.js -ln -f -s tools/mootools/mootools-more-%{moorev}.1-yc.js mootools-more.js -popd - -# Create an entry for tmpfiles.d -install -D -m 755 distros/fedora/zoneminder.tmpfiles %{buildroot}/etc/tmpfiles.d/zoneminder.conf - -install -m 755 -d %{buildroot}/run/zoneminder - - %post if [ $1 -eq 1 ] ; then - # Initial installation + # Initial installation /bin/systemctl daemon-reload >/dev/null 2>&1 || : fi @@ -199,8 +111,8 @@ fi %files %defattr(-,root,root,-) -%doc AUTHORS COPYING README.md distros/fedora/README.Fedora jscalendar-doc -%config(noreplace) %attr(640,root,%{zmgid_final}) /etc/zm.conf +%doc AUTHORS COPYING README.md distros/fedora/README.Fedora distros/fedora/jscalendar-doc +%config %attr(640,root,%{zmgid_final}) /etc/zm.conf %config(noreplace) %attr(644,root,root) /etc/httpd/conf.d/zoneminder.conf %config(noreplace) /etc/tmpfiles.d/zoneminder.conf %config(noreplace) /etc/logrotate.d/zoneminder @@ -223,9 +135,12 @@ fi %{_bindir}/zmupdate.pl %{_bindir}/zmvideo.pl %{_bindir}/zmwatch.pl +# Uncomment this for x10 support #%{_bindir}/zmx10.pl %{perl_vendorlib}/ZoneMinder* +%{perl_vendorlib}/x86_64-linux-thread-multi/auto/ZoneMinder* +#%{perl_archlib}/ZoneMinder* %{_mandir}/man*/* %dir %{_libexecdir}/zoneminder %{_libexecdir}/zoneminder/cgi-bin @@ -261,7 +176,7 @@ fi * Mon Jan 21 2013 Adam Tkac - 1.25.0-12 - rebuild due to "jpeg8-ABI" feature drop -* Mon Jan 7 2013 Remi Collet - 1.25.0-11 +* Mon Jan 7 2013 Remi Collet - 1.25.0-11 - fix configuration file for httpd 2.4, #871502 * Fri Dec 21 2012 Adam Tkac - 1.25.0-10 @@ -338,7 +253,7 @@ fi - Bump for gnutls update. * Thu Mar 24 2011 Jason L Tibbitts III - 1.24.3-4.20110324svn3310 -- Update to latest 1.24.3 subversion. Turns out that what upstream was calling +- Update to latest 1.24.3 subversion. Turns out that what upstream was calling 1.24.3 is really just an occasionally updated devel snapshot. - Rebase various patches. @@ -366,7 +281,7 @@ fi * Wed Jun 02 2010 Marcela Maslanova - 1.24.2-5 - Mass rebuild with perl-5.12.0 -* Fri Dec 4 2009 Stepan Kasal - 1.24.2-4 +* Fri Dec 4 2009 Stepan Kasal - 1.24.2-4 - rebuild against perl 5.10.1 - use Perl vendorarch and archlib variables correctly @@ -406,10 +321,10 @@ fi * Fri Jul 11 2008 Jason L Tibbitts III - 1.23.3-1 - Initial attempt at packaging 1.23. -* Tue Jul 1 2008 Martin Ebourne - 1.22.3-15 +* Tue Jul 1 2008 Martin Ebourne - 1.22.3-15 - Add perl module compat dependency, bz #453590 -* Tue May 6 2008 Martin Ebourne - 1.22.3-14 +* Tue May 6 2008 Martin Ebourne - 1.22.3-14 - Remove default runlevel, bz #441315 * Mon Apr 28 2008 Jason L Tibbitts III - 1.22.3-13 @@ -418,13 +333,13 @@ fi * Tue Feb 19 2008 Fedora Release Engineering - 1.22.3-12 - Autorebuild for GCC 4.3 -* Thu Jan 3 2008 Martin Ebourne - 1.22.3-11 +* Thu Jan 3 2008 Martin Ebourne - 1.22.3-11 - Fix compilation on gcc 4.3 -* Thu Dec 6 2007 Martin Ebourne - 1.22.3-10 +* Thu Dec 6 2007 Martin Ebourne - 1.22.3-10 - Rebuild for new openssl -* Thu Aug 2 2007 Martin Ebourne - 1.22.3-8 +* Thu Aug 2 2007 Martin Ebourne - 1.22.3-8 - Fix licence tag * Thu Jul 12 2007 Martin Ebourne - 1.22.3-7 @@ -443,7 +358,7 @@ fi * Sun Jun 10 2007 Martin Ebourne - 1.22.3-3 - Changes recommended in review by Jason Tibbitts -* Mon Apr 2 2007 Martin Ebourne - 1.22.3-2 +* Mon Apr 2 2007 Martin Ebourne - 1.22.3-2 - Standardised on package name of zoneminder * Thu Dec 28 2006 Martin Ebourne - 1.22.3-1 From 60962566a53faaf79ce7c46ea4f484b60cface3c Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sat, 19 Oct 2013 13:50:59 -0500 Subject: [PATCH 12/29] cmake support files for redhat/centos distros --- distros/redhat/CMakeLists.txt | 57 +++++++++++ distros/redhat/cambozola.sh | 7 ++ distros/redhat/zoneminder.cmake.el6.spec | 99 ++----------------- distros/redhat/zoneminder.in | 120 +++++++++++++++++++++++ 4 files changed, 194 insertions(+), 89 deletions(-) create mode 100644 distros/redhat/CMakeLists.txt create mode 100755 distros/redhat/cambozola.sh create mode 100755 distros/redhat/zoneminder.in diff --git a/distros/redhat/CMakeLists.txt b/distros/redhat/CMakeLists.txt new file mode 100644 index 000000000..63e742d68 --- /dev/null +++ b/distros/redhat/CMakeLists.txt @@ -0,0 +1,57 @@ +# CMakeLists.txt for the Redhat/CentOS Target Distro. + +# Create the zoneminder service file +configure_file(zoneminder.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.service @ONLY) + +# Download jscalendar & move files into position +file(DOWNLOAD http://softlayer-dal.dl.sourceforge.net/project/jscalendar/jscalendar/1.0/jscalendar-1.0.zip ${CMAKE_CURRENT_SOURCE_DIR}/jscalendar-1.0.zip LOG jsc_log STATUS download_jsc) +#message(STATUS "Log of jscalender script was: ${jsc_log}") +if(download_jsc EQUAL 0) + message(STATUS "Jscalander successfully downloaded. Installing...") + execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/jscalendar.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ERROR_VARIABLE unzip_jsc) + message(STATUS "Status of jscalender script was: ${unzip_jsc}") +else(download_jsc EQUAL 0) + message(STATUS "Unable to download optional jscalander. Skipping...") +endif(download_jsc EQUAL 0) + +# Download cambozola & move files into position +file(DOWNLOAD http://www.andywilcock.com/code/cambozola/cambozola-0.931.tar.gz ${CMAKE_CURRENT_SOURCE_DIR}/cambozola-0.931.tar.gz STATUS download_camb) +if(download_camb EQUAL 0) + message(STATUS "Cambozola successfully downloaded. Installing...") + execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/cambozola.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ERROR_VARIABLE untar_camb) + message(STATUS "Status of cambozola script was: ${untar_camb}") +else(download_camb EQUAL 0) + message(STATUS "Unable to download optional Cambozola. Skipping...") +endif(download_camb EQUAL 0) + +# Create several empty folders +file(MAKE_DIRECTORY sock swap zoneminder zoneminder-upload events images temp) + +# Install the empty folders +#install(DIRECTORY run DESTINATION /var DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_WRITE GROUP_READ GROUP_EXECUTE WORLD_WRITE WORLD_READ WORLD_EXECUTE) +install(DIRECTORY sock swap DESTINATION /var/lib/zoneminder DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +install(DIRECTORY zoneminder DESTINATION /var/log DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +install(DIRECTORY zoneminder DESTINATION /run DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +install(DIRECTORY zoneminder-upload DESTINATION /var/spool DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +install(DIRECTORY events images temp DESTINATION /var/lib/zoneminder DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + +# Create symlinks +install(CODE "execute_process(COMMAND ln -sf ../../../../var/lib/zoneminder/events \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/events\")") +install(CODE "execute_process(COMMAND ln -sf ../../../../var/lib/zoneminder/images \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/images\")") +install(CODE "execute_process(COMMAND ln -sf ../../../../var/lib/zoneminder/temp \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/temp\")") + +# Install auxillary files required to run zoneminder on CentOS +install(FILES zoneminder.conf DESTINATION /etc/httpd/conf.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES zm-logrotate_d DESTINATION /etc/logrotate.d RENAME zoneminder PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES redalert.wav DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/sounds PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +install(FILES zoneminder.service DESTINATION /etc/rc.d/init.d RENAME zoneminder PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) + +# Install jscalendar +if(unzip_jsc STREQUAL "") + install(DIRECTORY jscalendar-1.0/ DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/tools/jscalendar) +endif(unzip_jsc STREQUAL "") + +# Install cambozola +if(untar_camb STREQUAL "") + install(FILES cambozola-0.931/dist/cambozola.jar DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www) +endif(untar_camb STREQUAL "") diff --git a/distros/redhat/cambozola.sh b/distros/redhat/cambozola.sh new file mode 100755 index 000000000..645c5aa77 --- /dev/null +++ b/distros/redhat/cambozola.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +tar -xvzf cambozola-0.931.tar.gz +mkdir -v cambozola-doc +cd cambozola-0.931 +mv -v application.properties build.xml dist.sh *html LICENSE testPages/* ../cambozola-doc +rmdir -v testPages diff --git a/distros/redhat/zoneminder.cmake.el6.spec b/distros/redhat/zoneminder.cmake.el6.spec index e1f34d985..acb798701 100644 --- a/distros/redhat/zoneminder.cmake.el6.spec +++ b/distros/redhat/zoneminder.cmake.el6.spec @@ -1,7 +1,3 @@ -%define cambrev 0.931 -%define moorev 1.3.2 -%define jscrev 1.0 - %define zmuid $(id -un) %define zmgid $(id -gn) %define zmuid_final apache @@ -20,23 +16,10 @@ URL: http://www.zoneminder.com/ #Source0: https://github.com/ZoneMinder/ZoneMinder/archive/v%{version}.tar.gz Source0: ZoneMinder-%{version}.tar.gz -Source1: jscalendar-%{jscrev}.zip -#Source1: http://downloads.sourceforge.net/jscalendar/jscalendar-%{jscrev}.zip -# Mootools is currently bundled in the zoneminder tarball -#Source2: mootools-core-%{moorev}-full-compat-yc.js -#Source2: http://mootools.net/download/get/mootools-core-%{moorev}-full-compat-yc.js +Patch1: zoneminder-1.26.0-defaults.patch -Source3: cambozola-%{cambrev}.tar.gz -#Source3: http://www.andywilcock.com/code/cambozola/cambozola-%{cambrev}.tar.gz - -Patch1: zoneminder-runlevel.patch -Patch2: zoneminder-1.26.0-defaults.patch - -# BuildRoot is depreciated and ignored -#BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) - -BuildRequires: automake gnutls-devel bzip2-devel libtool +BuildRequires: cmake gnutls-devel bzip2-devel BuildRequires: mysql-devel pcre-devel libjpeg-turbo-devel BuildRequires: perl(Archive::Tar) perl(Archive::Zip) BuildRequires: perl(Date::Manip) perl(DBD::mysql) @@ -78,86 +61,19 @@ too much degradation of performance. %prep %setup -q -n ZoneMinder-%{version} -# Unpack jscalendar and move some files around -%setup -q -D -T -a 1 -n ZoneMinder-%{version} -mkdir jscalendar-doc -pushd jscalendar-%{jscrev} -mv *html *php doc/* README ../jscalendar-doc -rmdir doc -popd - -# Unpack Cambozola and move some files around -%setup -q -D -T -a 3 -n ZoneMinder-%{version} -mkdir cambozola-doc -pushd cambozola-%{cambrev} -mv application.properties build.xml dist.sh *html LICENSE testPages/* ../cambozola-doc -rmdir testPages -popd - -%patch1 -p0 -b .runlevel -%patch2 -p0 +%patch1 -p0 -b .defaults %build # Have to override CMAKE_INSTALL_LIBDIR for cmake < 2.8.7 due to this bug: # https://bugzilla.redhat.com/show_bug.cgi?id=795542 -%cmake -DCMAKE_INSTALL_LIBDIR:PATH=%{_lib} . +%cmake -DZM_TARGET_DISTRO="el6" -DCMAKE_INSTALL_LIBDIR:PATH=%{_lib} -DZM_PERL_SUBPREFIX="%{perl_vendorlib}" . make %{?_smp_mflags} -# cmake does this for us -#%{__perl} -pi -e 's/(ZM_WEB_USER=).*$/${1}%{zmuid_final}/;' -# -e 's/(ZM_WEB_GROUP=).*$/${1}%{zmgid_final}/;' zm.conf - %install -install -d %{buildroot}/%{_localstatedir}/run -install -d %{buildroot}/etc/logrotate.d - export DESTDIR=%{buildroot} -#export INSTALLDIRS=vendor make install -# Move perl files into rhel compliant locations -mkdir -p %{buildroot}/%{perl_vendorlib} -mv %{buildroot}%{perl_archlib}/ZoneMinder* %{buildroot}/%{perl_vendorlib} -rm -rf %{buildroot}%{_libdir} - -# Remove misc folder -rm -rf %{buildroot}/%{_datadir}/%{name}/misc - -install -m 755 -d %{buildroot}/%{_localstatedir}/log/zoneminder -for dir in events images temp -do - install -m 755 -d %{buildroot}/%{_localstatedir}/lib/zoneminder/$dir - if [ -d %{buildroot}/%{_datadir}/zoneminder/www/$dir ]; then - rmdir %{buildroot}/%{_datadir}/%{name}/www/$dir - fi - ln -sf ../../../..%{_localstatedir}/lib/zoneminder/$dir %{buildroot}/%{_datadir}/%{name}/www/$dir -done -install -m 755 -d %{buildroot}/%{_localstatedir}/lib/zoneminder/sock -install -m 755 -d %{buildroot}/%{_localstatedir}/lib/zoneminder/swap -install -m 755 -d %{buildroot}/%{_localstatedir}/spool/zoneminder-upload - -install -D -m 755 scripts/zm %{buildroot}/%{_initrddir}/zoneminder -install -D -m 644 distros/redhat/zoneminder.conf %{buildroot}/%{_sysconfdir}/httpd/conf.d/zoneminder.conf -install -D -m 755 distros/redhat/redalert.wav %{buildroot}/%{_datadir}/%{name}/www/sounds/redalert.wav -install distros/redhat/zm-logrotate_d $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/%{name} - -# Install jscalendar -install -d -m 755 %{buildroot}/%{_datadir}/%{name}/www/jscalendar -cp -rp jscalendar-%{jscrev}/* %{buildroot}/%{_datadir}/%{name}/www/jscalendar - -# Install Cambozola -cp -rp cambozola-%{cambrev}/dist/cambozola.jar %{buildroot}/%{_datadir}/%{name}/www/ -rm -rf cambozola-%{cambrev} - -# Install mootools -pushd %{buildroot}/%{_datadir}/%{name}/www -#install -m 644 %{Source2} mootools-core-%{moorev}-full-compat-yc.js -#ln -s mootools-core-%{moorev}-full-compat-yc.js mootools.js -ln -f -s tools/mootools/mootools-core-%{moorev}-yc.js mootools-core.js -ln -f -s tools/mootools/mootools-more-%{moorev}.1-yc.js mootools-more.js -popd - %post /sbin/chkconfig --add zoneminder /sbin/chkconfig zoneminder on @@ -194,7 +110,8 @@ rm -rf %{_docdir}/%{name}-%{version} %files %defattr(-,root,root,-) -%doc AUTHORS BUGS ChangeLog COPYING LICENSE NEWS README.md distros/redhat/README.CentOS jscalendar-doc cambozola-doc distros/redhat/local_zoneminder.te +%doc AUTHORS BUGS ChangeLog COPYING LICENSE NEWS README.md distros/redhat/README.CentOS distros/redhat/jscalendar-doc +%doc distros/redhat/cambozola-doc distros/redhat/local_zoneminder.te %config(noreplace) %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm.conf %config(noreplace) %attr(644,root,root) %{_sysconfdir}/httpd/conf.d/zoneminder.conf %config(noreplace) /etc/logrotate.d/%{name} @@ -219,6 +136,7 @@ rm -rf %{_docdir}/%{name}-%{version} %{_bindir}/zmx10.pl %{perl_vendorlib}/ZoneMinder* +%{perl_vendorlib}/x86_64-linux-thread-multi/auto/ZoneMinder* %{_mandir}/man*/* %dir %{_libexecdir}/%{name} %{_libexecdir}/%{name}/cgi-bin @@ -237,6 +155,9 @@ rm -rf %{_docdir}/%{name}-%{version} %changelog +* Sat Oct 19 2013 Andrew Bauer - 1.26.4 +- Streamline the cmake build. Move much code into cmakelist.txt file. + * Mon Oct 07 2013 Andrew Bauer - 1.26.4 - Initial cmake build. diff --git a/distros/redhat/zoneminder.in b/distros/redhat/zoneminder.in new file mode 100755 index 000000000..c46d4b164 --- /dev/null +++ b/distros/redhat/zoneminder.in @@ -0,0 +1,120 @@ +#!/bin/sh +# description: ZoneMinder is the top Linux video camera security and surveillance solution. ZoneMinder is intended for use in single or multi-camera video security applications.Copyright: Philip Coombes, Corey DeLasaux 2003-2008 +# chkconfig: 2345 99 00 +# processname: zmpkg.pl + +# Source function library. +. /etc/rc.d/init.d/functions + +prog=ZoneMinder +ZM_CONFIG="@ZM_CONFIG@" +pidfile="@ZM_RUNDIR@" +LOCKFILE=/var/lock/subsys/zm + +loadconf() +{ + if [ -f $ZM_CONFIG ]; then + . $ZM_CONFIG + else + echo "ERROR: $ZM_CONFIG not found." + return 1 + fi +} + +loadconf +command="$ZM_PATH_BIN/zmpkg.pl" + +start() +{ + zmupdate || return $? + loadconf || return $? + #Make sure the directory for our PID folder exists or create one. + [ ! -d $pidfile ] \ + && mkdir -m 774 $pidfile \ + && chown $ZM_WEB_USER:$ZM_WEB_GROUP $pidfile + #Make sure the folder for the socks file exists or create one + GetPath="select Value from Config where Name='ZM_PATH_SOCKS'" + dbHost=`echo $ZM_DB_HOST | cut -d: -f1` + dbPort=`echo $ZM_DB_HOST | cut -d: -s -f2` + if [ "$dbPort" = "" ] + then + ZM_PATH_SOCK=`echo $GetPath | mysql -B -h$ZM_DB_HOST -u$ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'` + else + ZM_PATH_SOCK=`echo $GetPath | mysql -B -h$dbHost -P$dbPort -u$ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'` + fi + [ ! -d $ZM_PATH_SOCK ] \ + && mkdir -m 774 $ZM_PATH_SOCK \ + && chown $ZM_WEB_USER:$ZM_WEB_GROUP $ZM_PATH_SOCK + echo -n $"Starting $prog: " + $command start + RETVAL=$? + [ $RETVAL = 0 ] && success || failure + echo + [ $RETVAL = 0 ] && touch $LOCKFILE + return $RETVAL +} + +stop() +{ + loadconf + echo -n $"Stopping $prog: " + $command stop + RETVAL=$? + [ $RETVAL = 0 ] && success || failure + echo + [ $RETVAL = 0 ] && rm -f $LOCKFILE +} + +zmstatus() +{ + loadconf + result=`$command status` + if [ "$result" = "running" ]; then + echo "ZoneMinder is running" + $ZM_PATH_BIN/zmu -l + RETVAL=0 + else + echo "ZoneMinder is stopped" + RETVAL=1 + fi +} + +zmupdate() +{ + if [ -x $ZM_PATH_BIN/zmupdate.pl ]; then + $ZM_PATH_BIN/zmupdate.pl -f + fi +} + + +case "$1" in + 'start') + start + ;; + 'stop') + stop + ;; + 'restart') + stop + start + ;; + 'condrestart') + loadconf + result=`$ZM_PATH_BIN/zmdc.pl check` + if [ "$result" = "running" ]; then + $ZM_PATH_BIN/zmdc.pl shutdown > /dev/null + rm -f $LOCKFILE + start + fi + ;; + 'status') + status httpd + status mysqld + zmstatus + ;; + *) + echo "Usage: $0 { start | stop | restart | condrestart | status }" + RETVAL=1 + ;; +esac +exit $RETVAL From d544a92ccbeb6f21a34cb2af74703fa6b408af72 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sat, 19 Oct 2013 13:54:25 -0500 Subject: [PATCH 13/29] change chkconfig default --- distros/redhat/zoneminder.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distros/redhat/zoneminder.in b/distros/redhat/zoneminder.in index c46d4b164..6fb4fef6b 100755 --- a/distros/redhat/zoneminder.in +++ b/distros/redhat/zoneminder.in @@ -1,6 +1,6 @@ #!/bin/sh # description: ZoneMinder is the top Linux video camera security and surveillance solution. ZoneMinder is intended for use in single or multi-camera video security applications.Copyright: Philip Coombes, Corey DeLasaux 2003-2008 -# chkconfig: 2345 99 00 +# chkconfig: - 99 00 # processname: zmpkg.pl # Source function library. From 183ce4b422658c64373fa76b5ece5bf033a397c2 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sun, 20 Oct 2013 12:44:09 -0500 Subject: [PATCH 14/29] Update zoneminder.cmake.el6.spec We need to strip the prefix from perl_vendorlib macro before passing it to cmake. --- distros/redhat/zoneminder.cmake.el6.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distros/redhat/zoneminder.cmake.el6.spec b/distros/redhat/zoneminder.cmake.el6.spec index acb798701..73d5bf682 100644 --- a/distros/redhat/zoneminder.cmake.el6.spec +++ b/distros/redhat/zoneminder.cmake.el6.spec @@ -66,7 +66,7 @@ too much degradation of performance. %build # Have to override CMAKE_INSTALL_LIBDIR for cmake < 2.8.7 due to this bug: # https://bugzilla.redhat.com/show_bug.cgi?id=795542 -%cmake -DZM_TARGET_DISTRO="el6" -DCMAKE_INSTALL_LIBDIR:PATH=%{_lib} -DZM_PERL_SUBPREFIX="%{perl_vendorlib}" . +%cmake -DZM_TARGET_DISTRO="el6" -DCMAKE_INSTALL_LIBDIR:PATH=%{_lib} -DZM_PERL_SUBPREFIX=`x="%{perl_vendorlib}" ; echo ${x#"%{_prefix}"}` . make %{?_smp_mflags} From c25a7ffc99d1d6ee423f6c7e784fd8b378827a2d Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sun, 20 Oct 2013 12:59:31 -0500 Subject: [PATCH 15/29] Update zoneminder.cmake.f19.spec We need to strip the prefix from perl_vendorlib before passing it to cmake --- distros/fedora/zoneminder.cmake.f19.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distros/fedora/zoneminder.cmake.f19.spec b/distros/fedora/zoneminder.cmake.f19.spec index 89dd96450..19056a361 100644 --- a/distros/fedora/zoneminder.cmake.f19.spec +++ b/distros/fedora/zoneminder.cmake.f19.spec @@ -64,7 +64,7 @@ too much degradation of performance. #%patch2 -p0 -b .noffmpeg %build -%cmake -DZM_TARGET_DISTRO="f19" -DZM_NO_X10=ON -DZM_NO_FFMPEG=ON -DZM_PERL_SUBPREFIX="%{perl_vendorlib}" . +%cmake -DZM_TARGET_DISTRO="f19" -DZM_NO_X10=ON -DZM_NO_FFMPEG=ON -DZM_PERL_SUBPREFIX=`x="%{perl_vendorlib}" ; echo ${x#"%{_prefix}"}` . make %{?_smp_mflags} From f5f573af930beb944d6eb4a8cdd5a5a87126328f Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Mon, 21 Oct 2013 16:11:37 +0300 Subject: [PATCH 16/29] Added an uninstall target to cmake and few text corrections to the INSTALL file --- CMakeLists.txt | 28 +++++++++++++++++++--------- INSTALL | 19 +++++++++++++------ cmake/cmake_uninstall.cmake.in | 26 ++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 cmake/cmake_uninstall.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ce3bc444..f5142976f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ include (CheckTypeSize) include (CheckStructHasMember) # Configuration options -mark_as_advanced(FORCE ZM_EXTRA_LIBS ZM_MYSQL_ENGINE ZM_NO_MMAP CMAKE_INSTALL_FULL_BINDIR ZM_PERL_SUBPREFIX ZM_PERL_USE_PATH) +mark_as_advanced(FORCE ZM_EXTRA_LIBS ZM_MYSQL_ENGINE ZM_NO_MMAP CMAKE_INSTALL_FULL_BINDIR ZM_PERL_SUBPREFIX ZM_PERL_USE_PATH ZM_TARGET_DISTRO) set(ZM_RUNDIR "/var/run/zm" CACHE PATH "Location of transient process files, default: /var/run/zm") set(ZM_TMPDIR "/tmp/zm" CACHE PATH "Location of temporary files, default: /tmp/zm") set(ZM_LOGDIR "/var/log/zm" CACHE PATH "Location of generated log files, default: /var/log/zm") @@ -57,9 +57,9 @@ set(ZM_EXTRA_LIBS "" CACHE STRING "A list of optional libraries, separated by se set(ZM_MYSQL_ENGINE "InnoDB" CACHE STRING "MySQL engine to use with database, default: InnoDB") set(ZM_NO_MMAP "OFF" CACHE BOOL "Set to ON to not use mmap shared memory. Shouldn't be enabled unless you experience problems with the shared memory. default: OFF") set(ZM_NO_FFMPEG "OFF" CACHE BOOL "Set to ON to skip ffmpeg checks and force building ZM without ffmpeg. default: OFF") -set(ZM_NO_X10 "OFF" CACHE BOOL "Set to ON to build ZoneMinder without X10 support") +set(ZM_NO_X10 "OFF" CACHE BOOL "Set to ON to build ZoneMinder without X10 support. default: OFF") set(ZM_PERL_SUBPREFIX "${CMAKE_INSTALL_LIBDIR}/perl5" CACHE PATH "Use a different directory for the zm perl modules. NOTE: This is a subprefix, e.g. lib will be turned into /lib, default: ${CMAKE_INSTALL_LIBDIR}/perl5") -set(ZM_PERL_USE_PATH "${CMAKE_INSTALL_PREFIX}/${ZM_PERL_SUBPREFIX}" CACHE PATH "Override the include path for zm perl modules. Useful if you are moving the perl modules without using the ZM_PERL_SUBPREFIX option. default: /") +set(ZM_PERL_USE_PATH "${CMAKE_INSTALL_PREFIX}/${ZM_PERL_SUBPREFIX}" CACHE PATH "Override the include path for zm perl modules. Useful if you are moving the perl modules without using the ZM_PERL_SUBPREFIX option. default: /") set(ZM_TARGET_DISTRO "" CACHE STRING "Build ZoneMinder for a specific distribution. Currently, valid names are: f19, el6") # Only required for cmakecacheimport: set(CMAKE_INSTALL_FULL_BINDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" CACHE PATH "Override default binary directory") @@ -427,9 +427,9 @@ set(EXTRA_PERL_LIB "use lib '${ZM_PERL_USE_PATH}';") # Reassign some variables if a target distro has been specified if((ZM_TARGET_DISTRO STREQUAL "f19") OR (ZM_TARGET_DISTRO STREQUAL "el6")) -set(ZM_RUNDIR "/var/run/zoneminder") -set(ZM_TMPDIR "/var/lib/zoneminder/temp") -set(ZM_LOGDIR "/var/log/zoneminder") + set(ZM_RUNDIR "/var/run/zoneminder") + set(ZM_TMPDIR "/var/lib/zoneminder/temp") + set(ZM_LOGDIR "/var/log/zoneminder") endif((ZM_TARGET_DISTRO STREQUAL "f19") OR (ZM_TARGET_DISTRO STREQUAL "el6")) # Generate files from the .in files @@ -443,12 +443,14 @@ add_subdirectory(src) add_subdirectory(scripts) add_subdirectory(db) add_subdirectory(web) + +# Process misc subdirectories if(ZM_TARGET_DISTRO STREQUAL "f19") -add_subdirectory(distros/fedora) + add_subdirectory(distros/fedora) elseif(ZM_TARGET_DISTRO STREQUAL "el6") -add_subdirectory(distros/redhat) + add_subdirectory(distros/redhat) else(ZM_TARGET_DISTRO STREQUAL "el6") -add_subdirectory(misc) + add_subdirectory(misc) endif(ZM_TARGET_DISTRO STREQUAL "f19") # Print optional libraries detection status @@ -467,3 +469,11 @@ endif(zmconfgen_result EQUAL 0) # Install zm.conf install(FILES zm.conf DESTINATION "/${CMAKE_INSTALL_SYSCONFDIR}") +# Uninstall target +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake" + IMMEDIATE @ONLY) +add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake) + diff --git a/INSTALL b/INSTALL index dce0adbd1..4b602b6b2 100644 --- a/INSTALL +++ b/INSTALL @@ -19,7 +19,6 @@ Important differences * Unlike the autotools way, the cmake way does not require any options. It attempts to detect some things by its own (system directories, libarch, web user and group) and uses defaults for others (installation paths and such). * Unlike the autotools way, which links the binaries to a fixed list of libraries, the cmake way only links to libraries that it found on the system. If a library is not found, but required, a fatal error will be shown during the configuration step. * Unlike the autotools way, the cmake way does not modify the system in any way it shouldnt. It only does what its supposed to do: Install files to your system. Nothing else and nothing leaks out of the DESTDIR environment variable (if used). This means that depending on your configuration, there might be an extra required step after installation: to link WEB_PATH/events and WEB_PATH/images folders to the correct places. -* Currently there is no "make uninstall" target for cmake. However, its possible to do this manually. The file install_manifest.txt contains the list of files installed to the system. This can be used in many ways to delete all files installed by cmake, such as: xargs rm < install_manifest.txt Configuration ------------- @@ -49,17 +48,20 @@ Advanced: ZM_MYSQL_ENGINE MySQL engine to use with database, default: InnoDB ZM_NO_MMAP Set to ON to not use mmap shared memory. Shouldn't be enabled unless you experience problems with the shared memory. default: OFF ZM_NO_FFMPEG Set to ON to skip ffmpeg checks and force building ZM without ffmpeg. default: OFF + ZM_NO_X10 Set to ON to build ZoneMinder without X10 support. default: OFF ZM_PERL_SUBPREFIX Use a different directory for the zm perl modules. NOTE: This is a subprefix, e.g. lib will be turned into /lib, default: /perl5 - ZM_PERL_USE_PATH Override the include path for zm perl modules. Useful if you are moving the perl modules without using the ZM_PERL_SUBPREFIX option. default: / + ZM_PERL_USE_PATH Override the include path for zm perl modules. Useful if you are moving the perl modules without using the ZM_PERL_SUBPREFIX option. default: / Useful configuration options provided by cmake: CMAKE_VERBOSE_MAKEFILE - Set this to ON (default OFF) to see what cmake is doing. Very useful for troubleshooting. CMAKE_BUILD_TYPE - Set this to Debug (default Release) to build ZoneMinder with debugging enabled. CMAKE_INSTALL_PREFIX - Use this to change the prefix (default /usr/local). This option behaves like --prefix from autoconf. Package maintainers will probably want to set this to "/usr". -CMAKE_INCLUDE_PATH - Use this to change the include search path. -CMAKE_LIBRARY_PATH - Use this to change the library search path. -Also see CMAKE_PREFIX_PATH for overriding both and some others. + +Useful environment variables provided by cmake: +CMAKE_INCLUDE_PATH - Use this to add to the include search path. +CMAKE_LIBRARY_PATH - Use this to add to the library search path. +CMAKE_PREFIX_PATH - Use this to add to both include and library search paths. /include will be added to the include search path and /lib to the library search path. Multiple paths can be specified, separated by a : character. For example: export CMAKE_PREFIX_PATH="/opt/libjpeg-turbo:/opt/ffmpeg-from-git" CFLAGS, CPPFLAGS and other environment variables: To append to the CFLAGS and CXXFLAGS, please use the CFLAGS and CXXFLAGS environment variables. @@ -69,7 +71,7 @@ To replace the CFLAGS and CXXFLAGS entirely: * For the Debug build type: use CMAKE_C_FLAGS_DEBUG for the CFLAGS and CMAKE_CXX_FLAGS_DEBUG for the CXXFLAGS Other important environment variables (such as LDFLAGS) are also supported. -The DESTDIR environment variable is also supported. +The DESTDIR environment variable is also supported, however it needs to be set by invoking cmake. For example: DESTDIR=mydestdir cmake [extra options] . For more information about DESTDIR, see: * http://www.gnu.org/prep/standards/html_node/DESTDIR.html @@ -107,6 +109,11 @@ By default, the content directory for new installations is /var/lib/zoneminder. 5) Run zmupdate.pl to update the database layout to the new version. +Uninstallation: +--------------- +By default, cmake does not have an uninstall target, however we have added a one. Simply run make uninstall (or DESTDIR=mydestdir make uninstall if a DESTDIR was used) and it will remove all the files that cmake installed. +It's also possible to do this manually. The file install_manifest.txt contains the list of files installed to the system. This can be used in many ways to delete all files installed by cmake, such as: xargs rm < install_manifest.txt + Contributions: -------------- Please visit our GitHub at http://github.com/ZoneMinder/ZoneMinder diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in new file mode 100644 index 000000000..c869827cc --- /dev/null +++ b/cmake/cmake_uninstall.cmake.in @@ -0,0 +1,26 @@ +if(POLICY CMP0007) + cmake_policy(SET CMP0007 OLD) +endif(POLICY CMP0007) + +if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") +endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + +file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +list(REVERSE files) +foreach (file ${files}) + message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + if (EXISTS "$ENV{DESTDIR}${file}") + execute_process( + COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}" + OUTPUT_VARIABLE rm_out + RESULT_VARIABLE rm_retval + ) + if(NOT ${rm_retval} EQUAL 0) + message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + endif (NOT ${rm_retval} EQUAL 0) + else (EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") + endif (EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) From c2477eb6611ad85e03af82b33c8bdbc11582da90 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Mon, 21 Oct 2013 17:13:07 +0300 Subject: [PATCH 17/29] cmake text improvements --- CMakeLists.txt | 36 ++++++++++++++++++------------------ INSTALL | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5142976f..15693ffbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,9 +97,9 @@ if(ZLIB_FOUND) include_directories(${ZLIB_INCLUDE_DIR}) set(CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIR}) check_include_file("zlib.h" HAVE_ZLIB_H) - set(optlibsfound "${optlibsfound} ZLIB") + set(optlibsfound "${optlibsfound} zlib") else(ZLIB_FOUND) - set(optlibsnotfound "${optlibsnotfound} ZLIB") + set(optlibsnotfound "${optlibsnotfound} zlib") endif(ZLIB_FOUND) # jpeg @@ -127,9 +127,9 @@ if(OPENSSL_FOUND) include_directories(${OPENSSL_INCLUDE_DIR}) set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) check_include_file("openssl/md5.h" HAVE_OPENSSL_MD5_H) - set(optlibsfound "${optlibsfound} OPENSSL") + set(optlibsfound "${optlibsfound} OpenSSL") else(OPENSSL_FOUND) - set(optlibsnotfound "${optlibsnotfound} OPENSSL") + set(optlibsnotfound "${optlibsnotfound} OpenSSL") endif(OPENSSL_FOUND) # pthread (using find_library and find_path) @@ -180,9 +180,9 @@ if(GCRYPT_LIBRARIES) endif(GCRYPT_INCLUDE_DIR) mark_as_advanced(FORCE GCRYPT_LIBRARIES GCRYPT_INCLUDE_DIR) check_include_file("gcrypt.h" HAVE_GCRYPT_H) - set(optlibsfound "${optlibsfound} GCRYPT") + set(optlibsfound "${optlibsfound} GCrypt") else(GCRYPT_LIBRARIES) - set(optlibsnotfound "${optlibsnotfound} GCRYPT") + set(optlibsnotfound "${optlibsnotfound} GCrypt") endif(GCRYPT_LIBRARIES) # gnutls (using find_library and find_path) @@ -198,9 +198,9 @@ if(GNUTLS_LIBRARIES) mark_as_advanced(FORCE GNUTLS_LIBRARIES GNUTLS_INCLUDE_DIR) check_include_file("gnutls/openssl.h" HAVE_GNUTLS_OPENSSL_H) check_include_file("gnutls/gnutls.h" HAVE_GNUTLS_GNUTLS_H) - set(optlibsfound "${optlibsfound} GNUTLS") + set(optlibsfound "${optlibsfound} GnuTLS") else(GNUTLS_LIBRARIES) - set(optlibsnotfound "${optlibsnotfound} GNUTLS") + set(optlibsnotfound "${optlibsnotfound} GnuTLS") endif(GNUTLS_LIBRARIES) # mysqlclient (using find_library and find_path) @@ -236,9 +236,9 @@ if(NOT ZM_NO_FFMPEG) endif(AVFORMAT_INCLUDE_DIR) mark_as_advanced(FORCE AVFORMAT_LIBRARIES AVFORMAT_INCLUDE_DIR) check_include_file("libavformat/avformat.h" HAVE_LIBAVFORMAT_AVFORMAT_H) - set(optlibsfound "${optlibsfound} AVFORMAT") + set(optlibsfound "${optlibsfound} AVFormat") else(AVFORMAT_LIBRARIES) - set(optlibsnotfound "${optlibsnotfound} AVFORMAT") + set(optlibsnotfound "${optlibsnotfound} AVFormat") endif(AVFORMAT_LIBRARIES) # avcodec (using find_library and find_path) @@ -253,9 +253,9 @@ if(NOT ZM_NO_FFMPEG) endif(AVCODEC_INCLUDE_DIR) mark_as_advanced(FORCE AVCODEC_LIBRARIES AVCODEC_INCLUDE_DIR) check_include_file("libavcodec/avcodec.h" HAVE_LIBAVCODEC_AVCODEC_H) - set(optlibsfound "${optlibsfound} AVCODEC") + set(optlibsfound "${optlibsfound} AVCodec") else(AVCODEC_LIBRARIES) - set(optlibsnotfound "${optlibsnotfound} AVCODEC") + set(optlibsnotfound "${optlibsnotfound} AVCodec") endif(AVCODEC_LIBRARIES) # avdevice (using find_library and find_path) @@ -270,9 +270,9 @@ if(NOT ZM_NO_FFMPEG) endif(AVDEVICE_INCLUDE_DIR) mark_as_advanced(FORCE AVDEVICE_LIBRARIES AVDEVICE_INCLUDE_DIR) check_include_file("libavdevice/avdevice.h" HAVE_LIBAVDEVICE_AVDEVICE_H) - set(optlibsfound "${optlibsfound} AVDEVICE") + set(optlibsfound "${optlibsfound} AVDevice") else(AVDEVICE_LIBRARIES) - set(optlibsnotfound "${optlibsnotfound} AVDEVICE") + set(optlibsnotfound "${optlibsnotfound} AVDevice") endif(AVDEVICE_LIBRARIES) # avutil (using find_library and find_path) @@ -288,9 +288,9 @@ if(NOT ZM_NO_FFMPEG) mark_as_advanced(FORCE AVUTIL_LIBRARIES AVUTIL_INCLUDE_DIR) check_include_file("libavutil/avutil.h" HAVE_LIBAVUTIL_AVUTIL_H) check_include_file("libavutil/mathematics.h" HAVE_LIBAVUTIL_MATHEMATICS_H) - set(optlibsfound "${optlibsfound} AVUTIL") + set(optlibsfound "${optlibsfound} AVUtil") else(AVUTIL_LIBRARIES) - set(optlibsnotfound "${optlibsnotfound} AVUTIL") + set(optlibsnotfound "${optlibsnotfound} AVUtil") endif(AVUTIL_LIBRARIES) # swscale (using find_library and find_path) @@ -305,9 +305,9 @@ if(NOT ZM_NO_FFMPEG) endif(SWSCALE_INCLUDE_DIR) mark_as_advanced(FORCE SWSCALE_LIBRARIES SWSCALE_INCLUDE_DIR) check_include_file("libswscale/swscale.h" HAVE_LIBSWSCALE_SWSCALE_H) - set(optlibsfound "${optlibsfound} SWSCALE") + set(optlibsfound "${optlibsfound} SWScale") else(SWSCALE_LIBRARIES) - set(optlibsnotfound "${optlibsnotfound} SWSCALE") + set(optlibsnotfound "${optlibsnotfound} SWScale") endif(SWSCALE_LIBRARIES) endif(NOT ZM_NO_FFMPEG) diff --git a/INSTALL b/INSTALL index 4b602b6b2..a175fc764 100644 --- a/INSTALL +++ b/INSTALL @@ -71,7 +71,7 @@ To replace the CFLAGS and CXXFLAGS entirely: * For the Debug build type: use CMAKE_C_FLAGS_DEBUG for the CFLAGS and CMAKE_CXX_FLAGS_DEBUG for the CXXFLAGS Other important environment variables (such as LDFLAGS) are also supported. -The DESTDIR environment variable is also supported, however it needs to be set by invoking cmake. For example: DESTDIR=mydestdir cmake [extra options] . +The DESTDIR environment variable is also supported, however it needs to be set before invoking cmake. For example: DESTDIR=mydestdir cmake [extra options] . For more information about DESTDIR, see: * http://www.gnu.org/prep/standards/html_node/DESTDIR.html From 54512ff6b358d203d0f9a6508bb7d59d9415c505 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Thu, 24 Oct 2013 15:36:32 +0300 Subject: [PATCH 18/29] Fixed a mistake in the INSTALL file --- INSTALL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index a175fc764..e8e9569d1 100644 --- a/INSTALL +++ b/INSTALL @@ -71,7 +71,7 @@ To replace the CFLAGS and CXXFLAGS entirely: * For the Debug build type: use CMAKE_C_FLAGS_DEBUG for the CFLAGS and CMAKE_CXX_FLAGS_DEBUG for the CXXFLAGS Other important environment variables (such as LDFLAGS) are also supported. -The DESTDIR environment variable is also supported, however it needs to be set before invoking cmake. For example: DESTDIR=mydestdir cmake [extra options] . +The DESTDIR environment variable is also supported, however it needs to be set before invoking make install. For example: DESTDIR=mydestdir make install For more information about DESTDIR, see: * http://www.gnu.org/prep/standards/html_node/DESTDIR.html From 79c7a1b255716ff96036647ce9928207ea6cea25 Mon Sep 17 00:00:00 2001 From: David Nesting Date: Sat, 26 Oct 2013 18:41:12 -0700 Subject: [PATCH 19/29] Apply INSERTs in Event::AddFrames in batches to avoid excessive query length --- src/zm_config.h.in | 1 + src/zm_event.cpp | 9 ++++++++- src/zm_event.h | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/zm_config.h.in b/src/zm_config.h.in index 01098c90f..1df1edf16 100644 --- a/src/zm_config.h.in +++ b/src/zm_config.h.in @@ -45,6 +45,7 @@ #define ZM_SCALE_BASE 100 // The factor by which we bump up 'scale' to simulate FP #define ZM_RATE_BASE 100 // The factor by which we bump up 'rate' to simulate FP +#define ZM_SQL_BATCH_SIZE 50 // Limit the size of multi-row SQL statements #define ZM_SQL_SML_BUFSIZ 256 // Size of SQL buffer #define ZM_SQL_MED_BUFSIZ 1024 // Size of SQL buffer #define ZM_SQL_LGE_BUFSIZ 8192 // Size of SQL buffer diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 47ac0e9ba..827904bbd 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -489,11 +489,18 @@ void Event::updateNotes( const StringSetMap &newNoteSetMap ) } void Event::AddFrames( int n_frames, Image **images, struct timeval **timestamps ) +{ + for (int i = 0; i < n_frames; i += ZM_SQL_BATCH_SIZE) { + AddFramesInternal(n_frames, i, images, timestamps); + } +} + +void Event::AddFramesInternal( int n_frames, int start_frame, Image **images, struct timeval **timestamps ) { static char sql[ZM_SQL_LGE_BUFSIZ]; strncpy( sql, "insert into Frames ( EventId, FrameId, TimeStamp, Delta ) values ", sizeof(sql) ); int frameCount = 0; - for ( int i = 0; i < n_frames; i++ ) + for ( int i = start_frame; i < n_frames && i - start_frame < ZM_SQL_BATCH_SIZE; i++ ) { if ( !timestamps[i]->tv_sec ) { diff --git a/src/zm_event.h b/src/zm_event.h index 7029a9f5c..f50a5bf06 100644 --- a/src/zm_event.h +++ b/src/zm_event.h @@ -133,6 +133,9 @@ public: void AddFrames( int n_frames, Image **images, struct timeval **timestamps ); void AddFrame( Image *image, struct timeval timestamp, int score=0, Image *alarm_frame=NULL ); +private: + void AddFramesInternal( int n_frames, int start_frame, Image **images, struct timeval **timestamps ); + public: static const char *getSubPath( struct tm *time ) { From b743375dcf9896bf984144f0e6c88101d3c4856a Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Tue, 29 Oct 2013 09:15:24 +0200 Subject: [PATCH 20/29] Attempt to get travis working again by skipping whole system update --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9e85b69ae..5071b7cc9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,8 +18,7 @@ compiler: - gcc before_install: - sudo apt-get update -qq - - sudo apt-get upgrade -y -qq - - sudo apt-get install -y -qq apache2 mysql-server php5 php5-mysql build-essential libmysqlclient-dev libssl-dev libbz2-dev libpcre3-dev libdbi-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libmime-perl libpcre3 libwww-perl libdbd-mysql-perl libsys-mmap-perl yasm subversion automake autoconf cmake libjpeg-turbo8-dev libjpeg-turbo8 apache2-mpm-prefork libapache2-mod-php5 php5-cli libtheora-dev libvorbis-dev libvpx-dev libx264-dev 2>&1 > /dev/null + - sudo apt-get install -y -qq zlib1g-dev apache2 mysql-server php5 php5-mysql build-essential libmysqlclient-dev libssl-dev libbz2-dev libpcre3-dev libdbi-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libmime-perl libwww-perl libdbd-mysql-perl libsys-mmap-perl yasm subversion automake autoconf cmake libjpeg-turbo8-dev apache2-mpm-prefork libapache2-mod-php5 php5-cli libtheora-dev libvorbis-dev libvpx-dev libx264-dev 2>&1 > /dev/null install: - git clone --depth=10 --branch=master git://source.ffmpeg.org/ffmpeg.git - cd ffmpeg From 014396949809474f3b5bbf3f69f954b483090bc9 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Tue, 29 Oct 2013 10:01:29 +0200 Subject: [PATCH 21/29] Do not print progress while building zoneminder perl modules unless CMAKE_VERBOSE_MAKEFILE is enabled --- scripts/ZoneMinder/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/ZoneMinder/CMakeLists.txt b/scripts/ZoneMinder/CMakeLists.txt index 267c98041..fb66f5606 100644 --- a/scripts/ZoneMinder/CMakeLists.txt +++ b/scripts/ZoneMinder/CMakeLists.txt @@ -6,8 +6,14 @@ configure_file(lib/ZoneMinder/Config.pm.in ${CMAKE_CURRENT_SOURCE_DIR}/lib/ZoneM configure_file(lib/ZoneMinder/Memory.pm.in ${CMAKE_CURRENT_SOURCE_DIR}/lib/ZoneMinder/Memory.pm @ONLY) configure_file(lib/ZoneMinder/ConfigData.pm.in ${CMAKE_CURRENT_SOURCE_DIR}/lib/ZoneMinder/ConfigData.pm @ONLY) +if(CMAKE_VERBOSE_MAKEFILE) + set(MAKEMAKER_NOECHO_COMMAND "") +else(CMAKE_VERBOSE_MAKEFILE) + set(MAKEMAKER_NOECHO_COMMAND "NOECHO=\"1>/dev/null\"") +endif(CMAKE_VERBOSE_MAKEFILE) + # Add build target for the perl modules -add_custom_target(zmperlmodules ALL perl Makefile.PL FIRST_MAKEFILE=MakefilePerl PREFIX=output LIB="output/${ZM_PERL_SUBPREFIX}" COMMAND make --makefile=MakefilePerl COMMAND make --makefile=MakefilePerl pure_install COMMENT "Building ZoneMinder perl modules") +add_custom_target(zmperlmodules ALL perl Makefile.PL FIRST_MAKEFILE=MakefilePerl PREFIX=output LIB="output/${ZM_PERL_SUBPREFIX}" ${MAKEMAKER_NOECHO_COMMAND} COMMAND make --makefile=MakefilePerl COMMAND make --makefile=MakefilePerl pure_install COMMENT "Building ZoneMinder perl modules") # Add install target for the perl modules install(DIRECTORY output/ DESTINATION "${CMAKE_INSTALL_PREFIX}") From 23ec8266d94aa6ba8988e83ec5a53ef8b1dcda05 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Tue, 29 Oct 2013 11:02:47 +0200 Subject: [PATCH 22/29] Hard code man dir path into cmake to fix issues with some distros --- scripts/ZoneMinder/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ZoneMinder/CMakeLists.txt b/scripts/ZoneMinder/CMakeLists.txt index fb66f5606..fec830ab9 100644 --- a/scripts/ZoneMinder/CMakeLists.txt +++ b/scripts/ZoneMinder/CMakeLists.txt @@ -13,7 +13,7 @@ else(CMAKE_VERBOSE_MAKEFILE) endif(CMAKE_VERBOSE_MAKEFILE) # Add build target for the perl modules -add_custom_target(zmperlmodules ALL perl Makefile.PL FIRST_MAKEFILE=MakefilePerl PREFIX=output LIB="output/${ZM_PERL_SUBPREFIX}" ${MAKEMAKER_NOECHO_COMMAND} COMMAND make --makefile=MakefilePerl COMMAND make --makefile=MakefilePerl pure_install COMMENT "Building ZoneMinder perl modules") +add_custom_target(zmperlmodules ALL perl Makefile.PL FIRST_MAKEFILE=MakefilePerl PREFIX=output LIB="output/${ZM_PERL_SUBPREFIX}" INSTALLMAN3DIR="output/${CMAKE_INSTALL_MANDIR}/man3" ${MAKEMAKER_NOECHO_COMMAND} COMMAND make --makefile=MakefilePerl COMMAND make --makefile=MakefilePerl pure_install COMMENT "Building ZoneMinder perl modules") # Add install target for the perl modules install(DIRECTORY output/ DESTINATION "${CMAKE_INSTALL_PREFIX}") From 604b7f4ccc4c5484566ab17ae17cade88cef38a3 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Tue, 29 Oct 2013 11:21:23 +0200 Subject: [PATCH 23/29] Clean files generated by MakeMaker when running cmake's make clean target --- scripts/ZoneMinder/CMakeLists.txt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/ZoneMinder/CMakeLists.txt b/scripts/ZoneMinder/CMakeLists.txt index fec830ab9..4e25f81a6 100644 --- a/scripts/ZoneMinder/CMakeLists.txt +++ b/scripts/ZoneMinder/CMakeLists.txt @@ -18,8 +18,5 @@ add_custom_target(zmperlmodules ALL perl Makefile.PL FIRST_MAKEFILE=MakefilePerl # Add install target for the perl modules install(DIRECTORY output/ DESTINATION "${CMAKE_INSTALL_PREFIX}") - - - - - +# Add additional commands to make clean +set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "output;blib;pm_to_blib;MakefilePerl") From 36f525efae844302e2336dd52a789c3e246f76ef Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Tue, 29 Oct 2013 12:43:28 +0200 Subject: [PATCH 24/29] Correctly hard code man dir path into cmake this time hopefully --- scripts/ZoneMinder/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ZoneMinder/CMakeLists.txt b/scripts/ZoneMinder/CMakeLists.txt index 4e25f81a6..b5ddfb5a3 100644 --- a/scripts/ZoneMinder/CMakeLists.txt +++ b/scripts/ZoneMinder/CMakeLists.txt @@ -13,7 +13,7 @@ else(CMAKE_VERBOSE_MAKEFILE) endif(CMAKE_VERBOSE_MAKEFILE) # Add build target for the perl modules -add_custom_target(zmperlmodules ALL perl Makefile.PL FIRST_MAKEFILE=MakefilePerl PREFIX=output LIB="output/${ZM_PERL_SUBPREFIX}" INSTALLMAN3DIR="output/${CMAKE_INSTALL_MANDIR}/man3" ${MAKEMAKER_NOECHO_COMMAND} COMMAND make --makefile=MakefilePerl COMMAND make --makefile=MakefilePerl pure_install COMMENT "Building ZoneMinder perl modules") +add_custom_target(zmperlmodules ALL perl Makefile.PL FIRST_MAKEFILE=MakefilePerl PREFIX=output LIB="output/${ZM_PERL_SUBPREFIX}" INSTALLSITEMAN3DIR="output/${CMAKE_INSTALL_MANDIR}/man3" ${MAKEMAKER_NOECHO_COMMAND} COMMAND make --makefile=MakefilePerl COMMAND make --makefile=MakefilePerl pure_install COMMENT "Building ZoneMinder perl modules") # Add install target for the perl modules install(DIRECTORY output/ DESTINATION "${CMAKE_INSTALL_PREFIX}") From 2c0469086513574b2c4b2851cb86be6b61232b24 Mon Sep 17 00:00:00 2001 From: Kyle Johnson Date: Wed, 30 Oct 2013 08:39:24 -0400 Subject: [PATCH 25/29] Allow larger shared memory sizes. Fixes #226 --- src/zm_monitor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zm_monitor.h b/src/zm_monitor.h index 47261bfbd..f08c621a2 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -167,7 +167,7 @@ protected: #else // ZM_MEM_MAPPED int shm_id; #endif // ZM_MEM_MAPPED - int mem_size; + long mem_size; unsigned char *mem_ptr; volatile SharedData *shared_data; @@ -263,7 +263,7 @@ protected: #else // ZM_MEM_MAPPED int shm_id; #endif // ZM_MEM_MAPPED - int mem_size; + long mem_size; unsigned char *mem_ptr; SharedData *shared_data; From fd03d89ce51fc38eea46815a53d5020a34a91cdc Mon Sep 17 00:00:00 2001 From: Kyle Johnson Date: Wed, 30 Oct 2013 09:17:26 -0400 Subject: [PATCH 26/29] Change mem_size in zm_monitor.h from long to unsigned long --- src/zm_monitor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zm_monitor.h b/src/zm_monitor.h index f08c621a2..496ce96b1 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -167,7 +167,7 @@ protected: #else // ZM_MEM_MAPPED int shm_id; #endif // ZM_MEM_MAPPED - long mem_size; + unsigned long mem_size; unsigned char *mem_ptr; volatile SharedData *shared_data; @@ -263,7 +263,7 @@ protected: #else // ZM_MEM_MAPPED int shm_id; #endif // ZM_MEM_MAPPED - long mem_size; + unsigned long mem_size; unsigned char *mem_ptr; SharedData *shared_data; From 36d94d160fd4add54d959ccecadfda430946986f Mon Sep 17 00:00:00 2001 From: Kyle Johnson Date: Wed, 30 Oct 2013 09:17:26 -0400 Subject: [PATCH 27/29] Change zm_monitor.h mem_size from long to unsigned long. Fixes #226. --- src/zm_monitor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zm_monitor.h b/src/zm_monitor.h index f08c621a2..496ce96b1 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -167,7 +167,7 @@ protected: #else // ZM_MEM_MAPPED int shm_id; #endif // ZM_MEM_MAPPED - long mem_size; + unsigned long mem_size; unsigned char *mem_ptr; volatile SharedData *shared_data; @@ -263,7 +263,7 @@ protected: #else // ZM_MEM_MAPPED int shm_id; #endif // ZM_MEM_MAPPED - long mem_size; + unsigned long mem_size; unsigned char *mem_ptr; SharedData *shared_data; From c2bd7c97ec260800b1645b17e0fb42036192a8a4 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Thu, 31 Oct 2013 18:10:00 +0200 Subject: [PATCH 28/29] First attempt at enabling out-of-source building for zm with cmake --- CMakeLists.txt | 5 +++++ db/CMakeLists.txt | 2 +- misc/CMakeLists.txt | 6 +++--- scripts/CMakeLists.txt | 32 +++++++++++++++---------------- scripts/ZoneMinder/CMakeLists.txt | 14 +++++++------- src/CMakeLists.txt | 2 +- web/CMakeLists.txt | 4 ++-- web/tools/mootools/CMakeLists.txt | 4 ++-- 8 files changed, 37 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15693ffbb..4502043cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,11 @@ cmake_minimum_required (VERSION 2.6) project (zoneminder) set(zoneminder_VERSION "1.26.4") +# CMake does not allow out-of-source build if CMakeCache.exists in the source folder. Abort and notify the user to save him from headache why it doesn't work. +if((NOT (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)) AND (EXISTS "${CMAKE_SOURCE_DIR}/CMakeCache.txt")) + message(FATAL_ERROR " You are attempting to do an out-of-source build, but a cmake cache file for an in-source build exists. Please delete the file CMakeCache.txt from the source folder to proceed.") +endif((NOT (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)) AND (EXISTS "${CMAKE_SOURCE_DIR}/CMakeCache.txt")) + # Default build type. To change the build type, use the CMAKE_BUILD_TYPE configuration option. if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Release or Debug" FORCE) diff --git a/db/CMakeLists.txt b/db/CMakeLists.txt index 5e53e8efc..41481a250 100644 --- a/db/CMakeLists.txt +++ b/db/CMakeLists.txt @@ -1,7 +1,7 @@ # CMakeLists.txt for the ZoneMinder database scripts # Create files from the .in files -configure_file(zm_create.sql.in ${CMAKE_CURRENT_SOURCE_DIR}/zm_create.sql @ONLY) +configure_file(zm_create.sql.in "${CMAKE_CURRENT_BINARY_DIR}/zm_create.sql" @ONLY) # Glob all files matching zm*.sql (to exclude *.in files and autotools's files) file(GLOB dbfileslist RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "zm*.sql") diff --git a/misc/CMakeLists.txt b/misc/CMakeLists.txt index c9e5e82a3..830e70ace 100644 --- a/misc/CMakeLists.txt +++ b/misc/CMakeLists.txt @@ -1,9 +1,9 @@ # CMakeLists.txt for the ZoneMinder misc files # Create files from the .in files -configure_file(apache.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/apache.conf @ONLY) -configure_file(logrotate.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/logrotate.conf @ONLY) -configure_file(syslog.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/syslog.conf @ONLY) +configure_file(apache.conf.in "${CMAKE_CURRENT_BINARY_DIR}/apache.conf" @ONLY) +configure_file(logrotate.conf.in "${CMAKE_CURRENT_BINARY_DIR}/logrotate.conf" @ONLY) +configure_file(syslog.conf.in "${CMAKE_CURRENT_BINARY_DIR}/syslog.conf" @ONLY) # Install the misc files install(FILES apache.conf logrotate.conf syslog.conf DESTINATION "${CMAKE_INSTALL_DATADIR}/zoneminder/misc") diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index f736eca9f..2409c7681 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -1,26 +1,26 @@ # CMakeLists.txt for the ZoneMinder perl scripts. # Process the perl modules subdirectory -add_subdirectory(ZoneMinder ZoneMinder) +add_subdirectory(ZoneMinder) # Create files from the .in files -configure_file(zmaudit.pl.in ${CMAKE_CURRENT_SOURCE_DIR}/zmaudit.pl @ONLY) -configure_file(zmcontrol.pl.in ${CMAKE_CURRENT_SOURCE_DIR}/zmcontrol.pl @ONLY) -configure_file(zmdc.pl.in ${CMAKE_CURRENT_SOURCE_DIR}/zmdc.pl @ONLY) -configure_file(zmfilter.pl.in ${CMAKE_CURRENT_SOURCE_DIR}/zmfilter.pl @ONLY) -configure_file(zmpkg.pl.in ${CMAKE_CURRENT_SOURCE_DIR}/zmpkg.pl @ONLY) -configure_file(zmtrack.pl.in ${CMAKE_CURRENT_SOURCE_DIR}/zmtrack.pl @ONLY) -configure_file(zmtrigger.pl.in ${CMAKE_CURRENT_SOURCE_DIR}/zmtrigger.pl @ONLY) -configure_file(zmupdate.pl.in ${CMAKE_CURRENT_SOURCE_DIR}/zmupdate.pl @ONLY) -configure_file(zmvideo.pl.in ${CMAKE_CURRENT_SOURCE_DIR}/zmvideo.pl @ONLY) -configure_file(zmwatch.pl.in ${CMAKE_CURRENT_SOURCE_DIR}/zmwatch.pl @ONLY) +configure_file(zmaudit.pl.in "${CMAKE_CURRENT_BINARY_DIR}/zmaudit.pl" @ONLY) +configure_file(zmcontrol.pl.in "${CMAKE_CURRENT_BINARY_DIR}/zmcontrol.pl" @ONLY) +configure_file(zmdc.pl.in "${CMAKE_CURRENT_BINARY_DIR}/zmdc.pl" @ONLY) +configure_file(zmfilter.pl.in "${CMAKE_CURRENT_BINARY_DIR}/zmfilter.pl" @ONLY) +configure_file(zmpkg.pl.in "${CMAKE_CURRENT_BINARY_DIR}/zmpkg.pl" @ONLY) +configure_file(zmtrack.pl.in "${CMAKE_CURRENT_BINARY_DIR}/zmtrack.pl" @ONLY) +configure_file(zmtrigger.pl.in "${CMAKE_CURRENT_BINARY_DIR}/zmtrigger.pl" @ONLY) +configure_file(zmupdate.pl.in "${CMAKE_CURRENT_BINARY_DIR}/zmupdate.pl" @ONLY) +configure_file(zmvideo.pl.in "${CMAKE_CURRENT_BINARY_DIR}/zmvideo.pl" @ONLY) +configure_file(zmwatch.pl.in "${CMAKE_CURRENT_BINARY_DIR}/zmwatch.pl" @ONLY) if(NOT ZM_NO_X10) -configure_file(zmx10.pl.in ${CMAKE_CURRENT_SOURCE_DIR}/zmx10.pl @ONLY) + configure_file(zmx10.pl.in "${CMAKE_CURRENT_BINARY_DIR}/zmx10.pl" @ONLY) endif(NOT ZM_NO_X10) -#configure_file(zmdbbackup.in ${CMAKE_CURRENT_SOURCE_DIR}/zmdbbackup @ONLY) -#configure_file(zmdbrestore.in ${CMAKE_CURRENT_SOURCE_DIR}/zmdbrestore @ONLY) -configure_file(zm.in ${CMAKE_CURRENT_SOURCE_DIR}/zm @ONLY) -#configure_file(zmeventdump.in ${CMAKE_CURRENT_SOURCE_DIR}/zmeventdump @ONLY) +#configure_file(zmdbbackup.in zmdbbackup @ONLY) +#configure_file(zmdbrestore.in zmdbrestore @ONLY) +configure_file(zm.in "${CMAKE_CURRENT_BINARY_DIR}/zm" @ONLY) +#configure_file(zmeventdump.in zmeventdump @ONLY) # Install the perl scripts install(FILES zmaudit.pl zmcontrol.pl zmdc.pl zmfilter.pl zmpkg.pl zmtrack.pl zmtrigger.pl zmupdate.pl zmvideo.pl zmwatch.pl DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/scripts/ZoneMinder/CMakeLists.txt b/scripts/ZoneMinder/CMakeLists.txt index b5ddfb5a3..48cced03d 100644 --- a/scripts/ZoneMinder/CMakeLists.txt +++ b/scripts/ZoneMinder/CMakeLists.txt @@ -1,10 +1,10 @@ # CMakeLists.txt for the ZoneMinder perl module. # Create files from the .in files -configure_file(lib/ZoneMinder/Base.pm.in ${CMAKE_CURRENT_SOURCE_DIR}/lib/ZoneMinder/Base.pm @ONLY) -configure_file(lib/ZoneMinder/Config.pm.in ${CMAKE_CURRENT_SOURCE_DIR}/lib/ZoneMinder/Config.pm @ONLY) -configure_file(lib/ZoneMinder/Memory.pm.in ${CMAKE_CURRENT_SOURCE_DIR}/lib/ZoneMinder/Memory.pm @ONLY) -configure_file(lib/ZoneMinder/ConfigData.pm.in ${CMAKE_CURRENT_SOURCE_DIR}/lib/ZoneMinder/ConfigData.pm @ONLY) +configure_file(lib/ZoneMinder/Base.pm.in "${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Base.pm" @ONLY) +configure_file(lib/ZoneMinder/Config.pm.in "${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Config.pm" @ONLY) +configure_file(lib/ZoneMinder/Memory.pm.in "${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/Memory.pm" @ONLY) +configure_file(lib/ZoneMinder/ConfigData.pm.in "${CMAKE_CURRENT_BINARY_DIR}/lib/ZoneMinder/ConfigData.pm" @ONLY) if(CMAKE_VERBOSE_MAKEFILE) set(MAKEMAKER_NOECHO_COMMAND "") @@ -13,10 +13,10 @@ else(CMAKE_VERBOSE_MAKEFILE) endif(CMAKE_VERBOSE_MAKEFILE) # Add build target for the perl modules -add_custom_target(zmperlmodules ALL perl Makefile.PL FIRST_MAKEFILE=MakefilePerl PREFIX=output LIB="output/${ZM_PERL_SUBPREFIX}" INSTALLSITEMAN3DIR="output/${CMAKE_INSTALL_MANDIR}/man3" ${MAKEMAKER_NOECHO_COMMAND} COMMAND make --makefile=MakefilePerl COMMAND make --makefile=MakefilePerl pure_install COMMENT "Building ZoneMinder perl modules") +add_custom_target(zmperlmodules ALL perl Makefile.PL FIRST_MAKEFILE=MakefilePerl PREFIX="${CMAKE_CURRENT_BINARY_DIR}/output" LIB="${CMAKE_CURRENT_BINARY_DIR}/output/${ZM_PERL_SUBPREFIX}" INSTALLSITEMAN3DIR="${CMAKE_CURRENT_BINARY_DIR}/output/${CMAKE_INSTALL_MANDIR}/man3" ${MAKEMAKER_NOECHO_COMMAND} COMMAND make --makefile=MakefilePerl COMMAND make --makefile=MakefilePerl pure_install WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMMENT "Building ZoneMinder perl modules") # Add install target for the perl modules -install(DIRECTORY output/ DESTINATION "${CMAKE_INSTALL_PREFIX}") +install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/output/" DESTINATION "${CMAKE_INSTALL_PREFIX}") -# Add additional commands to make clean +# Add additional files and directories to make clean set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "output;blib;pm_to_blib;MakefilePerl") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ed42140ec..b91baa978 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,7 @@ # CMakeLists.txt for the ZoneMinder binaries # Create files from the .in files -configure_file(zm_config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/zm_config.h @ONLY) +configure_file(zm_config.h.in "${CMAKE_CURRENT_BINARY_DIR}/zm_config.h" @ONLY) # Group together all the source files that are used by all the binaries (zmc, zma, zmu, zms etc) set(ZM_BIN_SRC_FILES zm_box.cpp zm_buffer.cpp zm_camera.cpp zm_comms.cpp zm_config.cpp zm_coord.cpp zm.cpp zm_db.cpp zm_logger.cpp zm_event.cpp zm_exception.cpp zm_file_camera.cpp zm_ffmpeg_camera.cpp zm_image.cpp zm_jpeg.cpp zm_local_camera.cpp zm_monitor.cpp zm_ffmpeg.cpp zm_mpeg.cpp zm_poly.cpp zm_regexp.cpp zm_remote_camera.cpp zm_remote_camera_http.cpp zm_remote_camera_rtsp.cpp zm_rtp.cpp zm_rtp_ctrl.cpp zm_rtp_data.cpp zm_rtp_source.cpp zm_rtsp.cpp zm_sdp.cpp zm_signal.cpp zm_stream.cpp zm_thread.cpp zm_time.cpp zm_timer.cpp zm_user.cpp zm_utils.cpp zm_zone.cpp) diff --git a/web/CMakeLists.txt b/web/CMakeLists.txt index 3ead70703..b547df708 100644 --- a/web/CMakeLists.txt +++ b/web/CMakeLists.txt @@ -1,10 +1,10 @@ # CMakeLists.txt for the ZoneMinder web files # Process the tools/mootools subdirectory -add_subdirectory(tools/mootools tools/mootools) +add_subdirectory(tools/mootools) # Create files from the .in files -configure_file(includes/config.php.in ${CMAKE_CURRENT_SOURCE_DIR}/includes/config.php @ONLY) +configure_file(includes/config.php.in "${CMAKE_CURRENT_BINARY_DIR}/includes/config.php" @ONLY) # Install the web files install(DIRECTORY ajax css graphics includes js lang skins tools views DESTINATION "${ZM_WEBDIR}" PATTERN "*.in" EXCLUDE PATTERN "*Make*" EXCLUDE) diff --git a/web/tools/mootools/CMakeLists.txt b/web/tools/mootools/CMakeLists.txt index 5d87420b9..c71e77ff4 100644 --- a/web/tools/mootools/CMakeLists.txt +++ b/web/tools/mootools/CMakeLists.txt @@ -11,7 +11,7 @@ else(NOT mtcorelist) math(EXPR mtcoreindex "${mtcorelistcount} - 1") list(GET mtcorelist ${mtcoreindex} mtcorelatest) message(STATUS "Using mootools core file: ${mtcorelatest}") - execute_process(COMMAND ln -f -s "${mtcorelatest}" "${CMAKE_CURRENT_SOURCE_DIR}/mootools-core.js" RESULT_VARIABLE mtcoreresult) + execute_process(COMMAND ln -f -s "${mtcorelatest}" "${CMAKE_CURRENT_BINARY_DIR}/mootools-core.js" RESULT_VARIABLE mtcoreresult) if(mtcoreresult) message(WARNING " Failed creating the required symlinks for mootools-core. Exit code: ${mtcoreresult}") endif(mtcoreresult) @@ -27,7 +27,7 @@ else(NOT mtmorelist) math(EXPR mtmoreindex "${mtmorelistcount} - 1") list(GET mtmorelist ${mtmoreindex} mtmorelatest) message(STATUS "Using mootools more file: ${mtmorelatest}") - execute_process(COMMAND ln -f -s "${mtmorelatest}" "${CMAKE_CURRENT_SOURCE_DIR}/mootools-more.js" RESULT_VARIABLE mtmoreresult) + execute_process(COMMAND ln -f -s "${mtmorelatest}" "${CMAKE_CURRENT_BINARY_DIR}/mootools-more.js" RESULT_VARIABLE mtmoreresult) if(mtmoreresult) message(WARNING " Failed creating the required symlinks for mootools-more. Exit code: ${mtmoreresult}") endif(mtmoreresult) From 069552321f33cd446eaf6b631fe044098cb745e9 Mon Sep 17 00:00:00 2001 From: Kfir Itzhak Date: Fri, 1 Nov 2013 13:31:37 +0200 Subject: [PATCH 29/29] Fix zmc crashing when four field deinterlacing is enabled together with left or right rotation --- src/zm_image.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/zm_image.h b/src/zm_image.h index efa34ef67..46c7a031b 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -187,11 +187,12 @@ public: inline void CopyBuffer( const Image &image ) { - if ( image.size != size ) - { - Panic( "Attempt to copy different size image buffers, expected %d, got %d", size, image.size ); - } - (*fptr_imgbufcpy)(buffer, image.buffer, size); + Assign(image); + } + inline Image &operator=( const Image &image ) + { + Assign(image); + return *this; } inline Image &operator=( const unsigned char *new_buffer ) {