[cmake-developers] Alternate if() without implicit variable expansion

Nils Gladitz nilsgladitz at gmail.com
Wed Sep 10 15:42:12 EDT 2014


On 09/10/2014 05:33 PM, Brad King wrote:
> Thanks.  I've updated the topic to include all the actual fixes
> for CMP0054 warnings within CMake's own code that I've found so
> far.

Thanks!

> I have a few more changes to request that you add to the topic:
>
> * The wording of the warning says what the change in behavior
>    is, but does not inform the user that the old behavior is
>    being used for compatibility.  Currently without reading the
>    policy documentation one might think from the messages that
>    the logic is being executed differently than before.

Done.

> * In cmIfCommand we should avoid doing the lookups when the
>    policy is NEW.  Instead of calling mf->GetPolicyStatus on
>    every step of the way, call it once at the beginning of the
>    if() command execution and save the result in a member.
>    Then in cmIfCommand::GetDefinitionIfUnquoted, check for
>    quoting and the policy status before even trying to do the
>    lookup.  That should make processing of quoted arguments
>    much faster because we won't have to check for a definition
>    with every string value.

The functions for condition evaluation were global or static (I assume 
so they could be shared with while()) and I would have had to pass 
through the policy state as extra parameters.
This was also done with CMP0012 but I figured I might just as well 
extract everything into its own class "cmConditionEvaluator" and have it 
keep everything that was being passed around as members instead.

> * The CMP0054-keywords-NEW test does not cover "(" and ")".
>    (Good catch on implementing those, BTW.)
>
> * The tests need to cover if() inside while() and foreach()
>    as well as macro() and function().  Also add nested if()
>    for completeness.

I added tests but specifically for the loops I am not entirely sure what 
to cover given that the context of recording and replaying is basically 
the same (unlike with functions/macros)?
I wouldn't mind some extra scrutiny to make sure they cover what you had 
in mind.

Thanks.

Nils



More information about the cmake-developers mailing list