How do I set a cmake policy?

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?

Answer

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().

Attribution
Source : Link , Question Author : Time4Tea , Answer Author : Kusalananda

Leave a Comment