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 <min> value. Or, use the <min>...<max>
syntax
> to tell CMake that the project requires at least <min> but has been
updated
>   to work with policies introduced by <max> 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 <winlinam@gmail.com>
This commit is contained in:
Jacob Su 2025-08-12 20:32:36 +08:00 committed by GitHub
parent 6e1134fe9b
commit f2e56c7e83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -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

View File

@ -7,6 +7,7 @@ The changelog for SRS.
<a name="v7-changes"></a>
## 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)