forked from Motion-Project/motion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
138 lines (119 loc) · 5.8 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
project(motion C)
cmake_minimum_required(VERSION 2.8)
unset(SQLITE3_FOUND CACHE )
unset(FFMPEG_FOUND CACHE )
include(CheckIncludeFiles)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
execute_process(COMMAND sh "${CMAKE_CURRENT_SOURCE_DIR}/version.sh" OUTPUT_VARIABLE VERSION)
set(BIN_PATH "${CMAKE_INSTALL_PREFIX}/bin")
set(sysconfdir "${CMAKE_INSTALL_PREFIX}/etc" CACHE STRING "system configuration directory")
set(PACKAGE_NAME ${PROJECT_NAME} CACHE STRING "package name")
set(PACKAGE_VERSION ${VERSION} CACHE STRING "package version")
find_package(PkgConfig REQUIRED)
find_package(Threads REQUIRED)
find_package(JPEG REQUIRED)
find_package(MMAL)
find_package(MySQL)
find_package(PostgreSQL)
pkg_check_modules(SQLITE3 sqlite3)
option(WITH_FFMPEG "enable FFmpeg support for encoding/decoding video" ON)
option(WITH_MMAL "enable MMAL (Multi-Media Abstraction Layer API) support for Raspberry Pi" ${MMAL_FOUND})
option(WITH_MYSQL "enable MySQL database support" ${MYSQL_FOUND})
option(WITH_PGSQL "enable PostgreSQL database support" ${PostgreSQL_FOUND})
option(WITH_SQLITE3 "enable SQLite database support" ${SQLITE3_FOUND})
option(WITH_V4L2 "enable Video 4 Linux (2) webcam support" ON)
option(WITH_BKTR "enable BKTR support (BSD only)" OFF)
set(HAVE_FFMPEG ${WITH_FFMPEG})
set(HAVE_MMAL ${WITH_MMAL})
set(HAVE_MYSQL ${WITH_MYSQL})
set(HAVE_PGSQL ${WITH_PGSQL})
set(HAVE_SQLITE3 ${WITH_SQLITE3})
set(HAVE_V4L2 OFF)
check_include_files("linux/videodev2.h" HAVE_LINUX_VIDEODEV2_H)
if(HAVE_LINUX_VIDEODEV2_H AND WITH_V4L2)
set(HAVE_V4L2 ON )
endif(HAVE_LINUX_VIDEODEV2_H AND WITH_V4L2)
set(HAVE_BKTR OFF)
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
check_include_files("dev/bktr/ioctl_bt848.h" HAVE_FREEBSD_BT848)
check_include_files("dev/bktr/ioctl_meteor.h" HAVE_FREEBSD_METEOR)
if(HAVE_FREEBSD_BT848 AND HAVE_FREEBSD_METEOR AND WITH_BKTR)
set(HAVE_BKTR ON )
endif(HAVE_FREEBSD_BT848 AND HAVE_FREEBSD_METEOR AND WITH_BKTR)
endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
if(CMAKE_SYSTEM_NAME MATCHES "NetBSD" OR CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
check_include_files("dev/ic/bt8xx.h" HAVE_NETOPEN_BT8XX)
if(HAVE_NETOPEN_BT8XX AND WITH_BKTR)
set(HAVE_BKTR ON )
endif(HAVE_NETOPEN_BT8XX AND WITH_BKTR)
endif(CMAKE_SYSTEM_NAME MATCHES "NetBSD" OR CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
configure_file(config.h.in "${CMAKE_CURRENT_SOURCE_DIR}/config.h")
configure_file(motion-dist.conf.in motion-dist.conf)
configure_file(camera1-dist.conf.in camera1-dist.conf)
configure_file(camera2-dist.conf.in camera2-dist.conf)
configure_file(camera3-dist.conf.in camera3-dist.conf)
configure_file(camera4-dist.conf.in camera4-dist.conf)
configure_file(motion.service.in motion.service)
configure_file(motion.spec.in motion.spec)
configure_file(motion.init-Debian.in motion.init-Debian)
configure_file(motion.init-FreeBSD.sh.in motion.init-FreeBSD.sh)
list(APPEND SRC_FILES
conf.c motion.c alg.c draw.c event.c ffmpeg.c jpegutils.c logger.c md5.c
netcam.c netcam_ftp.c netcam_jpeg.c netcam_rtsp.c netcam_wget.c
picture.c rotate.c stream.c track.c video_loopback.c webhttpd.c
video_v4l2.c video_common.c video_bktr.c)
include_directories(${JPEG_INCLUDE_DIR})
list(APPEND LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${JPEG_LIBRARIES})
if(WITH_FFMPEG)
pkg_check_modules(FFMPEG REQUIRED libavutil libavformat libavcodec libswscale)
include_directories(${FFMPEG_INCLUDE_DIRS})
link_directories(${FFMPEG_LIBRARY_DIRS})
list(APPEND LINK_LIBRARIES ${FFMPEG_LIBRARIES})
endif(WITH_FFMPEG)
if(WITH_MYSQL)
find_package(MySQL REQUIRED)
include_directories(${MYSQL_INCLUDE_DIRS})
list(APPEND LINK_LIBRARIES ${MYSQL_LIBRARIES})
endif(WITH_MYSQL)
if(WITH_PGSQL)
find_package(PostgreSQL REQUIRED)
include_directories(${PostgreSQL_INCLUDE_DIRS})
list(APPEND LINK_LIBRARIES ${PostgreSQL_LIBRARIES})
endif(WITH_PGSQL)
if(WITH_SQLITE3)
pkg_check_modules(SQLITE3 REQUIRED sqlite3)
include_directories(${SQLITE3_INCLUDE_DIRS})
link_directories(${SQLITE3_LIBRARY_DIRS})
list(APPEND LINK_LIBRARIES ${SQLITE3_LIBRARIES})
endif(WITH_SQLITE3)
if(WITH_MMAL)
find_package(MMAL REQUIRED)
list(APPEND SRC_FILES mmalcam.c)
endif(WITH_MMAL)
message("-- Configuration: " )
message("-- Package Name: " ${PACKAGE_NAME})
message("-- Package Version: " ${PACKAGE_VERSION})
message("-- Build System: " ${CMAKE_SYSTEM_NAME})
message("-- Config Dir: " ${sysconfdir})
message("-- Bin Dir: " ${BIN_PATH})
message("-- JPEG Include Dir: " ${JPEG_INCLUDE_DIR})
message("-- WITH_V4L2: " ${WITH_V4L2})
message("-- HAVE_V4L2: " ${HAVE_V4L2})
message("-- WITH_BKTR: " ${WITH_BKTR})
message("-- HAVE_BKTR: " ${HAVE_BKTR})
message("-- MYSQL: " ${WITH_MYSQL} " Include Dir: " ${MYSQL_INCLUDE_DIRS} )
message("-- SQLITE3: " ${WITH_SQLITE3} " Include Dir: " ${SQLITE3_INCLUDE_DIRS} )
message("-- PGSQL: " ${WITH_PGSQL} " Include Dir: " ${PostgreSQL_INCLUDE_DIRS} )
message("-- FFMPEG: " ${WITH_FFMPEG} " Include Dir: " ${FFMPEG_INCLUDE_DIRS} )
message("-- MMAL: " ${WITH_MMAL} )
message("-- CFLAGS: " ${CMAKE_C_FLAGS} )
add_executable(motion ${SRC_FILES})
target_link_libraries(motion ${LINK_LIBRARIES})
install(TARGETS motion DESTINATION "bin" COMPONENT binaries)
install(FILES motion-dist.conf camera1-dist.conf camera2-dist.conf camera3-dist.conf camera4-dist.conf
DESTINATION ${sysconfdir} COMPONENT configuration)
install(FILES motion.service motion.spec motion.init-Debian motion.init-FreeBSD.sh
DESTINATION "lib/${PROJECT_NAME}/examples" COMPONENT examples)
install(FILES CHANGELOG COPYING CREDITS README.md motion_guide.html mask1.png normal.jpg outputmotion1.jpg outputnormal1.jpg
DESTINATION "lib/${PROJECT_NAME}/doc" COMPONENT doc)