microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.4k stars 6.47k forks source link

[vcpkg scripts] CMake Deprecation warning for policies <3.10 #42065

Open nickelpro opened 3 weeks ago

nickelpro commented 3 weeks ago

Describe the bug vcpkg sets the cmake policy version to 3.7.2 on lines 40 and 878 of scripts/buildsystems/vcpkg.cmake

CMake 3.31 has deprecated policy versions <3.10 and will be removing them in the future, the correct mechanism here is to add a max version to the cmake_policy() call to indicate that vcpkg doesn't actually rely on these deprecated policy behaviors. Ideally this would be set to a modern version of CMake, but it is sufficient to set it to 3.10, ie cmake_policy(VERSION 3.7.2...3.10)

This is unrelated to the policy 0174 issue in #41999.

Full Disclosure: I'm a Kitware employee, happy to answer questions

Environment

To Reproduce Steps to reproduce the behavior:

  1. ./vcpkg install zlib
  2. See error

Expected behavior No warnings for deprecated cmake_policy() levels

Failure logs

CMake Deprecation Warning at build/Debug/_deps/vcpkg-src/scripts/buildsystems/vcpkg.cmake:40 (cmake_policy):
  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/Debug/CMakeFiles/3.31.0/CMakeSystem.cmake:6 (include)
  CMakeLists.txt:5 (project)

...

CMake Deprecation Warning at build/Debug/_deps/vcpkg-src/scripts/buildsystems/vcpkg.cmake:878 (cmake_policy):
  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/Debug/CMakeFiles/3.31.0/CMakeSystem.cmake:6 (include)
  CMakeLists.txt:5 (project)
nickelpro commented 3 weeks ago

Derp, this is already PR'd here: https://github.com/microsoft/vcpkg/pull/41574

Keeping this open just to say, "We released 3.31, this warning shows up now"