From f2e56c7e83df9d3455535cfc15057f48f7fe55d0 Mon Sep 17 00:00:00 2001 From: Jacob Su Date: Tue, 12 Aug 2025 20:32:36 +0800 Subject: [PATCH] fix srt cmake 4.x compiling error. v7.0.52 (#4431) ## How to reproduce? 1. cmake version 4.0.3 2. clean srt build cache: `rm -rf objs/Platform-*` 3. `./configure` compiling error output: > Build srt-1-fit > patching file './objs/Platform-SRS7-Darwin-24.6.0-Clang17.0.0-arm64/srt-1-fit/srtcore/api.cpp' > Running: cmake . -DCMAKE_INSTALL_PREFIX=/Users/jacobsu/hack/media/srs/trunk/objs/Platform-SRS7-Darwin-24.6.0-Clang17.0.0-arm64/3rdparty/srt -DENABLE_APPS=0 -DENABLE_STATIC=1 -DENABLE_CXX11=0 -DENABLE_SHARED=0 -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib/libcrypto.a > CMake Error at CMakeLists.txt:10 (cmake_minimum_required): > Compatibility with CMake < 3.5 has been removed from CMake. > > Update the VERSION argument value. Or, use the ... syntax > to tell CMake that the project requires at least but has been updated > to work with policies introduced by or earlier. > > Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway. > > -- Configuring incomplete, errors occurred! ## Cause CMake 4.x not long compatible with function cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR) with only min version anymore. ## Solution add `add -DCMAKE_POLICY_VERSION_MINIMUM=3.5` to cmake cmd args. --------- Co-authored-by: Haibo Chen <495810242@qq.com> Co-authored-by: OSSRS-AI --- trunk/auto/depends.sh | 5 +++++ trunk/doc/CHANGELOG.md | 1 + 2 files changed, 6 insertions(+) diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index 349feec2f..46e307d0c 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -693,6 +693,11 @@ fi if [[ $SRS_SRT == YES && $SRS_USE_SYS_SRT == NO ]]; then # Always disable c++11 for libsrt, because only the srt-app requres it. LIBSRT_OPTIONS="--enable-apps=0 --enable-static=1 --enable-c++11=0" + CMAKE_VERSION=$(cmake --version | head -n1 | cut -d' ' -f3) + CMAKE_MAJOR=$(echo $CMAKE_VERSION | cut -d'.' -f1) + if [[ $CMAKE_MAJOR -ge 4 ]]; then + LIBSRT_OPTIONS="$LIBSRT_OPTIONS --CMAKE_POLICY_VERSION_MINIMUM=3.5" + fi if [[ $SRS_SHARED_SRT == YES ]]; then LIBSRT_OPTIONS="$LIBSRT_OPTIONS --enable-shared=1" else diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 58c71a770..bfb95dd41 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -7,6 +7,7 @@ The changelog for SRS. ## SRS 7.0 Changelog +* v7.0, 2025-08-12, Merge [#4431](https://github.com/ossrs/srs/pull/4431): fix srt cmake 4.x compiling error. v7.0.52 (#4431) * v7.0, 2025-08-11, Merge [#4433](https://github.com/ossrs/srs/pull/4433): Use clang format. v7.0.52 (#4433) * v7.0, 2025-08-11, Merge [#4159](https://github.com/ossrs/srs/pull/4159): Feature: Support HLS with fmp4 segment for HEVC/LLHLS. v7.0.51 (#4159) * v7.0, 2025-08-11, Merge [#4432](https://github.com/ossrs/srs/pull/4432): AI: HTTP-FLV: Fix heap-use-after-free crash during stream unmount. v7.0.50 (#4432)