0

Background

CMake policy is documented here. One may set the policy to a cmake version with cmake_policy(version ...), or by specific policy with cmake_policy(set ...). One may query the current policy for a specific policy as well with cmake_policy(get...).

Also the only CMake variables are related to specific policies (for example here).

Question

Is there a way to get the current policy, by version? I mean: to get the policy version value previously provided to cmake_policy(version ...) for example.

Workarounds

I understand there may be solutions with a wrapper around cmake_policy, or (better but slower) building array variable with all policies status for some or all versions and to compare current policy values with those one to select a version, if any matches.

Why?

It might look like bad practice, but if you write cmake utilities/"libraries" to be used by many teams worldwide, you might need a quick way to get informed (in logs) if someone touched the policies in case they come back to you for support.

Conclusive question

Is there a simple solution ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.