[cmake-developers] Unique compile definitions

Stephen Kelly steveire at gmail.com
Mon Aug 13 09:09:36 EDT 2012


Brad King wrote:

> On 08/10/2012 10:30 AM, Stephen Kelly wrote:
>> I've updated the branch with the API change to use std::set. The XCode
>> generator does not use the cmLocalGenerator::AppendDefines method, but
>> the VisualStudio6Generator does.
> 
> That wasn't quite what I had in mind.  The string of escaped
> defines for the command line should be paired with a set of
> raw defines.

I'm not a fan of duplicating the information so much, and having to pass 
both a set and a string to the method to be modified to contain the define.

I uploaded a compromise compile-definitions-unique branch to my gitorious 
(git at gitorious.org:~steveire/cmake/steveires-cmake.git) which stores the 
unescaped definition in the set, and escapes it in the JoinDefines method.

I'm not certain what behavior change you are referring to in the case there 
is no duplicate (Ordering?).

Thanks,

Steve.

> Before appending definition to the end of the
> string test set insertion:
> 
>   if(defined.insert(def).second)
>     {
>     // first time we see this one
>     ...rest of logic to append to "defines" string.
>     }
> 
> That way no behavior changes unless there is a duplicate.
> IMO it is also cleaner to store the unescaped original
> definitions in the std::set.
> 
> -Brad




More information about the cmake-developers mailing list