-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[vcpkg.cmake] Fix CMP0126 warning when running in trace mode (#23784) #29969
Conversation
8dfa289
to
a7f0324
Compare
After reviewing the warnings I come to the conclusion that it would be safe to set the policy to NEW within the vcpkg.cmake policy scope. Opinions? |
does not warn when the policy is not set -> CMake bug ? or did you change CMAKE_POLICY_WARNING_CMPNNNN ? |
IIUC the behaviours is different with trace modes. |
In trace mode, CMake enables all optional warnings. This is not a bug.
|
I don't mind setting it to new. |
scripts/buildsystems/vcpkg.cmake
Outdated
@@ -38,6 +38,10 @@ if(CMAKE_VERSION VERSION_LESS Z_VCPKG_CMAKE_REQUIRED_MINIMUM_VERSION) | |||
endif() | |||
cmake_policy(PUSH) | |||
cmake_policy(VERSION 3.7.2) | |||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.21.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.21.0") | |
if(POLICY CMP0126) |
But the code also says you could actively suppress the warning if I read it correctly. (i.e. by explicitly setting it to false) |
Trying to get the full picture.
I'm not really against this change. But I want all options to be considered:
Last not least it might make sense to actually check the current warnings. In #23784, I see |
Avoiding the warning without modifying the policies is certainly an option. The pattern where the warning is triggered is:
The minimal impact fix is
Or it might be more elegant to use a differently named variable for holding the default value. If I remember correctly, only two VCPKG_* variables are affected. |
When running CMake 3.21 or newer in trace or debug mode, vcpkg.cmake would trigger the CMP0126 warning for VCPKG_MANIFEST_DIR and VCPKG_INSTALLED_DIR. The regular variable was used to set the initial value of the cache variable of the same name. This patch adds the regular variables Z_VCPKG_MANIFEST_DIR_INITIAL_VALUE and Z_VCPKG_INSTALLED_DIR_INITIAL_VALUE that are used to initialize their respective cache variables.
a7f0324
to
de49ecb
Compare
It's better to adapt to warnings than to avoid them, and I think this one is ok. |
When running CMake 3.21 or newer in trace mode, vcpkg.cmake would trigger the CMP0126 warning. Explicitly set this policy to OLD behavior within the vcpkg.cmake policy scope to silence the warning without changing behaviour.
Fixes #23784