Skip to content

build: raise cmake_minimum_required to 3.5 for CMake 4.x compatibility - #837

Open
Code-0-0 wants to merge 1 commit into
MetaCubeX:mainfrom
Code-0-0:build/cmake-min35
Open

Code-0-0 wants to merge 1 commit into
MetaCubeX:mainfrom
Code-0-0:build/cmake-min35

Conversation

@Code-0-0

Copy link
Copy Markdown

Summary

CMake 4.0 removed compatibility with cmake_minimum_required(VERSION < 3.5) and now aborts the
configure step with:

CMake Error at CMakeLists.txt:1 (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 ...
  Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.

core/src/main/cpp/CMakeLists.txt still requests VERSION 3.0, so any local build that ends up
using a CMake >= 4.0 (for example the CMake shipped with a MinGW/MSYS2 toolchain, or a CMake
selected through cmake.dir in local.properties) fails before anything is compiled. CI is not
affected because it uses the SDK's CMake 3.22.1 — which accepts 3.5 just as well.

Change

-cmake_minimum_required(VERSION 3.0)
+# 3.5 is the minimum accepted by CMake 4.x (anything lower is a hard error there)
+cmake_minimum_required(VERSION 3.5)

Nothing in this file depends on policies introduced after 3.5 (execute_process, configure_file,
string(TIMESTAMP), list(GET), add_library, target_link_libraries), so the bump only widens
the accepted range at the top: CMake 4.x works, and CMake >= 3.5 keeps working.

(If touching this file is undesirable, the equivalent workaround is to pass
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 from core/build.gradle.kts's externalNativeBuild.cmake
arguments.)

Verification

The same change was part of a fork build of app:assembleAlphaRelease on the Build Debug
workflow (which uses the SDK CMake 3.22.1), and the native bridge target configured and linked
successfully, all four ABIs:
https://github.com/Code-0-0/ClashMetaForAndroid/actions/runs/35441174195

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant