<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Tue, Jul 18, 2017 at 8:50 PM, Florian Lindner <span dir="ltr"><<a href="mailto:mailinglists@xgm.de" target="_blank">mailinglists@xgm.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">#Works, but I would prefer to have it just once for all targets and at the top of the file<br>
<span class="gmail-">set_property(TARGET testprecice APPEND<br>
  PROPERTY COMPILE_DEFINITIONS "FOO")<br>
<br>
</span><span class="gmail-">> BTW, you don't include the -D when adding to COMPILE_DEFINITIONS, just put FOO, not -DFOO. Have a read of the docs, they may give you other clues for this property (e.g. using the ..._CONFIG variant of it).<br>
<br>
</span>Yeah, I found out that I don't have to add -D. The docs say that generator expressions are preferable to using _CONFIG<br>
variant.<br></blockquote><div><br></div><div>So just to be crystal clear, this is what I would have expected to work if you wanted the symbol FOO to be defined for Debug builds for all targets in the current directory and below:</div><div><br></div><div><font face="monospace, monospace">set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:FOO>)</font></div><div><br></div><div>Note that this directory property is NOT used to initialise the corresponding target property. Rather, BOTH are combined to give the final set of command line compile definitions. It does not matter whether this directory property is set before or after you call add_executable() within the same CMakeLists.txt file (or more accurately, within the same directory scope).</div><div><br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class="gmail-">><br>
><br>
> On Tue, Jul 18, 2017 at 1:21 PM, Florian Lindner <<a href="mailto:mailinglists@xgm.de">mailinglists@xgm.de</a> <mailto:<a href="mailto:mailinglists@xgm.de">mailinglists@xgm.de</a>>> wrote:<br>
><br>
>     Am 18.07.2017 um 10:59 schrieb Craig Scott:<br>
>     > You appear to be setting a GLOBAL property where you probably meant DIRECTORY. You could also consider setting the<br>
>     > target property instead rather than applying it to all targets (unless that's what you want).<br>
><br>
>     I tried to set the property on all targets, therefore I thought GLOBAL is the right thing.<br>
><br>
>     However,<br>
><br>
>     set_property(DIRECTORY "${CMAKE_SOURCE_DIR}/src" APPEND<br>
>       PROPERTY COMPILE_DEFINITIONS "-DFOO")<br>
><br>
>     hasn't had any effect either.<br>
><br>
>     set_property(TARGET testprecice APPEND<br>
>       PROPERTY COMPILE_DEFINITIONS "FOO")<br>
><br>
>     works. But setting it on all targets is exactly what I want. How can I do that?<br>
><br>
>     Best,<br>
>     Florian<br>
><br>
>     ><br>
>     ><br>
>     > On Tue, Jul 18, 2017 at 12:56 PM, Florian Lindner <<a href="mailto:mailinglists@xgm.de">mailinglists@xgm.de</a> <mailto:<a href="mailto:mailinglists@xgm.de">mailinglists@xgm.de</a>><br>
</span><span class="gmail-">>     <mailto:<a href="mailto:mailinglists@xgm.de">mailinglists@xgm.de</a> <mailto:<a href="mailto:mailinglists@xgm.de">mailinglists@xgm.de</a>>>> wrote:<br>
>     ><br>
>     >     Hello,<br>
>     ><br>
>     >     I want to add compile definitions. Since I want to use generator expressions, I can't use add_definitions, but<br>
>     have to<br>
>     >     use the COMPILE_DEFINITIONS property, but neither:<br>
>     ><br>
>     >     set_property(GLOBAL APPEND<br>
>     >       PROPERTY COMPILE_DEFINITIONS "-DFOO")<br>
>     ><br>
>     >     for testing<br>
>     ><br>
>     >     or<br>
>     ><br>
>     >     set_property(GLOBAL APPEND<br>
>     >       PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:-DDebug>)<br>
>     ><br>
>     >     which should be final result, produces any -DFOO compiler switches.<br>
>     ><br>
>     >     I also tried placing it before and after the add_executable call.<br>
>     ><br>
>     >     What is wrong with that call?<br>
>     ><br>
>     >     Thanks,<br>
>     >     Florian<br></span></blockquote><div> </div></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div></div></div></div></div></div></div>
</div></div>