Build: Move V4L2 detection into its own module
Improves detection across different platforms (esp. FreeBSD) since system paths are automatically taken into account (this is in contrast to check_include_file).
This commit is contained in:
parent
615e3dd76b
commit
c83882a4c7
|
@ -268,7 +268,6 @@ if(ZM_SYSTEMD OR (IS_DIRECTORY /usr/lib/systemd/system) OR (IS_DIRECTORY /lib/sy
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# System checks
|
# System checks
|
||||||
check_include_file("linux/videodev2.h" HAVE_LINUX_VIDEODEV2_H)
|
|
||||||
check_include_file("execinfo.h" HAVE_EXECINFO_H)
|
check_include_file("execinfo.h" HAVE_EXECINFO_H)
|
||||||
if(HAVE_EXECINFO_H)
|
if(HAVE_EXECINFO_H)
|
||||||
check_function_exists("backtrace" HAVE_DECL_BACKTRACE)
|
check_function_exists("backtrace" HAVE_DECL_BACKTRACE)
|
||||||
|
@ -530,15 +529,16 @@ endif()
|
||||||
|
|
||||||
# Check for V4L header files and enable ZM_HAS_V4L, ZM_HAS_V4L2 accordingly
|
# Check for V4L header files and enable ZM_HAS_V4L, ZM_HAS_V4L2 accordingly
|
||||||
# Setting to zeros first is required because ZM uses #define for these
|
# Setting to zeros first is required because ZM uses #define for these
|
||||||
|
find_package(V4L2)
|
||||||
set(ZM_HAS_V4L 0)
|
set(ZM_HAS_V4L 0)
|
||||||
set(ZM_HAS_V4L2 0)
|
set(ZM_HAS_V4L2 0)
|
||||||
if(HAVE_LINUX_VIDEODEV2_H)
|
if(TARGET V4L2::videodev2)
|
||||||
set(ZM_HAS_V4L 1)
|
set(ZM_HAS_V4L 1)
|
||||||
set(ZM_HAS_V4L2 1)
|
set(ZM_HAS_V4L2 1)
|
||||||
endif()
|
else()
|
||||||
if(NOT HAVE_LINUX_VIDEODEV2_H)
|
|
||||||
message(AUTHOR_WARNING "Video 4 Linux headers weren't found - Analog and USB camera support will not be available")
|
message(AUTHOR_WARNING "Video 4 Linux headers weren't found - Analog and USB camera support will not be available")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Check for PCRE and enable ZM_PCRE accordingly
|
# Check for PCRE and enable ZM_PCRE accordingly
|
||||||
set(ZM_PCRE 0)
|
set(ZM_PCRE 0)
|
||||||
if(HAVE_LIBPCRE AND HAVE_PCRE_H)
|
if(HAVE_LIBPCRE AND HAVE_PCRE_H)
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
#[=======================================================================[.rst:
|
||||||
|
FindV4L2
|
||||||
|
----------
|
||||||
|
|
||||||
|
Find V4L2 headers and libv4l2
|
||||||
|
|
||||||
|
|
||||||
|
This module accepts optional COMPONENTS:
|
||||||
|
|
||||||
|
videodev2 (default)
|
||||||
|
libv4l2
|
||||||
|
|
||||||
|
IMPORTED Targets
|
||||||
|
^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
This module defines the following :prop_tgt:`IMPORTED` targets::
|
||||||
|
|
||||||
|
``V4L2::videodev2``
|
||||||
|
The Video for Linux Two header file, if found.
|
||||||
|
``V4L2::libv4l2``
|
||||||
|
A thin abstraction layer on top of video4linux2 devices, if found.
|
||||||
|
|
||||||
|
Result Variables
|
||||||
|
^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
``V4L2_FOUND``
|
||||||
|
System has v4l2 support. If no components are specified only the videodev2.h header has to be found.
|
||||||
|
``V4L2_INCLUDE_DIRS``
|
||||||
|
The v4l2 include directories.
|
||||||
|
``V4L2_LIBRARIES``
|
||||||
|
The libraries needed to have v4l2 support according to the specified components.
|
||||||
|
#]=======================================================================]
|
||||||
|
|
||||||
|
find_path(V4L2_VIDEODEV2_INCLUDE_DIR
|
||||||
|
NAMES linux/videodev2.h)
|
||||||
|
mark_as_advanced(V4L2_VIDEODEV2_INCLUDE_DIR)
|
||||||
|
|
||||||
|
if(EXISTS "${V4L2_VIDEODEV2_INCLUDE_DIR}")
|
||||||
|
set(V4L2_videodev2_FOUND TRUE)
|
||||||
|
else()
|
||||||
|
set(V4L2_videodev2_FOUND FALSE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
pkg_check_modules(PC_V4L2_LIBV4L2 QUIET libv4l2)
|
||||||
|
|
||||||
|
find_path(V4L2_LIBV4L2_INCLUDE_DIR
|
||||||
|
NAMES libv4l2.h
|
||||||
|
HINTS
|
||||||
|
${PC_V4L2_LIBV4L2_INCLUDEDIR}
|
||||||
|
${PC_V4L2_LIBV4L2_INCLUDE_DIRS})
|
||||||
|
mark_as_advanced(V4L2_LIBV4L2_INCLUDE_DIR)
|
||||||
|
|
||||||
|
find_library(V4L2_LIBV4L2_LIBRARY
|
||||||
|
NAMES ${PC_V4L2_LIBV4L2_LIBRARIES}
|
||||||
|
HINTS
|
||||||
|
${PC_V4L2_LIBV4L2_LIBDIR}
|
||||||
|
${PC_V4L2_LIBV4L2_LIBRARY_DIR})
|
||||||
|
mark_as_advanced(V4L2_LIBV4L2_LIBRARY)
|
||||||
|
|
||||||
|
if(EXISTS "${V4L2_LIBV4L2_INCLUDE_DIR}" AND
|
||||||
|
EXISTS "${V4L2_LIBV4L2_LIBRARY}")
|
||||||
|
set(V4L2_libv4l2_FOUND TRUE)
|
||||||
|
else()
|
||||||
|
set(V4L2_libv4l2_FOUND FALSE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(V4L2
|
||||||
|
REQUIRED_VARS
|
||||||
|
V4L2_VIDEODEV2_INCLUDE_DIR
|
||||||
|
HANDLE_COMPONENTS)
|
||||||
|
|
||||||
|
set(V4L2_INCLUDE_DIRS)
|
||||||
|
set(V4L2_LIBRARIES)
|
||||||
|
|
||||||
|
if(V4L2_videodev2_FOUND)
|
||||||
|
set(V4L2_VIDEODEV2_INCLUDE_DIRS ${V4L2_VIDEODEV2_INCLUDE_DIR})
|
||||||
|
list(APPEND V4L2_INCLUDE2_DIRS
|
||||||
|
"${V4L2_VIDEODEV2_INCLUDE_DIRS}")
|
||||||
|
|
||||||
|
add_library(V4L2::videodev2 INTERFACE IMPORTED)
|
||||||
|
set_target_properties(V4L2::videodev2 PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${V4L2_VIDEODEV2_INCLUDE_DIRS}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(V4L2_libv4l2_FOUND)
|
||||||
|
set(V4L2_LIBV4L2_INCLUDE_DIRS ${V4L2_LIBV4L2_INCLUDE_DIR})
|
||||||
|
set(V4L2_LIBV4L2_LIBRARIES ${V4L2_LIBV4L2_LIBRARY})
|
||||||
|
|
||||||
|
list(APPEND V4L2_INCLUDE_DIRS
|
||||||
|
"${V4L2_LIBV4L2_INCLUDE_DIRS}")
|
||||||
|
list(APPEND V4L2_LIBRARIES
|
||||||
|
"${V4L2_LIBV4L2_LIBRARIES}")
|
||||||
|
|
||||||
|
add_library(V4L2::libv4l2 UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(V4L2::libv4l2 PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${V4L2_LIBV4L2_INCLUDE_DIRS}"
|
||||||
|
IMPORTED_LOCATION "${V4L2_LIBV4L2_LIBRARY}")
|
||||||
|
endif()
|
|
@ -98,6 +98,12 @@ elseif(${ZM_JWT_BACKEND} STREQUAL "libjwt")
|
||||||
JWT::libjwt)
|
JWT::libjwt)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(TARGET V4L2::videodev2)
|
||||||
|
target_link_libraries(zm
|
||||||
|
PRIVATE
|
||||||
|
V4L2::videodev2)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(zmc zmc.cpp)
|
add_executable(zmc zmc.cpp)
|
||||||
add_executable(zms zms.cpp)
|
add_executable(zms zms.cpp)
|
||||||
add_executable(zmu zmu.cpp)
|
add_executable(zmu zmu.cpp)
|
||||||
|
|
Loading…
Reference in New Issue