Sorry, I forgot that I already had that code pasted in my original post. Sorry for the duplicate code :)<br><br><div class="gmail_quote">On Mon, May 14, 2012 at 5:17 PM, Robert Dailey <span dir="ltr">&lt;<a href="mailto:rcdailey.lists@gmail.com" target="_blank">rcdailey.lists@gmail.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 class="gmail_quote"><div class="im">On Mon, May 14, 2012 at 4:58 PM, Bill Hoffman <span dir="ltr">&lt;<a href="mailto:bill.hoffman@kitware.com" target="_blank">bill.hoffman@kitware.com</a>&gt;</span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


For those we hard coded many of the flags into a table.  So, basically for VS greater than 6, we have a table that maps flags to actual options in the IDE.  There is no special per-compiled support in CMake... :)<br>
<br>
All it knows is that flat /Foobar == &quot;Turn on option foobar&quot; and creates the right xml or project input file.</blockquote><div><br></div></div>Thanks for the explanation.<div><br></div><div>It would be nice to have target properties for these, instead of this obscure mapping. It makes it difficult to figure out how exactly to append compiler flags. For example, I&#39;m using set_property() with APPEND_STRING, and I have to make sure my spacing is correct each time I enable a compiler-specific feature using compiler flags. I had to use trial &amp; error to determine that APPEND_STRINGS worked, but APPEND didn&#39;t for COMPILE_FLAGS. There&#39;s a lot of boilerplate logic that I have to deal with when using set_property with COMPILE_FLAGS. </div>

<div><br></div><div>It would be much easier to specify some target properties instead. Or maybe to simplify things, we can have a compiler_flags() command that simplifies doing this work, if it is undesirable to have new target properties?</div>

<div><br></div><div>Is improvement desired in this area? Is the current implementation really satisfactory? It doesn&#39;t exactly offer an intuitive or maintainable solution.</div><div><br></div><div>Here is what I have to do right now to enable precompiled headers on MSVC:</div>
<div><div class="h5">
<div><br></div><div><div>macro( _precompiled_headers PrecompiledHeader PrecompiledSource SourcesVar )</div><div><span style="white-space:pre-wrap">        </span>if( MSVC )</div><div><span style="white-space:pre-wrap">                </span>get_filename_component( PrecompiledBasename ${PrecompiledHeader} NAME_WE )</div>

<div><span style="white-space:pre-wrap">                </span>set( PrecompiledBinary &quot;${CMAKE_CURRENT_BINARY_DIR}/${PrecompiledBasename}.pch&quot; )</div><div><span style="white-space:pre-wrap">                </span>set( Sources ${${SourcesVar}} )</div>

<div><br></div><div><span style="white-space:pre-wrap">                </span>set_property(</div><div><span style="white-space:pre-wrap">                        </span>SOURCE ${PrecompiledSource} APPEND_STRING PROPERTY</div>
<div><span style="white-space:pre-wrap">                        </span>COMPILE_FLAGS &quot;/Yc\&quot;${PrecompiledHeader}\&quot; /Fp\&quot;${PrecompiledBinary}\&quot; &quot;</div><div><span style="white-space:pre-wrap">                </span>)</div>
<div><br></div><div><span style="white-space:pre-wrap">                </span>set_property(</div><div><span style="white-space:pre-wrap">                        </span>SOURCE ${PrecompiledSource} APPEND PROPERTY</div><div>
<span style="white-space:pre-wrap">                        </span>OBJECT_OUTPUTS &quot;${PrecompiledBinary}&quot;</div><div><span style="white-space:pre-wrap">                </span>)</div><div><span style="white-space:pre-wrap">                </span></div>
<div><span style="white-space:pre-wrap">                </span>set_property(</div><div><span style="white-space:pre-wrap">                        </span>SOURCE ${Sources} APPEND_STRING PROPERTY</div><div><span style="white-space:pre-wrap">                        </span>COMPILE_FLAGS &quot;/Yu\&quot;${PrecompiledHeader}\&quot; /Fp\&quot;${PrecompiledBinary}\&quot; &quot;</div>

<div><span style="white-space:pre-wrap">                </span>)</div><div><span style="white-space:pre-wrap">                </span></div><div><span style="white-space:pre-wrap">                </span>set_property(</div>
<div><span style="white-space:pre-wrap">                        </span>SOURCE ${Sources} APPEND PROPERTY</div><div><span style="white-space:pre-wrap">                        </span>OBJECT_DEPENDS &quot;${PrecompiledBinary}&quot;</div>
<div><span style="white-space:pre-wrap">                </span>)</div><div><span style="white-space:pre-wrap">        </span>else()</div><div><span style="white-space:pre-wrap">                </span>message( &quot;Precompiled header support not provided for this platform&quot; )</div>

<div><span style="white-space:pre-wrap">        </span>endif()</div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span># Add precompiled header to SourcesVar</div>
<div><span style="white-space:pre-wrap">        </span>list( APPEND ${SourcesVar} ${PrecompiledSource} )</div><div>endmacro()</div></div><div><br></div></div></div><div>I feel like CMake should offer me a higher-level way of dealing with this. </div>

</div>
</blockquote></div><br>