Documentation issue : Policy CMP0077

When I read this policy I thought:

“Does this policy of honoring normal variables only apply if the cache variable was created with option()?
What if the variable is created using set like this?”

set(FOOBAR 1 CACHE STRING "hello")

I tested it myself and it doesn’t matter if the variable was created with option or set.

Is this a documentation issue?

It makes no difference what method was used to create the cache variable originally. CMake doesn’t track how a cache variable was created. I don’t see anything in the documentation of the CMP0077 policy which suggests otherwise, but if there’s something about the existing docs which you think is inaccurate, feel free to highlight the specific parts.

Gotcha. That makes sense.

When I said “Is this a documentation issue?” that’s was a bit dramatic.

I just had a bit of an interpretation problem.

Because when I read the policy it uses the option() command to describe things.

" * CMP0077: option() honors normal variables."

This is how it’s presented. So I thought perhaps only CACHE variables that were TYPE=BOOL honored normal variables.

And when I read the policy page the option() command is used to describe the policy.

I guess I would write the policy header like this instead.

“CMP0077: cache variables honor normal variables”

But that’s just an opinion.

That would be incorrect. The longer title would be “CMP0077: The option command will honor existing normal variables with the same name as what the option command will use”

While this is pedantic, it is important, as cache variables and the option command behavior differently when an existing normal variable exists with the same name.

Before CMP0077 both cache variables and the option command would delete a normal variable with the same name on first execution of CMake. Subsequent executions of CMake would not delete the normal variable.

After CMP0077 the option command doesn’t delete a normal variable with the same name, while CACHE variables do.