v4l2camera: backport upstream patch for CMake >= 4.0 support

Backport upstream patch for v4l2camera for CMake >= 4.0 support.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
This commit is contained in:
Christian Marangi
2025-11-24 23:53:14 +01:00
parent 79171199a2
commit 5ce5d78e24
7 changed files with 337 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
From 8e13b8df40af5d48a05775f851b7900b5f87e9ad Mon Sep 17 00:00:00 2001
From: Michel Promonet <michel.promonet@free.fr>
Date: Sun, 29 Dec 2024 15:20:34 +0100
Subject: [PATCH] update cmake version min
---
v4l2rtspserver/libv4l2cpp/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/v4l2rtspserver/libv4l2cpp/CMakeLists.txt
+++ b/v4l2rtspserver/libv4l2cpp/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.0)
+cmake_minimum_required(VERSION 3.5)
# set project name from current directory
get_filename_component(BASENAME ${CMAKE_CURRENT_LIST_DIR} NAME)

View File

@@ -0,0 +1,55 @@
From d912aab90cfc907903a6801801b3f4badefb1cfd Mon Sep 17 00:00:00 2001
From: Michel Promonet <michel.promonet@free.fr>
Date: Sat, 21 Sep 2024 22:05:03 +0200
Subject: [PATCH] add logger in public properties
---
v4l2rtspserver/CMakeLists.txt | 26 +++++++++++++-------------
2 files changed, 14 insertions(+), 14 deletions(-)
--- a/v4l2rtspserver/CMakeLists.txt
+++ b/v4l2rtspserver/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.0)
+cmake_minimum_required(VERSION 3.5)
project(v4l2rtspserver)
@@ -48,18 +48,6 @@ find_package (Threads)
target_link_libraries (${PROJECT_NAME} Threads::Threads)
-# LOG4CPP
-if (LOG4CPP)
- find_library(LOG4CPP_LIBRARY NAMES log4cpp)
- if (LOG4CPP_LIBRARY)
- message(STATUS "Log4Cpp available ${LOG4CPP_LIBRARY}")
- add_definitions(-DHAVE_LOG4CPP)
- target_link_libraries(${PROJECT_NAME} "${LOG4CPP_LIBRARY}")
-
- SET(CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}liblog4cpp5v5,)
- endif ()
-endif ()
-
# openssl ?
if (WITH_SSL)
find_package(OpenSSL QUIET)
@@ -104,6 +92,18 @@ if (OpenSSL_FOUND)
set(LIBRARIES ${LIBRARIES} ${OPENSSL_LIBRARIES})
endif ()
+# LOG4CPP
+if (LOG4CPP)
+ find_library(LOG4CPP_LIBRARY NAMES log4cpp)
+ if (LOG4CPP_LIBRARY)
+ message(STATUS "Log4Cpp available ${LOG4CPP_LIBRARY}")
+ target_compile_definitions(libv4l2rtspserver PUBLIC HAVE_LOG4CPP)
+ target_link_libraries(libv4l2rtspserver PUBLIC "${LOG4CPP_LIBRARY}")
+
+ SET(CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}liblog4cpp5v5,)
+ endif ()
+endif ()
+
#ALSA
if (ALSA)
find_package(ALSA QUIET)

View File

@@ -0,0 +1,20 @@
From d2159e48a6e45f58a4fef652de5785112056ee23 Mon Sep 17 00:00:00 2001
From: Michel Promonet <michel.promonet@free.fr>
Date: Sun, 29 Dec 2024 15:21:56 +0100
Subject: [PATCH] replace exec_program with exec_process
---
v4l2rtspserver/CMakeLists.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
--- a/v4l2rtspserver/CMakeLists.txt
+++ b/v4l2rtspserver/CMakeLists.txt
@@ -117,7 +117,7 @@ if (ALSA)
endif()
# libv4l2cpp
-EXEC_PROGRAM("git submodule update --init")
+execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init)
add_subdirectory(libv4l2cpp EXCLUDE_FROM_ALL)
target_include_directories(libv4l2rtspserver PUBLIC libv4l2cpp/inc)
target_link_libraries (libv4l2rtspserver PUBLIC libv4l2cpp ${LIBRARIES})

View File

@@ -0,0 +1,131 @@
From c093fbfcf28541a9bdef46a4c430241c640a031a Mon Sep 17 00:00:00 2001
From: Edmunt Pienkowsky <roed@onet.eu>
Date: Tue, 8 Jul 2025 07:17:20 +0200
Subject: [PATCH] CMake Improvements (#355)
* CMake: Do not define CMAKE_BUILD_TYPE
It is absolutely right to leave CMAKE_BUILD_TYPE variable undefined.
In this case compilation flags are taken from CFLAGS and CXXFLAGS environment variables.
* CMake: Always define VERSION macro
* Allow to define VERSION macro by V4L2RTSPSERVER_VERSION environment variable.
* Warn if value of VERSION could not be determined.
* Use add_compile_definitions instead of add_definitions.
* CMake: Init submodules only if git command is available
* CMake: Use imported targets defined by find_package command
* CMake: Install systemd service conditionally
One may disable installation of systemd service by setting SYSTEND cache variable to OFF (ON by default).
---
CMakeLists.txt | 54 ++++++++++++++++++++++++++++----------------------
1 file changed, 30 insertions(+), 24 deletions(-)
--- a/v4l2rtspserver/CMakeLists.txt
+++ b/v4l2rtspserver/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.5)
+cmake_minimum_required(VERSION 3.12)
project(v4l2rtspserver)
@@ -10,24 +10,26 @@ set(STATICSTDCPP ON CACHE BOOL "use gcc
set(LOG4CPP OFF CACHE BOOL "use log4cpp if available")
set(LIVE555URL http://www.live555.com/liveMedia/public/live555-latest.tar.gz CACHE STRING "live555 url")
set(LIVE555CFLAGS -DBSD=1 -DSOCKLEN_T=socklen_t -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -DALLOW_RTSP_SERVER_PORT_REUSE=1 -DNO_STD_LIB=1 CACHE STRING "live555 CFGLAGS")
-
-if(NOT CMAKE_BUILD_TYPE)
- set (CMAKE_BUILD_TYPE "Release")
-endif()
+set(SYSTEMD ON CACHE BOOL "install SystemD service")
set(CMAKE_CXX_STANDARD 20)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake/")
-# set version based on git
find_package(Git)
-if(GIT_FOUND)
+if(DEFINED ENV{V4L2RTSPSERVER_VERSION})
+ # set version from V4L2RTSPSERVER_VERSION env variable
+ add_compile_definitions("VERSION=\"$ENV{V4L2RTSPSERVER_VERSION}\"")
+elseif(GIT_FOUND)
+ # set version based on git
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} -C ${CMAKE_CURRENT_SOURCE_DIR} describe --tags --always --dirty OUTPUT_VARIABLE VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
STRING(REGEX REPLACE "^v(.*)" "\\1" VERSION "${VERSION}")
- add_definitions("-DVERSION=\"${VERSION}\"")
+ add_compile_definitions("VERSION=\"${VERSION}\"")
+else()
+ message(WARNING "VERSION is undefined")
+ add_compile_definitions("VERSION=\"undefined\"")
endif()
-
# define executable to build
include_directories("inc")
add_executable(${PROJECT_NAME} main.cpp)
@@ -89,7 +91,7 @@ target_compile_definitions(libv4l2rtspse
target_link_libraries (${PROJECT_NAME} libv4l2rtspserver ${LIVE_LIBRARIES})
set (LIBRARIES "")
if (OpenSSL_FOUND)
- set(LIBRARIES ${LIBRARIES} ${OPENSSL_LIBRARIES})
+ set(LIBRARIES ${LIBRARIES} OpenSSL::SSL)
endif ()
# LOG4CPP
@@ -109,15 +111,17 @@ if (ALSA)
find_package(ALSA QUIET)
MESSAGE("ALSA_FOUND = ${ALSA_FOUND}")
if (ALSA_LIBRARY)
- target_compile_definitions(libv4l2rtspserver PUBLIC HAVE_ALSA)
- set(LIBRARIES ${LIBRARIES} ${ALSA_LIBRARY})
-
+ target_compile_definitions(libv4l2rtspserver PUBLIC HAVE_ALSA)
+ set(LIBRARIES ${LIBRARIES} ALSA::ALSA)
+
SET(CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}libasound2,)
endif ()
endif()
# libv4l2cpp
-execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init)
+if (GIT_FOUND)
+ execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init)
+endif()
add_subdirectory(libv4l2cpp EXCLUDE_FROM_ALL)
target_include_directories(libv4l2rtspserver PUBLIC libv4l2cpp/inc)
target_link_libraries (libv4l2rtspserver PUBLIC libv4l2cpp ${LIBRARIES})
@@ -140,17 +144,19 @@ 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)
+if (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})
-endif (SYSTEMD_FOUND)
+ endif (SYSTEMD_FOUND)
+endif (SYSTEMD)
# package
install (TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)

View File

@@ -0,0 +1,42 @@
From 765d8da0f9285a6a9aacc4de7479b471781b67b9 Mon Sep 17 00:00:00 2001
From: Michel Promonet <michel.promonet@free.fr>
Date: Sat, 21 Sep 2024 23:33:17 +0200
Subject: [PATCH] remove useless verbose
---
v4l2rtspserver/inc/ALSACapture.h | 5 ++---
v4l2rtspserver/src/V4l2RTSPServer.cpp | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
--- a/v4l2rtspserver/inc/ALSACapture.h
+++ b/v4l2rtspserver/inc/ALSACapture.h
@@ -22,8 +22,8 @@
struct ALSACaptureParameters
{
- ALSACaptureParameters(const char* devname, const std::list<snd_pcm_format_t> & formatList, unsigned int sampleRate, unsigned int channels, int verbose) :
- m_devName(devname), m_formatList(formatList), m_sampleRate(sampleRate), m_channels(channels), m_verbose(verbose) {
+ ALSACaptureParameters(const char* devname, const std::list<snd_pcm_format_t> & formatList, unsigned int sampleRate, unsigned int channels) :
+ m_devName(devname), m_formatList(formatList), m_sampleRate(sampleRate), m_channels(channels) {
}
@@ -31,7 +31,6 @@ struct ALSACaptureParameters
std::list<snd_pcm_format_t> m_formatList;
unsigned int m_sampleRate;
unsigned int m_channels;
- int m_verbose;
};
class ALSACapture : public DeviceInterface
--- a/v4l2rtspserver/src/V4l2RTSPServer.cpp
+++ b/v4l2rtspserver/src/V4l2RTSPServer.cpp
@@ -209,7 +209,7 @@ StreamReplicator* V4l2RTSPServer::Create
// Init audio capture
LOG(NOTICE) << "Create ALSA Source..." << audioDevice;
- ALSACaptureParameters param(audioDevice.c_str(), audioFmtList, audioFreq, audioNbChannels, verbose);
+ ALSACaptureParameters param(audioDevice.c_str(), audioFmtList, audioFreq, audioNbChannels);
ALSACapture* audioCapture = ALSACapture::createNew(param);
if (audioCapture)
{

View File

@@ -0,0 +1,33 @@
From 97d9f7ae4dd7a90fc03685b04e0cdc14ccff7015 Mon Sep 17 00:00:00 2001
From: mpromonet <michel.promonet@free.fr>
Date: Sat, 21 Sep 2024 23:10:37 +0200
Subject: [PATCH] add pthread to lib
---
v4l2rtspserver/CMakeLists.txt | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/v4l2rtspserver/CMakeLists.txt
+++ b/v4l2rtspserver/CMakeLists.txt
@@ -45,10 +45,6 @@ message(STATUS "CMAKE_TOOLCHAIN_FILE=${C
message(STATUS "CMAKE_C_COMPILER=${CMAKE_C_COMPILER}")
message(STATUS "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
-#pthread
-find_package (Threads)
-target_link_libraries (${PROJECT_NAME} Threads::Threads)
-
# openssl ?
if (WITH_SSL)
@@ -94,6 +90,10 @@ if (OpenSSL_FOUND)
set(LIBRARIES ${LIBRARIES} OpenSSL::SSL)
endif ()
+#pthread
+find_package (Threads)
+target_link_libraries (libv4l2rtspserver PUBLIC Threads::Threads)
+
# LOG4CPP
if (LOG4CPP)
find_library(LOG4CPP_LIBRARY NAMES log4cpp)

View File

@@ -0,0 +1,39 @@
From 7de505f51e0715f882d00e9aa7cf30df7db52949 Mon Sep 17 00:00:00 2001
From: Michel Promonet <michel.promonet@free.fr>
Date: Sat, 21 Sep 2024 23:34:32 +0200
Subject: [PATCH] remove verbose param
---
CMakeLists.txt | 2 +-
src/main.cpp | 4 ++--
v4l2rtspserver | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.0)
+cmake_minimum_required(VERSION 3.5)
option (WITH_COMPRESS "Enable compression" ON)
option (BUILD_UI "Build ui" ON)
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -152,7 +152,7 @@ int main(int argc, char* argv[])
std::string videoDev, audioDev;
getline(is, videoDev, ',');
getline(is, audioDev);
- V4L2DeviceParameters param(videoDev.c_str(), videoformatList, width, height, fps, ioTypeIn, verbose);
+ V4L2DeviceParameters param(videoDev.c_str(), videoformatList, width, height, fps, ioTypeIn);
std::unique_ptr<V4l2Capture> videoCapture(V4l2Capture::create(param));
if (!videoCapture)
{
@@ -162,7 +162,7 @@ int main(int argc, char* argv[])
{
#ifdef HAVE_ALSA
std::string audioDevice = V4l2RTSPServer::getV4l2Alsa(audioDev);
- ALSACaptureParameters param(audioDevice.c_str(), audioFmtList, audioFreq, audioNbChannels, verbose);
+ ALSACaptureParameters param(audioDevice.c_str(), audioFmtList, audioFreq, audioNbChannels);
audioCapture.reset(ALSACapture::createNew(param));
#endif