zoneminder/CMakeLists.txt

851 lines
33 KiB
CMake
Raw Normal View History

2013-09-28 17:59:50 +08:00
# Main CMake file for the ZoneMinder project.
# Created by mastertheknife (Kfir Itzhak)
# For more information and installation, see the INSTALL file
#
2016-12-23 22:56:10 +08:00
cmake_minimum_required (VERSION 2.8.7)
project (zoneminder)
file (STRINGS "version" zoneminder_VERSION)
# make API version a minor of ZM version
set(zoneminder_API_VERSION "${zoneminder_VERSION}.1")
2015-11-22 08:21:18 +08:00
# Make sure the submodules are there
if( NOT EXISTS "${CMAKE_SOURCE_DIR}/web/api/app/Plugin/Crud/Lib/CrudControllerTrait.php" )
2015-11-22 08:21:18 +08:00
message( SEND_ERROR "The git submodules are not available. Please run
git submodule update --init --recursive")
endif( NOT EXISTS "${CMAKE_SOURCE_DIR}/web/api/app/Plugin/Crud/Lib/CrudControllerTrait.php" )
2015-11-22 08:21:18 +08:00
# CMake does not allow out-of-source build if CMakeCache.exists
# in the source folder. Abort and notify the user
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.
2013-09-28 17:59:50 +08:00
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
Release CACHE STRING "Build type: Release or Debug" FORCE)
2013-09-28 17:59:50 +08:00
endif(NOT CMAKE_BUILD_TYPE)
# Can assist in troubleshooting
2013-09-28 17:59:50 +08:00
#set(CMAKE_VERBOSE_MAKEFILE ON)
#set(CMAKE_INSTALL_ALWAYS ON)
# Host OS Check
set(HOST_OS "")
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(HOST_OS "linux")
endif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
if(${CMAKE_SYSTEM_NAME} MATCHES ".*(SunOS|Solaris).*")
set(HOST_OS "solaris")
set(SOLARIS 1)
endif(${CMAKE_SYSTEM_NAME} MATCHES ".*(SunOS|Solaris).*")
if(${CMAKE_SYSTEM_NAME} MATCHES ".*BSD.*")
set(HOST_OS "BSD")
set(BSD 1)
endif(${CMAKE_SYSTEM_NAME} MATCHES ".*BSD.*")
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(HOST_OS "darwin")
endif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
if(NOT HOST_OS)
message(FATAL_ERROR
"ZoneMinder was unable to deterimine the host OS. Please report this. Value of CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
endif(NOT HOST_OS)
2013-09-28 17:59:50 +08:00
# Default CLFAGS and CXXFLAGS:
set(CMAKE_C_FLAGS_RELEASE "-Wall -D__STDC_CONSTANT_MACROS -O2")
set(CMAKE_CXX_FLAGS_RELEASE "-Wall -D__STDC_CONSTANT_MACROS -O2")
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/")
# GCC below 6.0 doesn't support __target__("fpu=neon") attribute, required for compiling ARM Neon code, otherwise compilation fails.
# Must use -mfpu=neon compiler flag instead, but only do that for processors that support neon, otherwise strip the neon code alltogether,
# because passing -fmpu=neon is unsafe to processors that don't support neon
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND CMAKE_SYSTEM_NAME MATCHES "Linux")
IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
EXEC_PROGRAM(grep ARGS " neon " "/proc/cpuinfo" OUTPUT_VARIABLE neonoutput RETURN_VALUE neonresult)
IF(neonresult EQUAL 0)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -mfpu=neon")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mfpu=neon")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -mfpu=neon")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -mfpu=neon")
ELSE(neonresult EQUAL 0)
add_definitions(-DZM_STRIP_NEON=1)
message(STATUS "ARM Neon is not available on this processor. Neon functions will be absent")
ENDIF(neonresult EQUAL 0)
ENDIF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND CMAKE_SYSTEM_NAME MATCHES "Linux")
2013-09-28 17:59:50 +08:00
# Modules that we need:
include (GNUInstallDirs)
include (CheckIncludeFile)
include (CheckIncludeFiles)
include (CheckFunctionExists)
include (CheckPrototypeDefinition_fixed)
2013-09-28 17:59:50 +08:00
include (CheckTypeSize)
include (CheckStructHasMember)
2015-04-01 11:07:19 +08:00
include (CheckSendfile)
2013-09-28 17:59:50 +08:00
# Configuration options
mark_as_advanced(
FORCE ZM_EXTRA_LIBS
ZM_MYSQL_ENGINE
ZM_NO_MMAP
CMAKE_INSTALL_FULL_BINDIR
ZM_PERL_MM_PARMS
ZM_PERL_SEARCH_PATH
ZM_TARGET_DISTRO
ZM_CONFIG_DIR
ZM_CONFIG_SUBDIR
ZM_SYSTEMD)
set(ZM_RUNDIR "/var/run/zm" CACHE PATH
"Location of transient process files, default: /var/run/zm")
set(ZM_SOCKDIR "/var/run/zm" CACHE PATH
"Location of Unix domain socket files, default /var/run/zm")
set(ZM_TMPDIR "/var/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: <prefix>/${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: <prefix>/${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")
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")
set(ZM_DB_PASS "zmpass" CACHE STRING
"Password of ZoneMinder database user, default: zmpass")
set(ZM_WEB_USER "" CACHE STRING
"The user apache or the local web server runs on. Leave empty for automatic detection.
If that fails, you can use this variable to force")
set(ZM_WEB_GROUP "" CACHE STRING
"The group apache or the local web server runs on,
Leave empty to be the same as the web user")
2013-09-28 17:59:50 +08:00
# Advanced
set(ZM_CONFIG_DIR "/${CMAKE_INSTALL_SYSCONFDIR}" CACHE PATH
"Location of ZoneMinder configuration, default system config directory")
set(ZM_CONFIG_SUBDIR "${ZM_CONFIG_DIR}/conf.d" CACHE PATH
"Location of ZoneMinder configuration subfolder, default: ZM_CONFIG_DIR/conf.d")
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_NO_LIBVLC "OFF" CACHE BOOL
"Set to ON to skip libvlc checks and force building ZM without libvlc. default: OFF")
set(ZM_NO_CURL "OFF" CACHE BOOL
"Set to ON to skip cURL checks and force building ZM without cURL. default: OFF")
set(ZM_NO_X10 "OFF" CACHE BOOL
"Set to ON to build ZoneMinder without X10 support. default: OFF")
set(ZM_ONVIF "ON" CACHE BOOL
"Set to ON to enable basic ONVIF support. This is EXPERIMENTAL and may not
work with all cameras claiming to be ONVIF compliant. default: ON")
set(ZM_PERL_MM_PARMS INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1 CACHE STRING
"By default, ZoneMinder's Perl modules are installed into the Vendor folders,
as defined by your installation of Perl. You can change that here. Consult Perl's
MakeMaker documentation for a definition of acceptable parameters. If you set this
to something that causes the modules to be installed outside Perl's normal search
path, then you will also need to set ZM_PERL_SEARCH_PATH accordingly.")
set(ZM_PERL_SEARCH_PATH "" CACHE PATH
"Use to add a folder to your Perl's search path. This will need to be set in cases
where ZM_PERL_MM_PARMS has been modified such that ZoneMinder's Perl modules are
installed outside Perl's default search path.")
set(ZM_TARGET_DISTRO "" CACHE STRING
"Build ZoneMinder for a specific distribution. Currently, valid names are: fc24, fc25, el6, el7, OS13, FreeBSD")
set(ZM_SYSTEMD "OFF" CACHE BOOL
"Set to ON to force building ZM with systemd support. default: OFF")
# Reassign some variables if a target distro has been specified
if((ZM_TARGET_DISTRO MATCHES "^el") OR (ZM_TARGET_DISTRO MATCHES "^fc"))
2015-02-09 06:16:31 +08:00
set(ZM_RUNDIR "/var/run/zoneminder")
set(ZM_SOCKDIR "/var/lib/zoneminder/sock")
set(ZM_TMPDIR "/var/lib/zoneminder/temp")
set(ZM_LOGDIR "/var/log/zoneminder")
set(ZM_CONFIG_DIR "/etc/zm")
set(ZM_CONFIG_SUBDIR "/etc/zm/conf.d")
2015-02-15 19:34:27 +08:00
set(ZM_WEBDIR "/usr/share/zoneminder/www")
set(ZM_CGIDIR "/usr/libexec/zoneminder/cgi-bin")
elseif(ZM_TARGET_DISTRO STREQUAL "OS13")
set(ZM_RUNDIR "/var/run/zoneminder")
set(ZM_TMPDIR "/var/run/zoneminder")
set(ZM_CONTENTDIR "/var/run/zoneminder")
set(ZM_LOGDIR "/var/log/zoneminder")
set(ZM_WEB_USER "wwwrun")
set(ZM_WEB_GROUP "www")
set(ZM_WEBDIR "/srv/www/htdocs/zoneminder")
set(ZM_CGIDIR "/srv/www/cgi-bin")
2016-04-06 19:45:21 +08:00
elseif(ZM_TARGET_DISTRO STREQUAL "FreeBSD")
2016-03-11 21:38:29 +08:00
set(ZM_RUNDIR "/var/run/zm")
set(ZM_SOCKDIR "/var/run/zm")
set(ZM_TMPDIR "/var/tmp/zm")
set(ZM_CONTENTDIR "/usr/local/var/lib/zoneminder")
set(ZM_WEB_USER "www")
set(ZM_WEB_GROUP "www")
set(ZM_CONFIG_DIR "/usr/local/etc/zm")
set(ZM_CONFIG_SUBDIR "/usr/local/etc/zm/conf.d")
2016-03-11 21:38:29 +08:00
set(ZM_WEBDIR "/usr/local/share/zoneminder/www")
set(ZM_CGIDIR "/usr/local/libexec/zoneminder/cgi-bin")
2016-03-12 05:56:29 +08:00
set(ZM_PERL_MM_PARMS "INSTALLDIRS=site")
endif((ZM_TARGET_DISTRO MATCHES "^el") OR (ZM_TARGET_DISTRO MATCHES "^fc"))
2013-09-28 17:59:50 +08:00
# Required for certain checks to work
set(CMAKE_EXTRA_INCLUDE_FILES
${CMAKE_EXTRA_INCLUDE_FILES} stdio.h stdlib.h math.h signal.h
)
2013-09-28 17:59:50 +08:00
# Required for including headers from the this folder
include_directories("${CMAKE_BINARY_DIR}")
2013-09-28 17:59:50 +08:00
# This is required to enable searching in lib64 (if exists), do not change
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON)
# Set the systemd flag if systemd is autodetected or ZM_SYSTEMD has been set
if(ZM_SYSTEMD OR (IS_DIRECTORY /usr/lib/systemd/system) OR (IS_DIRECTORY /lib/systemd/system))
set(WITH_SYSTEMD 1)
endif(ZM_SYSTEMD OR (IS_DIRECTORY /usr/lib/systemd/system) OR (IS_DIRECTORY /lib/systemd/system))
# System checks
2015-05-21 06:23:41 +08:00
check_include_file("libv4l1-videodev.h" HAVE_LIBV4L1_VIDEODEV_H)
2015-04-04 07:21:28 +08:00
if(NOT HAVE_LIBV4L1_VIDEODEV_H)
check_include_file("linux/videodev.h" HAVE_LINUX_VIDEODEV_H)
endif(NOT HAVE_LIBV4L1_VIDEODEV_H)
2013-09-28 17:59:50 +08:00
check_include_file("linux/videodev2.h" HAVE_LINUX_VIDEODEV2_H)
check_include_file("execinfo.h" HAVE_EXECINFO_H)
2015-10-03 01:37:50 +08:00
if (HAVE_EXECINFO_H)
check_function_exists("backtrace" HAVE_DECL_BACKTRACE)
if (NOT HAVE_DECL_BACKTRACE)
find_library (EXECINFO_LIBRARY NAMES execinfo)
if (EXECINFO_LIBRARY)
2016-03-11 05:00:21 +08:00
list(APPEND ZM_BIN_LIBS "-lexecinfo")
2015-10-03 01:37:50 +08:00
endif (EXECINFO_LIBRARY)
endif (NOT HAVE_DECL_BACKTRACE)
check_function_exists("backtrace_symbols" HAVE_DECL_BACKTRACE_SYMBOLS)
endif (HAVE_EXECINFO_H)
2013-10-06 23:26:33 +08:00
check_include_file("ucontext.h" HAVE_UCONTEXT_H)
2013-09-28 17:59:50 +08:00
check_include_file("sys/sendfile.h" HAVE_SYS_SENDFILE_H)
check_include_file("sys/syscall.h" HAVE_SYS_SYSCALL_H)
check_function_exists("syscall" HAVE_SYSCALL)
2013-09-28 17:59:50 +08:00
check_function_exists("sendfile" HAVE_SENDFILE)
check_function_exists("posix_memalign" HAVE_POSIX_MEMALIGN)
check_type_size("siginfo_t" HAVE_SIGINFO_T)
check_type_size("ucontext_t" HAVE_UCONTEXT_T)
2013-09-28 17:59:50 +08:00
# *** LIBRARY CHECKS ***
if (UNIX)
include (CheckLibraryExists)
CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
if(NOT HAVE_CLOCK_GETTIME)
message(FATAL_ERROR "clock_gettime not found")
else(NOT HAVE_CLOCK_GETTIME)
list(APPEND ZM_BIN_LIBS "-lrt")
endif(NOT HAVE_CLOCK_GETTIME)
endif(UNIX)
2013-09-28 17:59:50 +08:00
# zlib
find_package(ZLIB)
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}")
2013-09-28 17:59:50 +08:00
check_include_file("zlib.h" HAVE_ZLIB_H)
2013-10-21 22:13:07 +08:00
set(optlibsfound "${optlibsfound} zlib")
else(ZLIB_FOUND)
2013-10-21 22:13:07 +08:00
set(optlibsnotfound "${optlibsnotfound} zlib")
2013-09-28 17:59:50 +08:00
endif(ZLIB_FOUND)
2013-12-28 00:02:32 +08:00
# Do not check for cURL if ZM_NO_CURL is on
if(NOT ZM_NO_CURL)
# cURL
find_package(CURL)
if(CURL_FOUND)
set(HAVE_LIBCURL 1)
list(APPEND ZM_BIN_LIBS ${CURL_LIBRARIES})
include_directories(${CURL_INCLUDE_DIRS})
set(CMAKE_REQUIRED_INCLUDES ${CURL_INCLUDE_DIRS})
check_include_file("curl/curl.h" HAVE_CURL_CURL_H)
set(optlibsfound "${optlibsfound} cURL")
else(CURL_FOUND)
set(optlibsnotfound "${optlibsnotfound} cURL")
endif(CURL_FOUND)
2013-12-28 00:04:24 +08:00
endif(NOT ZM_NO_CURL)
2013-11-04 22:57:22 +08:00
2013-09-28 17:59:50 +08:00
# jpeg
find_package(JPEG)
if(JPEG_FOUND)
set(HAVE_LIBJPEG 1)
list(APPEND ZM_BIN_LIBS "${JPEG_LIBRARIES}")
#link_directories(${JPEG_LIBRARY})
include_directories("${JPEG_INCLUDE_DIR}")
set(CMAKE_REQUIRED_INCLUDES "${JPEG_INCLUDE_DIR}")
2013-09-28 17:59:50 +08:00
check_include_files("stdio.h;jpeglib.h" HAVE_JPEGLIB_H)
if(NOT HAVE_JPEGLIB_H)
message(FATAL_ERROR
"ZoneMinder requires libjpeg headers - check that libjpeg development packages are installed")
endif(NOT HAVE_JPEGLIB_H)
2013-09-28 17:59:50 +08:00
else(JPEG_FOUND)
message(FATAL_ERROR
"ZoneMinder requires jpeg but it was not found on your system")
2013-09-28 17:59:50 +08:00
endif(JPEG_FOUND)
# OpenSSL
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}")
2013-09-28 17:59:50 +08:00
check_include_file("openssl/md5.h" HAVE_OPENSSL_MD5_H)
2013-10-21 22:13:07 +08:00
set(optlibsfound "${optlibsfound} OpenSSL")
else(OPENSSL_FOUND)
2013-10-21 22:13:07 +08:00
set(optlibsnotfound "${optlibsnotfound} OpenSSL")
2013-09-28 17:59:50 +08:00
endif(OPENSSL_FOUND)
# pthread (using find_library and find_path)
2013-09-28 17:59:50 +08:00
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)
2013-09-28 17:59:50 +08:00
check_include_file("pthread.h" HAVE_PTHREAD_H)
if(NOT HAVE_PTHREAD_H)
message(FATAL_ERROR
"ZoneMinder requires pthread headers - check that pthread development packages are installed")
endif(NOT HAVE_PTHREAD_H)
2013-09-28 17:59:50 +08:00
else(PTHREAD_LIBRARIES)
message(FATAL_ERROR
"ZoneMinder requires pthread but it was not found on your system")
2013-09-28 17:59:50 +08:00
endif(PTHREAD_LIBRARIES)
# pcre (using find_library and find_path)
2013-09-28 17:59:50 +08:00
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)
2013-09-28 17:59:50 +08:00
check_include_file("pcre.h" HAVE_PCRE_H)
set(optlibsfound "${optlibsfound} PCRE")
else(PCRE_LIBRARIES)
set(optlibsnotfound "${optlibsnotfound} PCRE")
2013-09-28 17:59:50 +08:00
endif(PCRE_LIBRARIES)
# gcrypt (using find_library and find_path)
2013-09-28 17:59:50 +08:00
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)
2013-09-28 17:59:50 +08:00
check_include_file("gcrypt.h" HAVE_GCRYPT_H)
2013-10-21 22:13:07 +08:00
set(optlibsfound "${optlibsfound} GCrypt")
else(GCRYPT_LIBRARIES)
2013-10-21 22:13:07 +08:00
set(optlibsnotfound "${optlibsnotfound} GCrypt")
2013-09-28 17:59:50 +08:00
endif(GCRYPT_LIBRARIES)
# gnutls (using find_library and find_path)
find_library(GNUTLS_LIBRARIES gnutls-openssl)
if(NOT GNUTLS_LIBRARIES)
find_library(GNUTLS_LIBRARIES gnutls)
endif(NOT GNUTLS_LIBRARIES)
2013-09-28 17:59:50 +08:00
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)
2013-09-28 17:59:50 +08:00
check_include_file("gnutls/openssl.h" HAVE_GNUTLS_OPENSSL_H)
check_include_file("gnutls/gnutls.h" HAVE_GNUTLS_GNUTLS_H)
2013-10-21 22:13:07 +08:00
set(optlibsfound "${optlibsfound} GnuTLS")
else(GNUTLS_LIBRARIES)
2013-10-21 22:13:07 +08:00
set(optlibsnotfound "${optlibsnotfound} GnuTLS")
2013-09-28 17:59:50 +08:00
endif(GNUTLS_LIBRARIES)
# mysqlclient (using find_library and find_path)
2013-09-28 17:59:50 +08:00
find_library(MYSQLCLIENT_LIBRARIES mysqlclient PATH_SUFFIXES mysql)
if(MYSQLCLIENT_LIBRARIES)
set(HAVE_LIBMYSQLCLIENT 1)
list(APPEND ZM_BIN_LIBS "${MYSQLCLIENT_LIBRARIES}")
find_path(MYSQLCLIENT_INCLUDE_DIR mysql.h PATH_SUFFIXES mysql)
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.h" HAVE_MYSQL_H)
if(NOT HAVE_MYSQL_H)
message(FATAL_ERROR
"ZoneMinder requires MySQL headers - check that MySQL development packages are installed")
endif(NOT HAVE_MYSQL_H)
2013-09-28 17:59:50 +08:00
else(MYSQLCLIENT_LIBRARIES)
message(FATAL_ERROR
"ZoneMinder requires mysqlclient but it was not found on your system")
2013-09-28 17:59:50 +08:00
endif(MYSQLCLIENT_LIBRARIES)
Feature h264 videostorage (#1882) * Moved writing of configure options from Controller to Model. Fixes #191. * Initial commit for saving events as videos :) * Add zm_video.cpp to autotools * Add zm_video.h to autotools * Search for MP4V2 header file 3 times: mp4v2/mp4v2.h, mp4v2.h, mp4.h * Fix serve memory leak * Few minor code improvements * Added the ability to override preset, tune, profile and few other improvements * Correctly write SPS & PPS from x264 encoder headers * Remove unnessecary SPS & PPS writing code * Imported missing files from master to feature-h264-videostorage * Audio support including fixes for dts/pts, split on keyframe and update to mkv extension to prevent ffmpeg problems writing rtsp audio to mp4 containter (header problem) * Updates to make gcc happy * Add html5 video control to timeline and event to support mkv playback * Add zm_videostore.cpp to CMakeLists.txt * Remove Modern Branch for now * Fix minor bug * Option handled added in master, removing duplicate declaration * Add CaptureandRecord from zm_camera.h * Putting placeholder in for CaptureAndRecord function * Removed duplicate code and brackets * add digest auth file for cmake Conflicts: src/CMakeLists.txt * Add web dir back into Makefile.am Revert "Removed web from SUBDIRS in Makefile.am" This reverts commit d9bbcdf3a94cba4d8955fcd03bd965ed2772f34d. * Add CaptureAndRecord to vlc, still need to make it record * Resolve SegFault on videostore * Swap to mp4 container * mp4 changes * spaces to tabs, hide video stuff if video writer is turned off * Make timeline open event.mp4 instead of mkv * Missed mkv in timeline.js * Fix some issues from the merge conflict * Resolve post merge build issues with braces * Fix whitespace * Update Jpeg and Video options for passthrough options * Whitespace fix zm_camera.h * Fix array mkssing comma * Add support for Jpeg save options for h264 branch snapshot. Might remove altogether if snapshots not needed * Update VideoStoreData memory size comment * Change from config.use_mkv_storage to per monitor option VideoWriter from video branch * Fix bracket issues post merge * Clean up comments and add av_free_packet * Convert from event_directory to event file as per Video branch * Testing videojs for video playback * Fixed a missing bracket post merge and also SQL_values now used for EventID and Monitors * bring recent improvements in ffmpeg capture function into captureandrecord * Remove pict from writeAudioFramePacket as not used * Add translate options for h264 Storage options in Monitor and update en_gb file * Cherry-Pick from iconnor - make it compile on ubuntu 15.04. Which is libav 56.1.0 Conflicts: src/zm_ffmpeg.cpp src/zm_remote_camera_rtsp.cpp Conflicts: distros/ubuntu1204/changelog * Clean up videostore code and remove lots of unused code * proof of concept for dynamic/automatic video rotation using video-js plugin zoomrotate Conflicts: web/skins/classic/views/event.php * removed redundant field in sql query Conflicts: web/skins/classic/views/event.php * local storage of video js plugin * Beautify! Make the code somewhat readable. * added missing videojs.zoomrotate.js file added missing videojs.zoomrotate.js file * Typo added missing " * Added missing brackets * fix to display thumbnails when only storing snapshot.jpg * added control for video playback rate Conflicts: web/skins/classic/views/event.php * dynamically create jpegs from video file for viewing in browser * fix timeline view for SaveJPEGs monitors (without enabled VideoWriter) * only expose monitor info which are being used in client * fix segmentation fault in zma with ubuntu 14.04 and ffmpeg 2.5.8 (gcc 4.8) when libx264 is not installed * better way of detecting showing image or video in timeline and event view instead of Monitor.VideoWriter, Event.DefaultVideo is used, so even if VideoWriter/SaveJPEG option is changed, a valid image or video will always be displayed for historical events in both timeline and event view this also fixes loading videos in timeline view * Fixes problem of crashing zmc when bad packet arrives causing av_interleaved_write_frame() to return non-zero (-22). Prefilters common packet issues. Add metadata title to generated video file * Remove syslog.h * fixed SaveJPEGs are not working which is caused in errors introduced when merging with master * Update README.md * Fix build warnings specific to h264 branch, unused FrameImg, unused ret and int64_t snprintf issues * Fix PRId64 issue in travis, builds locally fine, but I can see a gcc version issue here * Fix PRId64 issue in travis, another try * Try "STDC_FORMAT_MACROS" to see if that helps Travis on gcc 4.6.3 * Revert space removal around PRId64 * video branch ffmpeg 2.9 fixes ffmpeg 2.9 patched removed SSE2 CPU * Add FFMPEGInit back * use webvvt to overlay timestamp (honoring Monitor.LabelFormat) to videos in timeline and event also fixed bug which prevented seeking in timeline video preview * ffmpeg 3.0 API build failure fixes * Update README.md * merge all the commits from the messed up iconnor_video branch * fix whitespace * revert * whitespace fixes * spelling fix * put back some text * add these back * fix spelling mistake * Steal some packet dumping routines from ffmpeg. Convert them to use our logging routines * add a test and error message if the codec is not h264 * these have been removed in master * add a view to check auth and just send the video * add some comments, and dump filename and AVFormatContext on failure to write header * add the toggle for RecordAudio so that the checkbox works to turn off Audio * Must init videoStore in constuctor * more debug and comments, return checking * Fix dropped part of sql query. * fix extra else and some whitespace * Fix missing } from merge that was preventing building. * fix tabs * get rid of use of separator, just use \n * Restore lost fixes for deprecation * Why are these failing * Respect record_audio flag when setting up video file so dont try and initiliase mp4 with unsupported audio * Forgot that I was trying to solve case of stream is true and record_audio is false. * Pass swscale_ctx back in to getCachedContext or it will create new context every frame and leak memory like a mofo. * Add libx264-dev and libmp4v2-dev to build requires to save hassle of ensuring they are installed before build. * Merge my Rotation/Orientation work and fixes for bad h264 streams * need arpa/inet for reverse lookups * pull in the new byte range code for viewing videos * Move our recording flag deeper into closeevent * add braces and only call closeEvent if there is an event * deprecate the z_frame_rate stuff which is deprecated in ffmpeg * remark out some debugging * fix for video on stream 1 * fix audio_stream to audio_st * Ignore bad decodes * fix problems with content-length causing viewing to not work in chrome/android * change logic of sending file contents to handle an off by one and be more readable * Some fixes pointed out by Maxim Romanov. Also simply the loading of events to not join the Monitors table * fix to sql for timeline * added RecordAudio to sql in README * Use sub queries instead of joins to fix errors when using new mysql defaults. * fix sql queries * Dockerfile to build feature-h264-videostorage * Must cast codec * add php-acpu as a dependency * require php5-acpu * fix typo * remove extra / * Add a line for out-of-tree builds to do api/lib/Cake/bootstrap.php * delete merge conflict files * delete merge conflict files
2017-05-16 10:02:48 +08:00
# x264 (using find_library and find_path)
find_library(X264_LIBRARIES x264)
if(X264_LIBRARIES)
set(HAVE_LIBX264 1)
list(APPEND ZM_BIN_LIBS "${X264_LIBRARIES}")
find_path(X264_INCLUDE_DIR x264.h)
if(X264_INCLUDE_DIR)
include_directories("${X264_INCLUDE_DIR}")
set(CMAKE_REQUIRED_INCLUDES "${X264_INCLUDE_DIR}")
endif(X264_INCLUDE_DIR)
mark_as_advanced(FORCE X264_LIBRARIES X264_INCLUDE_DIR)
check_include_files("stdint.h;x264.h" HAVE_X264_H)
set(optlibsfound "${optlibsfound} x264")
else(X264_LIBRARIES)
set(optlibsnotfound "${optlibsnotfound} x264")
endif(X264_LIBRARIES)
# mp4v2 (using find_library and find_path)
find_library(MP4V2_LIBRARIES mp4v2)
if(MP4V2_LIBRARIES)
set(HAVE_LIBMP4V2 1)
list(APPEND ZM_BIN_LIBS "${MP4V2_LIBRARIES}")
# mp4v2/mp4v2.h
find_path(MP4V2_INCLUDE_DIR mp4v2/mp4v2.h)
if(MP4V2_INCLUDE_DIR)
include_directories("${MP4V2_INCLUDE_DIR}")
set(CMAKE_REQUIRED_INCLUDES "${MP4V2_INCLUDE_DIR}")
endif(MP4V2_INCLUDE_DIR)
check_include_file("mp4v2/mp4v2.h" HAVE_MP4V2_MP4V2_H)
# mp4v2.h
find_path(MP4V2_INCLUDE_DIR mp4v2.h)
if(MP4V2_INCLUDE_DIR)
include_directories("${MP4V2_INCLUDE_DIR}")
set(CMAKE_REQUIRED_INCLUDES "${MP4V2_INCLUDE_DIR}")
endif(MP4V2_INCLUDE_DIR)
check_include_file("mp4v2.h" HAVE_MP4V2_H)
# mp4.h
find_path(MP4V2_INCLUDE_DIR mp4.h)
if(MP4V2_INCLUDE_DIR)
include_directories("${MP4V2_INCLUDE_DIR}")
set(CMAKE_REQUIRED_INCLUDES "${MP4V2_INCLUDE_DIR}")
endif(MP4V2_INCLUDE_DIR)
check_include_file("mp4.h" HAVE_MP4_H)
mark_as_advanced(FORCE MP4V2_LIBRARIES MP4V2_INCLUDE_DIR)
set(optlibsfound "${optlibsfound} mp4v2")
else(MP4V2_LIBRARIES)
set(optlibsnotfound "${optlibsnotfound} mp4v2")
endif(MP4V2_LIBRARIES)
set(PATH_FFMPEG "")
set(OPT_FFMPEG "no")
# 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" /usr/include/ffmpeg)
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)
2013-10-21 22:13:07 +08:00
set(optlibsfound "${optlibsfound} AVFormat")
else(AVFORMAT_LIBRARIES)
2013-10-21 22:13:07 +08:00
set(optlibsnotfound "${optlibsnotfound} AVFormat")
endif(AVFORMAT_LIBRARIES)
2013-09-28 17:59:50 +08:00
# 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" /usr/include/ffmpeg)
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)
2013-10-21 22:13:07 +08:00
set(optlibsfound "${optlibsfound} AVCodec")
else(AVCODEC_LIBRARIES)
2013-10-21 22:13:07 +08:00
set(optlibsnotfound "${optlibsnotfound} AVCodec")
endif(AVCODEC_LIBRARIES)
2013-09-28 17:59:50 +08:00
# 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" /usr/include/ffmpeg)
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)
2013-10-21 22:13:07 +08:00
set(optlibsfound "${optlibsfound} AVDevice")
else(AVDEVICE_LIBRARIES)
2013-10-21 22:13:07 +08:00
set(optlibsnotfound "${optlibsnotfound} AVDevice")
endif(AVDEVICE_LIBRARIES)
2013-09-28 17:59:50 +08:00
# 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" /usr/include/ffmpeg)
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)
2013-10-21 22:13:07 +08:00
set(optlibsfound "${optlibsfound} AVUtil")
else(AVUTIL_LIBRARIES)
2013-10-21 22:13:07 +08:00
set(optlibsnotfound "${optlibsnotfound} AVUtil")
endif(AVUTIL_LIBRARIES)
2013-09-28 17:59:50 +08:00
# 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" /usr/include/ffmpeg)
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)
2013-10-21 22:13:07 +08:00
set(optlibsfound "${optlibsfound} SWScale")
else(SWSCALE_LIBRARIES)
2013-10-21 22:13:07 +08:00
set(optlibsnotfound "${optlibsnotfound} SWScale")
endif(SWSCALE_LIBRARIES)
# rescale (using find_library and find_path)
find_library(AVRESAMPLE_LIBRARIES avresample)
if(AVRESAMPLE_LIBRARIES)
set(HAVE_LIBAVRESAMPLE 1)
list(APPEND ZM_BIN_LIBS "${AVRESAMPLE_LIBRARIES}")
find_path(AVRESAMPLE_INCLUDE_DIR "libavresample/avresample.h" /usr/include/ffmpeg)
if(AVRESAMPLE_INCLUDE_DIR)
include_directories("${AVRESAMPLE_INCLUDE_DIR}")
set(CMAKE_REQUIRED_INCLUDES "${AVRESAMPLE_INCLUDE_DIR}")
endif(AVRESAMPLE_INCLUDE_DIR)
mark_as_advanced(FORCE AVRESAMPLE_LIBRARIES AVRESAMPLE_INCLUDE_DIR)
check_include_file("libavresample/avresample.h" HAVE_LIBAVRESAMPLE_AVRESAMPLE_H)
set(optlibsfound "${optlibsfound} AVResample")
else(AVRESAMPLE_LIBRARIES)
set(optlibsnotfound "${optlibsnotfound} AVResample")
endif(AVRESAMPLE_LIBRARIES)
# Find the path to the ffmpeg executable
2015-05-24 21:39:44 +08:00
find_program(FFMPEG_EXECUTABLE
NAMES ffmpeg avconv
PATH_SUFFIXES ffmpeg)
if(FFMPEG_EXECUTABLE)
set(PATH_FFMPEG "${FFMPEG_EXECUTABLE}")
set(OPT_FFMPEG "yes")
mark_as_advanced(FFMPEG_EXECUTABLE)
endif(FFMPEG_EXECUTABLE)
endif(NOT ZM_NO_FFMPEG)
2013-09-28 17:59:50 +08:00
2013-12-13 01:45:29 +08:00
# Do not check for libvlc if ZM_NO_LIBVLC is on
if(NOT ZM_NO_LIBVLC)
# libvlc (using find_library and find_path)
find_library(LIBVLC_LIBRARIES vlc)
if(LIBVLC_LIBRARIES)
set(HAVE_LIBVLC 1)
list(APPEND ZM_BIN_LIBS "${LIBVLC_LIBRARIES}")
find_path(LIBVLC_INCLUDE_DIR "vlc/vlc.h")
if(LIBVLC_INCLUDE_DIR)
include_directories("${LIBVLC_INCLUDE_DIR}")
set(CMAKE_REQUIRED_INCLUDES "${LIBVLC_INCLUDE_DIR}")
endif(LIBVLC_INCLUDE_DIR)
mark_as_advanced(FORCE LIBVLC_LIBRARIES LIBVLC_INCLUDE_DIR)
2013-12-21 12:47:12 +08:00
check_include_file("vlc/vlc.h" HAVE_VLC_VLC_H)
2013-12-13 01:45:29 +08:00
set(optlibsfound "${optlibsfound} libVLC")
else(LIBVLC_LIBRARIES)
set(optlibsnotfound "${optlibsnotfound} libVLC")
endif(LIBVLC_LIBRARIES)
endif(NOT ZM_NO_LIBVLC)
find_package(Boost 1.36.0)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
set(CMAKE_REQUIRED_INCLUDES "${Boost_INCLUDE_DIRS}")
list(APPEND ZM_BIN_LIBS "${Boost_LIBRARIES}")
endif()
2013-09-28 17:59:50 +08:00
# *** END OF LIBRARY CHECKS ***
# Check for gnutls or crypto
if((NOT HAVE_LIBCRYPTO) AND (NOT HAVE_LIBGNUTLS))
message(FATAL_ERROR
"ZoneMinder requires crypto or gnutls but none were found on your system")
2013-09-28 17:59:50 +08:00
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)
2015-04-04 07:21:28 +08:00
if(HAVE_LINUX_VIDEODEV_H OR HAVE_LIBV4L1_VIDEODEV_H)
2013-09-28 17:59:50 +08:00
set(ZM_HAS_V4L 1)
set(ZM_HAS_V4L1 1)
2015-04-04 07:21:28 +08:00
endif(HAVE_LINUX_VIDEODEV_H OR HAVE_LIBV4L1_VIDEODEV_H)
2013-09-28 17:59:50 +08:00
if(HAVE_LINUX_VIDEODEV2_H)
set(ZM_HAS_V4L 1)
set(ZM_HAS_V4L2 1)
endif(HAVE_LINUX_VIDEODEV2_H)
if((NOT HAVE_LINUX_VIDEODEV_H)
AND (NOT HAVE_LIBV4L1_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_LIBV4L1_VIDEODEV_H)
AND (NOT HAVE_LINUX_VIDEODEV2_H))
2013-09-28 17:59:50 +08:00
# Check for PCRE and enable ZM_PCRE accordingly
set(ZM_PCRE 0)
2013-09-28 17:59:50 +08:00
if(HAVE_LIBPCRE AND HAVE_PCRE_H)
set(ZM_PCRE 1)
endif(HAVE_LIBPCRE AND HAVE_PCRE_H)
# 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)
set(ENABLE_MMAP yes)
set(ZM_MMAP_PERLPACKAGE "Sys::Mmap")
endif(NOT ZM_NO_MMAP)
2013-09-28 17:59:50 +08:00
# Check for the ONVIF flag and enable ZM_HAS_ONVIF accordingly
set(ZM_HAS_ONVIF 0)
if(ZM_ONVIF)
set(ZM_HAS_ONVIF 1)
endif(ZM_ONVIF)
# Check for authentication functions
2013-09-28 17:59:50 +08:00
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)
2013-09-28 17:59:50 +08:00
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)
2013-09-28 17:59:50 +08:00
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)
2013-09-28 17:59:50 +08:00
endif(HAVE_GNUTLS_GNUTLS_H)
if(HAVE_MD5_OPENSSL OR HAVE_MD5_GNUTLS)
set(HAVE_DECL_MD5 1)
else(HAVE_MD5_OPENSSL OR HAVE_MD5_GNUTLS)
message(AUTHOR_WARNING
"ZoneMinder requires a working MD5 function for hashed authenication but
none were found - hashed authenication will not be available")
2013-09-28 17:59:50 +08:00
endif(HAVE_MD5_OPENSSL OR HAVE_MD5_GNUTLS)
# Dirty fix for zm_user only using openssl's md5 if gnutls and gcrypt are not available.
# This needs to be fixed in zm_user.[h,cpp] but such fix will also require changes to configure.ac
if(HAVE_LIBCRYPTO AND HAVE_OPENSSL_MD5_H AND HAVE_MD5_OPENSSL)
set(HAVE_GCRYPT_H 0)
set(HAVE_GNUTLS_OPENSSL_H 0)
endif(HAVE_LIBCRYPTO AND HAVE_OPENSSL_MD5_H AND HAVE_MD5_OPENSSL)
# Check for Perl
2013-09-28 17:59:50 +08:00
find_package(Perl)
if(NOT PERL_FOUND)
message(FATAL_ERROR
"ZoneMinder requires Perl 5.6.0 or newer but it was not found on your system")
2013-09-28 17:59:50 +08:00
endif(NOT PERL_FOUND)
2013-09-28 17:59:50 +08:00
# Checking for perl modules requires FindPerlModules.cmake
# Check all required modules at once
# TODO: Add checking for the optional modules
find_package(
PerlModules COMPONENTS Sys::Syslog DBI DBD::mysql
Getopt::Long Time::HiRes Date::Manip LWP::UserAgent
ExtUtils::MakeMaker ${ZM_MMAP_PERLPACKAGE})
2013-09-28 17:59:50 +08:00
if(NOT PERLMODULES_FOUND)
message(FATAL_ERROR
"Not all required perl modules were found on your system")
2013-09-28 17:59:50 +08:00
endif(NOT PERLMODULES_FOUND)
# Attempt to check which user apache (or other web server) runs on by
# searching for a user beginning with apache or www and then cutting the user
# from the first matching user line
2013-09-28 17:59:50 +08:00
if(ZM_WEB_USER STREQUAL "")
# Check for a user matching ^apache and cut the username from the
# userline in the first match
2013-09-28 17:59:50 +08:00
file(STRINGS "/etc/passwd" userline_apache REGEX "^apache")
file(STRINGS "/etc/passwd" userline_www REGEX "^www")
if(NOT (userline_apache STREQUAL ""))
execute_process(
COMMAND echo ${userline_apache}
COMMAND cut -d: -f1 OUTPUT_VARIABLE ZM_WEB_USER
OUTPUT_STRIP_TRAILING_WHITESPACE)
2013-09-28 17:59:50 +08:00
elseif(NOT (userline_www STREQUAL ""))
execute_process(
COMMAND echo ${userline_www}
COMMAND cut -d: -f1 OUTPUT_VARIABLE ZM_WEB_USER
OUTPUT_STRIP_TRAILING_WHITESPACE)
2013-09-28 17:59:50 +08:00
endif(NOT (userline_apache STREQUAL ""))
message(STATUS "Detected web server user: ${ZM_WEB_USER}")
endif(ZM_WEB_USER STREQUAL "")
# Check if webgroup contains anything. If not, use the web user as the web group
if(NOT ZM_WEB_GROUP)
set(ZM_WEB_GROUP ${ZM_WEB_USER})
endif(NOT ZM_WEB_GROUP)
message(STATUS "Using web user: ${ZM_WEB_USER}")
message(STATUS "Using web group: ${ZM_WEB_GROUP}")
if(WITH_SYSTEMD)
# Check for polkit
find_package(Polkit)
if(NOT POLKIT_FOUND)
message(FATAL_ERROR
"Running ZoneMinder requires polkit. Building ZoneMinder requires the polkit development package.")
endif(NOT POLKIT_FOUND)
endif(WITH_SYSTEMD)
2014-08-10 21:47:11 +08:00
2013-09-28 17:59:50 +08:00
# Some variables that zm expects
set(ZM_PID "${ZM_RUNDIR}/zm.pid")
set(ZM_CONFIG "${ZM_CONFIG_DIR}/zm.conf")
set(VERSION "${zoneminder_VERSION}")
set(API_VERSION "${zoneminder_API_VERSION}")
set(PKGDATADIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/zoneminder")
2013-09-28 17:59:50 +08:00
set(BINDIR "${CMAKE_INSTALL_FULL_BINDIR}")
set(LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}")
set(SYSCONFDIR "/${CMAKE_INSTALL_SYSCONFDIR}")
set(WEB_PREFIX "${ZM_WEBDIR}")
set(CGI_PREFIX "${ZM_CGIDIR}")
set(WEB_USER "${ZM_WEB_USER}")
set(WEB_GROUP "${ZM_WEB_GROUP}")
set(ZM_DB_TYPE "mysql")
if(ZM_PERL_SEARCH_PATH)
set(EXTRA_PERL_LIB "use lib '${ZM_PERL_SEARCH_PATH}'; # Include custom perl install path")
else(ZM_PERL_SEARCH_PATH)
set(EXTRA_PERL_LIB "# Include from system perl paths only")
endif(ZM_PERL_SEARCH_PATH)
2013-09-28 17:59:50 +08:00
# If this is an out-of-source build, copy the files we need to the binary directory
if(NOT (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR))
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/conf.d" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/conf.d")
endif(NOT (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR))
2013-09-28 17:59:50 +08:00
# Generate files from the .in files
configure_file(zm.conf.in "${CMAKE_CURRENT_BINARY_DIR}/zm.conf" @ONLY)
configure_file(zoneminder-config.cmake "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY)
configure_file(zmconfgen.pl.in "${CMAKE_CURRENT_BINARY_DIR}/zmconfgen.pl" @ONLY)
configure_file(zmlinkcontent.sh.in "${CMAKE_CURRENT_BINARY_DIR}/zmlinkcontent.sh" @ONLY)
2013-09-28 17:59:50 +08:00
# Create a target for man pages
include(Pod2Man)
ADD_MANPAGE_TARGET()
2013-09-28 17:59:50 +08:00
# Process subdirectories
add_subdirectory(src)
add_subdirectory(scripts)
add_subdirectory(db)
add_subdirectory(web)
2014-08-10 21:47:11 +08:00
add_subdirectory(misc)
2014-11-01 08:23:18 +08:00
# Enable ONVIF support
2015-04-09 23:44:16 +08:00
if(ZM_ONVIF)
2014-11-01 08:23:18 +08:00
add_subdirectory(onvif)
2015-04-09 23:44:16 +08:00
endif(ZM_ONVIF)
2014-08-10 21:47:11 +08:00
# Process distro subdirectories
if((ZM_TARGET_DISTRO MATCHES "^el") OR (ZM_TARGET_DISTRO MATCHES "^fc"))
add_subdirectory(distros/redhat)
elseif(ZM_TARGET_DISTRO STREQUAL "OS13")
add_subdirectory(distros/opensuse)
endif((ZM_TARGET_DISTRO MATCHES "^el") OR (ZM_TARGET_DISTRO MATCHES "^fc"))
2013-09-28 17:59:50 +08:00
# Print optional libraries detection status
message(STATUS "Optional libraries found:${optlibsfound}")
message(STATUS "Optional libraries not found:${optlibsnotfound}")
2013-09-28 17:59:50 +08:00
# Run ZM configuration generator
message(STATUS "Running ZoneMinder configuration generator")
execute_process(COMMAND perl ./zmconfgen.pl RESULT_VARIABLE zmconfgen_result)
if(zmconfgen_result EQUAL 0)
message(STATUS
"ZoneMinder configuration generator completed successfully")
2013-09-28 17:59:50 +08:00
else(zmconfgen_result EQUAL 0)
message(FATAL_ERROR
"ZoneMinder configuration generator failed. Exit code: ${zmconfgen_result}")
2013-09-28 17:59:50 +08:00
endif(zmconfgen_result EQUAL 0)
# Install zm.conf and conf.d subfolder
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zm.conf" DESTINATION "${ZM_CONFIG_DIR}")
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/conf.d/" DESTINATION "${ZM_CONFIG_SUBDIR}")
2013-09-28 17:59:50 +08:00
# 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)
2016-07-24 07:26:10 +08:00
# Configure CCache if available
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif(CCACHE_FOUND)
2017-04-27 03:18:32 +08:00