v4l2rtspserver/CMakeLists.txt

104 lines
3.6 KiB
CMake
Raw Normal View History

2014-08-15 19:11:03 +00:00
cmake_minimum_required(VERSION 2.6)
# 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)
2014-09-05 19:33:27 +00:00
set(CMAKE_BUILD_TYPE DEBUG)
set(CMAKE_C_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS "-Wall")
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})
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}")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_FLAGS}")
target_link_libraries(${PROJECT_NAME} gcov)
endif()
# v4l2wrapper
2015-10-11 17:11:44 +00:00
include_directories("v4l2wrapper/inc")
2015-10-31 21:36:50 +00:00
find_library(V4L2WRAPPER_LIBRARY libv4l2wrapper.a PATHS ".")
if (NOT V4L2WRAPPER_LIBRARY)
2016-09-16 19:50:35 +00:00
message(STATUS "Installing v4l2wrapper")
2015-10-31 21:36:50 +00:00
EXEC_PROGRAM("git submodule init && git submodule update && make -C v4l2wrapper CC=${CMAKE_C_COMPILER} CFLAGS_EXTRA=--sysroot=${CMAKE_FIND_ROOT_PATH} && cp v4l2wrapper/libv4l2wrapper.a . && make -C v4l2wrapper clean")
find_library(V4L2WRAPPER_LIBRARY libv4l2wrapper.a PATHS ".")
message(STATUS "v4l2wrapper built in V4L2WRAPPER_LIBRARY=${V4L2WRAPPER_LIBRARY}")
endif (NOT V4L2WRAPPER_LIBRARY)
target_link_libraries(${PROJECT_NAME} ${V4L2WRAPPER_LIBRARY})
2014-08-15 19:11:03 +00:00
#pthread
find_package (Threads)
target_link_libraries (${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
2016-06-19 17:15:51 +00:00
#ALSA
2016-09-16 19:50:35 +00:00
find_package(ALSA)
if (NOT ALSA_LIBRARY)
message(STATUS "Installing libasound2-dev.")
EXEC_PROGRAM("sudo apt-get install -y libasound2-dev")
endif (NOT ALSA_LIBRARY)
2016-06-19 17:15:51 +00:00
find_package(ALSA)
target_link_libraries (${PROJECT_NAME} ${ALSA_LIBRARY})
2014-11-22 14:35:59 +00:00
# LOG4CPP
find_path(LOG4CPP_INCLUDE_DIR log4cpp/Category.hh)
if (NOT LOG4CPP_INCLUDE_DIR)
2016-09-16 19:50:35 +00:00
message(STATUS "Installing liblog4cpp5-dev.")
EXEC_PROGRAM("sudo apt-get install -y liblog4cpp5-dev")
2014-11-22 14:35:59 +00:00
endif (NOT LOG4CPP_INCLUDE_DIR)
2016-09-16 19:50:35 +00:00
find_path(V4L2_INCLUDE_DIR log4cpp/Category.hh)
2014-11-22 14:35:59 +00:00
include_directories(${LOG4CPP_INCLUDE_DIR})
find_library(LOG4CPP_LIBRARY log4cpp)
target_link_libraries(${PROJECT_NAME} "${LOG4CPP_LIBRARY}")
2014-08-15 19:11:03 +00:00
# live555
find_path(LIBLIVE555_INCLUDE_DIR liveMedia/liveMedia.hh)
if (NOT LIBLIVE555_INCLUDE_DIR)
2016-09-16 19:50:35 +00:00
message(STATUS "Installing liblivemedia-dev")
EXEC_PROGRAM("sudo apt-get install -y liblivemedia-dev")
2014-08-15 19:11:03 +00:00
endif (NOT LIBLIVE555_INCLUDE_DIR)
2016-09-16 19:50:35 +00:00
find_path(LIBLIVE555_INCLUDE_DIR liveMedia/liveMedia.hh)
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)
set(LIBLIVE555_LIBRARIES "")
foreach (LIBLIVE555_module groupsock liveMedia UsageEnvironment BasicUsageEnvironment)
find_library( ${LIBLIVE555_module}_LIBRARY ${LIBLIVE555_module} )
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})
2016-01-30 11:43:46 +00:00
#testing
enable_testing()
add_test(help ./${PROJECT_NAME} -h)
2014-08-15 20:33:40 +00:00
# package
2014-08-15 22:27:47 +00:00
install (TARGETS ${PROJECT_NAME} DESTINATION bin)
2014-08-15 20:33:40 +00:00
SET(CPACK_GENERATOR "DEB")
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})
2015-10-17 12:45:34 +00:00
find_package(Git)
if(GIT_FOUND)
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty OUTPUT_VARIABLE VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
STRING(REGEX REPLACE "^v(.*)" "\\1" VERSION ${VERSION})
SET(CPACK_PACKAGE_VERSION "${VERSION}")
endif()
2014-08-15 20:33:40 +00:00
INCLUDE(CPack)