[CMake] Can an option enforce a default, even if cache is present?

Mario Emmenlauer mario at emmenlauer.de
Tue Nov 27 08:49:46 EST 2018


Dear all,

I've just discovered that option() behaves differently than I anticipated.
After reading the docs and searching with google I'm still confused how to
achieve my desired behaviour.

What I've just learned is that unspecified options take their cached value
and do *not* go back to their default value, if a cache exists. I assumed
that options take their default when not explicitly specified.

Now my problem: I could not find a way to get the behaviour I'd like. Is it
possible to enforce the default for an option when its not specified by the
user, even if a cache exists?

I tried to unset() the option from the cache but that does not do what I'd
like.

All the best,

    Mario Emmenlauer


More information about the CMake mailing list