I'm trying to compile the Paraview graphical visualization software for my ARM-based laptop; however, I am getting a few configuration warnings that seem to relate to cmake 'policies'. The warning text and the cmake man page suggest that I should be able to run the command cmake_policy() to set a particular policy; however, I can't figure out how or where to run it.

How can I set a particular cmake policy?


The CMake command cmake_policy() is documented in the CMake documentation.

It is usually added to the CMakeLists.txt file of the project to change the behaviour of CMake itself, usually to be able to handle older CMakeLists.txt features with newer versions of CMake.

You may use it to set an individual policy using

cmake_policy(SET CMP<NNNN> OLD)

where <NNNN> is a CMake policy number and where OLD indicates that you want the "old behaviour" of this policy (the word OLD could also be NEW).

Or, you may use the command to set policies for compatibility with a particular version of CMake using

cmake_policy(VERSION x.xx)

where x.xx must be at least 2.4.

In either case, the CMakeLists.txt file of the project is modified, and cmake will have to be re-run.

See also the documentation for cmake_minimum_required().

| improve this answer | |
  • Thanks for your answer. So, is NEW the default for policies, unless overridden? Also, it seems like any policy changes tend to be more for a specific project, rather than 'global' settings, is that correct? – Time4Tea Apr 16 '19 at 13:06
  • 1
    @Time4Tea I think that you are correct on both points. NEW exists to allow toggling policies on or off for specific parts of a CMakeLists.txt file. – Kusalananda Apr 16 '19 at 13:33
  • 1
    Is there a way to do it from command line? Namely with cmake ...? – Royi May 3 at 12:33
  • 2
    @Royi Yes, you can set CMAKE_POLICY_DEFAULT_CMP<NNNN> on the command line, e.g. -DCMAKE_POLICY_DEFAULT_CMP0063=NEW. – Jake Cobb Jul 20 at 19:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.