2018-02-17 15:46:02 +00:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
2014-08-15 19:11:03 +00:00
|
|
|
|
|
|
|
# set project name from current directory
|
2014-08-15 20:33:40 +00:00
|
|
|
get_filename_component(BASENAME ${CMAKE_SOURCE_DIR} NAME)
|
|
|
|
project(${BASENAME})
|
2014-08-15 19:11:03 +00:00
|
|
|
|
2016-01-30 11:43:46 +00:00
|
|
|
option(COVERAGE "Coverage" OFF)
|
|
|
|
|
2018-09-22 18:56:46 +00:00
|
|
|
set (CMAKE_CXX_STANDARD 11)
|
2014-09-05 19:33:27 +00:00
|
|
|
set(CMAKE_C_FLAGS "-Wall")
|
2018-09-22 18:56:46 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "-Wall")
|
2018-08-31 22:24:46 +00:00
|
|
|
SET(CMAKE_FIND_ROOT_PATH "${CMAKE_SOURCE_DIR}/${CMAKE_SYSTEM_PROCESSOR}")
|
2014-09-05 19:33:27 +00:00
|
|
|
|
2018-01-27 17:24:47 +00:00
|
|
|
# set version based on git
|
2017-04-23 14:40:07 +00:00
|
|
|
find_package(Git)
|
|
|
|
if(GIT_FOUND)
|
|
|
|
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty OUTPUT_VARIABLE VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2017-12-16 17:12:44 +00:00
|
|
|
STRING(REGEX REPLACE "^v(.*)" "\\1" VERSION "${VERSION}")
|
2017-04-23 14:40:07 +00:00
|
|
|
add_definitions("-DVERSION=\"${VERSION}\"")
|
|
|
|
endif()
|
|
|
|
|
2016-01-30 11:43:46 +00:00
|
|
|
|
2014-08-15 19:11:03 +00:00
|
|
|
# define executable to build
|
2015-10-11 17:11:44 +00:00
|
|
|
include_directories("inc")
|
2014-08-15 19:11:03 +00:00
|
|
|
aux_source_directory(src SRC_FILES)
|
|
|
|
add_executable(${PROJECT_NAME} ${SRC_FILES})
|
2015-01-25 21:55:04 +00:00
|
|
|
|
2016-01-30 11:43:46 +00:00
|
|
|
if (COVERAGE)
|
|
|
|
set(COVERAGE_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_FLAGS}")
|
2017-05-25 16:26:23 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_FLAGS}")
|
2016-01-30 11:43:46 +00:00
|
|
|
target_link_libraries(${PROJECT_NAME} gcov)
|
|
|
|
endif()
|
|
|
|
|
2018-01-28 14:39:18 +00:00
|
|
|
message(STATUS "CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
|
2018-01-27 17:24:47 +00:00
|
|
|
message(STATUS "CMAKE_C_COMPILER=${CMAKE_C_COMPILER}")
|
|
|
|
message(STATUS "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
|
|
|
|
message(STATUS "CMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}")
|
|
|
|
|
2015-01-25 21:55:04 +00:00
|
|
|
# v4l2wrapper
|
2015-10-11 17:11:44 +00:00
|
|
|
include_directories("v4l2wrapper/inc")
|
2018-02-25 22:53:00 +00:00
|
|
|
find_library(V4L2WRAPPER_LIBRARY libv4l2wrapper.a)
|
2015-09-06 17:05:34 +00:00
|
|
|
if (NOT V4L2WRAPPER_LIBRARY)
|
2016-09-16 19:50:35 +00:00
|
|
|
message(STATUS "Installing v4l2wrapper")
|
2018-08-31 22:24:46 +00:00
|
|
|
EXEC_PROGRAM("mkdir -p ${CMAKE_FIND_ROOT_PATH}/include/libv4l2cpp && mkdir -p ${CMAKE_FIND_ROOT_PATH}/lib")
|
|
|
|
EXEC_PROGRAM("git submodule init && git submodule update && make -C v4l2wrapper CC=${CMAKE_C_COMPILER} PREFIX=${CMAKE_FIND_ROOT_PATH} all install")
|
2018-02-25 22:53:00 +00:00
|
|
|
find_library(V4L2WRAPPER_LIBRARY libv4l2wrapper.a)
|
2015-10-11 17:42:56 +00:00
|
|
|
message(STATUS "v4l2wrapper built in V4L2WRAPPER_LIBRARY=${V4L2WRAPPER_LIBRARY}")
|
2015-09-06 17:05:34 +00:00
|
|
|
endif (NOT V4L2WRAPPER_LIBRARY)
|
|
|
|
target_link_libraries(${PROJECT_NAME} ${V4L2WRAPPER_LIBRARY})
|
2014-08-15 19:11:03 +00:00
|
|
|
|
2015-01-25 18:31:18 +00:00
|
|
|
#pthread
|
|
|
|
find_package (Threads)
|
|
|
|
target_link_libraries (${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
|
2016-06-19 17:15:51 +00:00
|
|
|
#ALSA
|
2017-05-25 16:26:23 +00:00
|
|
|
find_package(ALSA QUIET)
|
|
|
|
if (ALSA_LIBRARY)
|
2018-01-20 13:19:09 +00:00
|
|
|
message(STATUS "Alsa available")
|
2017-05-25 16:26:23 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_ALSA")
|
|
|
|
target_link_libraries (${PROJECT_NAME} ${ALSA_LIBRARY})
|
2018-01-20 17:43:12 +00:00
|
|
|
|
2018-01-20 18:16:31 +00:00
|
|
|
SET(CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}libasound2-dev,)
|
2017-05-25 16:26:23 +00:00
|
|
|
endif (ALSA_LIBRARY)
|
2016-06-19 17:15:51 +00:00
|
|
|
|
2014-11-22 14:35:59 +00:00
|
|
|
# LOG4CPP
|
|
|
|
find_path(LOG4CPP_INCLUDE_DIR log4cpp/Category.hh)
|
2017-12-09 16:18:36 +00:00
|
|
|
if (LOG4CPP_INCLUDE_DIR)
|
|
|
|
message(STATUS "Log4Cpp available")
|
2017-12-10 11:31:20 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_LOG4CPP")
|
2017-12-09 16:18:36 +00:00
|
|
|
include_directories(${LOG4CPP_INCLUDE_DIR})
|
2016-09-16 19:50:35 +00:00
|
|
|
|
2017-12-09 16:18:36 +00:00
|
|
|
find_library(LOG4CPP_LIBRARY log4cpp)
|
|
|
|
target_link_libraries(${PROJECT_NAME} "${LOG4CPP_LIBRARY}")
|
2018-01-20 17:43:12 +00:00
|
|
|
|
2018-01-20 18:16:31 +00:00
|
|
|
SET(CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}liblog4cpp5-dev,)
|
2017-12-09 16:18:36 +00:00
|
|
|
endif (LOG4CPP_INCLUDE_DIR)
|
2014-11-22 14:35:59 +00:00
|
|
|
|
|
|
|
|
2014-08-15 19:11:03 +00:00
|
|
|
# live555
|
2018-12-12 23:07:37 +00:00
|
|
|
find_path(LIBLIVE555_INCLUDE_DIR liveMedia/liveMedia.hh ONLY_CMAKE_FIND_ROOT_PATH)
|
2014-08-15 19:11:03 +00:00
|
|
|
if (NOT LIBLIVE555_INCLUDE_DIR)
|
2018-01-20 17:43:12 +00:00
|
|
|
message(STATUS "Installing live555")
|
2018-01-20 13:19:09 +00:00
|
|
|
EXEC_PROGRAM("wget http://www.live555.com/liveMedia/public/live555-latest.tar.gz -O - | tar xzf -")
|
2018-12-08 23:06:12 +00:00
|
|
|
EXEC_PROGRAM("cd live && ./genMakefiles linux-gdb && make CPLUSPLUS_COMPILER='${CMAKE_CXX_COMPILER} -DALLOW_RTSP_SERVER_PORT_REUSE=1' C_COMPILER=${CMAKE_C_COMPILER} LINK='${CMAKE_CXX_COMPILER} -o' PREFIX=${CMAKE_FIND_ROOT_PATH} install")
|
2014-08-15 19:11:03 +00:00
|
|
|
endif (NOT LIBLIVE555_INCLUDE_DIR)
|
2016-09-16 19:50:35 +00:00
|
|
|
|
2018-12-12 23:07:37 +00:00
|
|
|
find_path(LIBLIVE555_INCLUDE_DIR liveMedia/liveMedia.hh ONLY_CMAKE_FIND_ROOT_PATH)
|
2014-08-15 19:11:03 +00:00
|
|
|
foreach (LIBLIVE555_module groupsock liveMedia UsageEnvironment BasicUsageEnvironment)
|
|
|
|
include_directories(${LIBLIVE555_INCLUDE_DIR}/${LIBLIVE555_module})
|
|
|
|
endforeach (LIBLIVE555_module)
|
2018-09-22 18:56:46 +00:00
|
|
|
message(STATUS "live555 available '${LIBLIVE555_INCLUDE_DIR}'")
|
2014-08-15 19:11:03 +00:00
|
|
|
|
|
|
|
set(LIBLIVE555_LIBRARIES "")
|
|
|
|
foreach (LIBLIVE555_module groupsock liveMedia UsageEnvironment BasicUsageEnvironment)
|
2018-12-08 23:06:12 +00:00
|
|
|
find_library( ${LIBLIVE555_module}_LIBRARY ${LIBLIVE555_module} ONLY_CMAKE_FIND_ROOT_PATH)
|
2014-08-15 19:11:03 +00:00
|
|
|
if ( ${LIBLIVE555_module}_LIBRARY )
|
|
|
|
set(LIBLIVE555_LIBRARIES ${LIBLIVE555_LIBRARIES} ${${LIBLIVE555_module}_LIBRARY})
|
|
|
|
endif ( ${LIBLIVE555_module}_LIBRARY )
|
|
|
|
endforeach (LIBLIVE555_module)
|
|
|
|
target_link_libraries(${PROJECT_NAME} ${LIBLIVE555_LIBRARIES})
|
2018-12-08 23:06:12 +00:00
|
|
|
message(STATUS "live555 available '${LIBLIVE555_LIBRARIES}'")
|
2014-08-15 19:11:03 +00:00
|
|
|
|
2016-01-30 11:43:46 +00:00
|
|
|
#testing
|
|
|
|
enable_testing()
|
|
|
|
add_test(help ./${PROJECT_NAME} -h)
|
|
|
|
|
2018-01-20 19:45:26 +00:00
|
|
|
#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)
|
2018-12-08 14:44:43 +00:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/v4l2rtspserver.service DESTINATION ${SYSTEMD_SERVICES_INSTALL_DIR})
|
2018-01-20 19:45:26 +00:00
|
|
|
endif (SYSTEMD_FOUND)
|
|
|
|
|
2014-08-15 20:33:40 +00:00
|
|
|
# package
|
2018-12-08 14:44:43 +00:00
|
|
|
install (TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
|
|
|
|
install (FILES index.html DESTINATION share/${PROJECT_NAME}/)
|
2018-12-08 15:14:30 +00:00
|
|
|
install (FILES hls.js/dist/hls.light.min.js DESTINATION share/${PROJECT_NAME}/hls.js/dist/)
|
2014-08-15 22:27:47 +00:00
|
|
|
|
2018-02-04 18:16:40 +00:00
|
|
|
SET(CPACK_GENERATOR "DEB")
|
2014-08-15 20:33:40 +00:00
|
|
|
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Michel Promonet")
|
|
|
|
SET(CPACK_PACKAGE_CONTACT "michel.promonet@free.fr")
|
2015-11-21 18:03:31 +00:00
|
|
|
SET(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
|
2018-01-20 18:23:20 +00:00
|
|
|
STRING(REGEX REPLACE ",$" "" CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}")
|
2018-12-08 14:44:43 +00:00
|
|
|
SET(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
|
2017-04-23 14:40:07 +00:00
|
|
|
if(VERSION)
|
2015-10-17 12:45:34 +00:00
|
|
|
SET(CPACK_PACKAGE_VERSION "${VERSION}")
|
|
|
|
endif()
|
2014-08-15 20:33:40 +00:00
|
|
|
INCLUDE(CPack)
|
|
|
|
|