[cmake-developers] Unique compile definitions

Stephen Kelly steveire at gmail.com
Sun Aug 19 16:17:07 EDT 2012


Brad King wrote:

> On 8/16/2012 11:42 AM, Stephen Kelly wrote:
>> I thought that I could make -DNAME="value" appear twice with this code:
>> 
>>  add_definitions(-D"NAME=Value" -DNAME="Value")
> 
> CMake syntax treats quotes in the middle of an unquoted argument
> literally.  The double quotes are part of the string.  This code:
> 
>  
http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmMakefile.cxx;hb=v2.8.9#l1269
> 
> does not recognize it as a definition flag.
> 
>> This might be intentional, but then the code in AppendDefines is dead and
>> should be removed. If it is unintentional, then I have found a bug.
> 
> The code should be active if the value needs quoting on the
> generated shell command line:
> 
>  set_property(TARGET foo PROPERTY COMPILE_DEFINITIONS "FOO=with space")

What you say makes sense. But maybe the comment I pointed out should be 
removed or made more clear. It doesn't seem to relate to what the code is 
actually about. What do you think?

>> There is still Watcom escaping which I did not test though. As the
>> current patch stores unescaped defines, the escaped defines may not be
>> unique.
> 
> The defines CMake knows about will be unique.  It is only the
> raw -D flag that leaks through the above-linked code without
> being recognized that might create a duplicate.  Rather than
> try to handle the historical pre-quoted case and guess what
> the user meant we should either make no change or just add
> a warning for it.

Ok, sounds fine to me. In that case, the branch is almost ready to merge to 
next. All that remains is to test the visual studio patch. Can I just merge 
the branch and fix any errors related to that which appear on the dashboard, 
or should I wait and ask someone to test it first? 

Thanks,

Steve.






More information about the cmake-developers mailing list