android / ndk

The Android Native Development Kit
2.01k stars 257 forks source link

[BUG] From Cmake-3.31.0 some warnings " (cmake_minimum_required)" #2100

Open rumas84 opened 1 week ago

rumas84 commented 1 week ago

Description

CMake Deprecation Warning at /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/android.toolchain.cmake:35 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  /usr/share/cmake-3.31/Modules/CMakeDetermineSystem.cmake:146 (include)
  CMakeLists.txt:14 (project)

CMake Deprecation Warning at /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/android-legacy.toolchain.cmake:35 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/android.toolchain.cmake:55 (include)
  /usr/share/cmake-3.31/Modules/CMakeDetermineSystem.cmake:146 (include)
  CMakeLists.txt:14 (project)

CMake Deprecation Warning at /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/android.toolchain.cmake:35 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  build/CMakeFiles/3.31.0/CMakeSystem.cmake:6 (include)
  CMakeLists.txt:14 (project)

-- The C compiler identification is Clang 18.0.2
CMake Deprecation Warning at /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/flags.cmake:18 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  /usr/share/cmake-3.31/Modules/Platform/Android-Clang.cmake:23 (include)
  /usr/share/cmake-3.31/Modules/Platform/Android-Clang-C.cmake:1 (include)
  /usr/share/cmake-3.31/Modules/CMakeCInformation.cmake:48 (include)
  CMakeLists.txt:14 (project)

-- Detecting C compiler ABI info
CMake Deprecation Warning at /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/android.toolchain.cmake:35 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  /opt/ninja-build2+/oscam-gitlab/build/CMakeFiles/3.31.0/CMakeSystem.cmake:6 (include)
  /opt/ninja-build2+/oscam-gitlab/build/CMakeFiles/CMakeScratch/TryCompile-lWzK3x/CMakeLists.txt:4 (project)

CMake Deprecation Warning at /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/android-legacy.toolchain.cmake:35 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/android.toolchain.cmake:55 (include)
  /opt/ninja-build2+/oscam-gitlab/build/CMakeFiles/3.31.0/CMakeSystem.cmake:6 (include)
  /opt/ninja-build2+/oscam-gitlab/build/CMakeFiles/CMakeScratch/TryCompile-lWzK3x/CMakeLists.txt:4 (project)

CMake Deprecation Warning at /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/flags.cmake:18 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  /usr/share/cmake-3.31/Modules/Platform/Android-Clang.cmake:23 (include)
  /usr/share/cmake-3.31/Modules/Platform/Android-Clang-C.cmake:1 (include)
  /usr/share/cmake-3.31/Modules/CMakeCInformation.cmake:48 (include)
  /opt/ninja-build2+/oscam-gitlab/build/CMakeFiles/CMakeScratch/TryCompile-lWzK3x/CMakeLists.txt:4 (project)

-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/ninja-build2+/sources/android-ndk-r27b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- ....
...
..
.
HOSTCC  webif/pages_gen
GEN     webif/pages.c
GEN     Compressed 384952 template bytes into 156941 bytes. 228011 saved bytes (59.23%).
-- The CXX compiler identification is Clang 18.0.2
-- Detecting CXX compiler ABI info
CMake Deprecation Warning at /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/android.toolchain.cmake:35 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  /opt/ninja-build2+/oscam-gitlab/build/CMakeFiles/3.31.0/CMakeSystem.cmake:6 (include)
  /opt/ninja-build2+/oscam-gitlab/build/CMakeFiles/CMakeScratch/TryCompile-ZwKrb9/CMakeLists.txt:4 (project)

CMake Deprecation Warning at /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/android-legacy.toolchain.cmake:35 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/android.toolchain.cmake:55 (include)
  /opt/ninja-build2+/oscam-gitlab/build/CMakeFiles/3.31.0/CMakeSystem.cmake:6 (include)
  /opt/ninja-build2+/oscam-gitlab/build/CMakeFiles/CMakeScratch/TryCompile-ZwKrb9/CMakeLists.txt:4 (project)

CMake Deprecation Warning at /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/flags.cmake:18 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  /usr/share/cmake-3.31/Modules/Platform/Android-Clang.cmake:23 (include)
  /usr/share/cmake-3.31/Modules/Platform/Android-Clang-CXX.cmake:1 (include)
  /usr/share/cmake-3.31/Modules/CMakeCXXInformation.cmake:48 (include)
  /opt/ninja-build2+/oscam-gitlab/build/CMakeFiles/CMakeScratch/TryCompile-ZwKrb9/CMakeLists.txt:4 (project)

-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/ninja-build2+/sources/android-ndk-r27b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for math.h
CMake Deprecation Warning at /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/android.toolchain.cmake:35 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  /opt/ninja-build2+/oscam-gitlab/build/CMakeFiles/3.31.0/CMakeSystem.cmake:6 (include)
  /opt/ninja-build2+/oscam-gitlab/build/CMakeFiles/CMakeScratch/TryCompile-8BVN7A/CMakeLists.txt:4 (project)

CMake Deprecation Warning at /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/android-legacy.toolchain.cmake:35 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/android.toolchain.cmake:55 (include)
  /opt/ninja-build2+/oscam-gitlab/build/CMakeFiles/3.31.0/CMakeSystem.cmake:6 (include)
  /opt/ninja-build2+/oscam-gitlab/build/CMakeFiles/CMakeScratch/TryCompile-8BVN7A/CMakeLists.txt:4 (project)

CMake Deprecation Warning at /opt/ninja-build2+/sources/android-ndk-r27b/build/cmake/flags.cmake:18 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  /usr/share/cmake-3.31/Modules/Platform/Android-Clang.cmake:23 (include)
  /usr/share/cmake-3.31/Modules/Platform/Android-Clang-C.cmake:1 (include)
  /usr/share/cmake-3.31/Modules/CMakeCInformation.cmake:48 (include)
  /opt/ninja-build2+/oscam-gitlab/build/CMakeFiles/CMakeScratch/TryCompile-8BVN7A/CMakeLists.txt:4 (project)

On my side CMakeLists.txt updated and it's ok . cmake_minimum_required(VERSION 2.8...3.10)

Affected versions

r27, r28

Canary version

No response

Host OS

Linux

Host OS version

Ubuntu 24.04.1

Affected ABIs

armeabi-v7a

Build system

CMake

Other build system

No response

minSdkVersion

Null

Device API level

No response

DanAlbert commented 1 week ago

Thanks for the heads up. Changing that is a breaking change for any of our users that are still on 3.6, which was the first version we had in the Android SDK and our metrics say is still used by a a handful of users (1.5% ish). We'll hold off on changing this until CMake decides to follow through on the removal. I don't think I've been through a CMake deprecation before so I'm not sure if they follow through on removals or if they deprecate to cover their asses in the event that they've got an engineering reason to remove a thing later.

1% of builds isn't all that many, and the number of those that are using a modern NDK is probably much lower (unfortunately I don't have those stats correlated), so fixing this probably wouldn't be too disruptive, but I'd prefer not to break anyone at all to just fix a warning.

mhdfasilwyd commented 5 days ago

This seems like an annoying issue when you have lot of useful logs along the build, found a workaround to suppress the warnings here.

set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "" FORCE)

misery commented 5 days ago

Maybe you could add a "work-around" for that.

if(CMAKE_VERSION VERSION_LESS "3.31")
   cmake_minimum_required(VERSION 3.6)
else()
   cmake_minimum_required(VERSION 3.10)
endif()

A little bit strange but it should work.

Of course that would not help if you use deprecated API. But I don't think that there is any - otherwise it should be replaced soon with an IF(CMAKE_VERSION).

DanAlbert commented 5 days ago

This seems like an annoying issue when you have lot of useful logs along the build

I agree, it's just not as annoying as your build being broken, and the only way I can fix the warning is by breaking the build for people using older versions of CMake.

Maybe you could add a "work-around" for that.

if(CMAKE_VERSION VERSION_LESS "3.31")
   cmake_minimum_required(VERSION 3.6)
else()
   cmake_minimum_required(VERSION 3.10)
endif()

A little bit strange but it should work.

Of course that would not help if you use deprecated API. But I don't think that there is any - otherwise it should be replaced soon with an IF(CMAKE_VERSION).

That would fork the behavior of the toolchain file and we'd have to test with multiple versions of CMake, which we don't currently have infrastucture for and I'd rather not add yet another dimension to our test matrix.

rumas84 commented 2 days ago

Just, if you will do an update then do not forget flags.cmake file line 18 . Commit from Cmake: (https://github.com/Kitware/CMake/commit/84db8506ffc38381dd2502be41879ffe03d8e8e9#diff-93e508dc54714bf93511f1d1097464c28b43d71a40221883473108de15c33423R4)