add systemd startup script

This commit is contained in:
Michel Promonet 2018-01-20 20:45:26 +01:00
parent fdb5b9a708
commit f7136b173b
2 changed files with 19 additions and 0 deletions

View File

@ -97,6 +97,19 @@ target_link_libraries(${PROJECT_NAME} ${LIBLIVE555_LIBRARIES})
enable_testing()
add_test(help ./${PROJECT_NAME} -h)
#systemd
find_package(PkgConfig)
pkg_check_modules(SYSTEMD systemd QUIET)
if (SYSTEMD_FOUND)
message(STATUS "SystemD available")
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=systemdsystemunitdir systemd OUTPUT_VARIABLE SYSTEMD_SERVICES_INSTALL_DIR)
string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_SERVICES_INSTALL_DIR "${SYSTEMD_SERVICES_INSTALL_DIR}")
message(STATUS "SystemD directory '${SYSTEMD_SERVICES_INSTALL_DIR}'")
configure_file(v4l2rtspserver.service.in ${CMAKE_CURRENT_BINARY_DIR}/v4l2rtspserver.service @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/v4l2rtspserver.service DESTINATION ${SYSTEMD_SERVICES_INSTALL_DIR} COMPONENT data)
endif (SYSTEMD_FOUND)
# package
install (TARGETS ${PROJECT_NAME} DESTINATION bin)

View File

@ -0,0 +1,6 @@
[Unit]
Description=V4L2 RTSP server
[Service]
Type=simple
ExecStart=@CMAKE_INSTALL_PREFIX@/bin/v4l2rtspserver