Thanks.<div><br></div><div>This seems to work:</div><div><br></div><div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set_property( TARGET foo APPEND_STRING PROPERTY</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>COMPILE_FLAGS &quot;/ZI &quot;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>)</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>set_property( TARGET foo APPEND_STRING PROPERTY</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>COMPILE_FLAGS &quot;/W4 &quot;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>)</div><div><br></div><div>Just make sure you have a space at the end of each one, so that when the strings are appended, there is a space between each compiler flag.</div>
<div><br></div><div>---------</div>Robert Dailey<br>
<br><br><div class="gmail_quote">On Mon, Feb 6, 2012 at 4:13 PM,  <span dir="ltr">&lt;<a href="mailto:aaron.meadows@thomsonreuters.com">aaron.meadows@thomsonreuters.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">I believe that is the defined behavior.  Usually, people would use add_definitions() to add the flags before creating the target.  If you have one target per subdirectory, you don’t have to worry about removing them afterwards:<u></u><u></u></span></b></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">CMakeLists.txt:<u></u><u></u></span></b></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">   add_definitions(/foo)<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">   add_subdirectory(baz)<u></u><u></u></span></b></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">   add_subdirectory(qux)<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">baz/CMakeLists.txt<u></u><u></u></span></b></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">   add_definitions(/bar)<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">   add_executable(baz baz.cpp)<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">qux/CMakeLists.txt<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">   add_executable(qux qux.cpp)<u></u><u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">baz gets the compiler flags “/foo /bar”, qux only gets “/foo”.<u></u><u></u></span></b></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">As an aside, I ran into a similar issue, but with Linker Flags in the cache.  To overcome that, I wrote a few functions to encapsulate the writing of flags and handle checking for duplicates.  You could certainly do something similar with properties:<u></u><u></u></span></b></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">############################################################<u></u><u></u></span></b></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">## Cache Set Helper Functions<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">############################################################<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">function(AppendIfMissing _outVar _inVar _value)<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">  string(REGEX REPLACE &quot; &quot; &quot;;&quot; _inList &quot;${${_inVar}}&quot;)<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">  list(FIND _inList &quot;${_value}&quot; _pos)<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">  if(${_pos} EQUAL -1)<u></u><u></u></span></b></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">    set(${_outVar} &quot;${${_inVar}} ${_value}&quot; PARENT_SCOPE)<u></u><u></u></span></b></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">  else()<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">    set(${_outVar} &quot;${${_inVar}}&quot; PARENT_SCOPE)<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">  endif()<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">endfunction(AppendIfMissing)<u></u><u></u></span></b></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">function(CheckAndAppendCacheForce _varName _value _type )<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">  AppendIfMissing(_outvar ${_varName} ${_value})<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">  foreach(_arg IN LISTS ARGN)<u></u><u></u></span></b></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">    set(_desc &quot;${_desc} ${_arg}&quot;)<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">  endforeach()<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">  set(${_varName} &quot;${_outvar}&quot; CACHE ${_type} &quot;${_desc}&quot; FORCE)<u></u><u></u></span></b></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">endfunction(CheckAndAppendCacheForce)<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">function(CheckAndAppendCache _varName _value _type )<u></u><u></u></span></b></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">  AppendIfMissing(_outvar ${_varName} ${_value})<u></u><u></u></span></b></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">  foreach(_arg IN LISTS ARGN)<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">    set(_desc &quot;${_desc} ${_arg}&quot;)<u></u><u></u></span></b></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">  endforeach()<u></u><u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p><p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">  set(${_varName} &quot;${_outvar}&quot; CACHE ${_type} &quot;${_desc}&quot;)<u></u><u></u></span></b></p>
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f">endfunction(CheckAndAppendCache)<u></u><u></u></span></b></p><p class="MsoNormal">
<b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p>
<p class="MsoNormal"><b><span style="font-size:9.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#666666">Aaron Meadows</span></b><span style="font-size:9.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#666666"><u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#7f7f7f"><u></u> <u></u></span></b></p><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> <a href="mailto:cmake-bounces@cmake.org" target="_blank">cmake-bounces@cmake.org</a> [mailto:<a href="mailto:cmake-bounces@cmake.org" target="_blank">cmake-bounces@cmake.org</a>] <b>On Behalf Of </b>Robert Dailey<br>
<b>Sent:</b> Monday, February 06, 2012 3:58 PM<br><b>To:</b> CMake ML<br><b>Subject:</b> [CMake] COMPILE_FLAGS property that appends instead of replaces<u></u><u></u></span></p><div class="im"><p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I would like to set the COMPILE_FLAGS property multiple times on the same target through set_target_properties(), however only the last call seems to persist. Previous flags set get overridden. Is this the correct behavior? If so, is there a way to make this property append instead of replace on the same target?<br clear="all">
<u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">---------<u></u><u></u></p></div><p class="MsoNormal">Robert Dailey<u></u><u></u></p></div></div></div><br>
This email was sent to you by Thomson Reuters, the global news and information company. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.</blockquote>
</div><br></div>