No one has anything to say about this?<br><br><div class="gmail_quote">On Wed, May 9, 2012 at 1:32 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">To my knowledge there are no dedicated target properties or commands that allow one to easily add precompiled headers support to a target. In my case, I&#39;m generating for visual studio and I have the following that I can use to enable precompiled headers:<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>The one interesting thing I have noticed is the way these compile flags translate to actual vcproj output:</div>

<div><div><br></div><div><span style="white-space:pre-wrap">                                </span>&lt;FileConfiguration</div><div><span style="white-space:pre-wrap">                                        </span>Name=&quot;MinSizeRel|Win32&quot;&gt;</div>
<div><span style="white-space:pre-wrap">                                        </span>&lt;Tool</div><div><span style="white-space:pre-wrap">                                        </span>Name=&quot;VCCLCompilerTool&quot;</div><div><span style="white-space:pre-wrap">                                        </span>ForcedIncludeFiles=&quot;C:/Code/work/cmake-decomp/cmake/files/source/hash_map_hack.hpp;StdAfx.cpp&quot;</div>


<div><span style="white-space:pre-wrap">                                        </span>PrecompiledHeaderFile=&quot;C:/Code/work/cmake-decomp/build-vc9/server/exchange/tools/uploadlog/StdAfx.pch&quot;</div><div><span style="white-space:pre-wrap">                                        </span>PrecompiledHeaderThrough=&quot;StdAfx.h&quot;</div>


<div><span style="white-space:pre-wrap">                                        </span>UsePrecompiledHeader=&quot;2&quot;</div><div><span style="white-space:pre-wrap">                                        </span>AdditionalDependencies=&quot;C:\Code\work\cmake-decomp\build-vc9\server\exchange\tools\uploadlog\StdAfx.pch&quot;</div>


<div><span style="white-space:pre-wrap">                                        </span>/&gt;</div></div><div><br></div><div>CMake seems to do more than just add them as general compiler flags, it seems to know exactly which attributes in the VCPROJ XML are mapped to their respective command line alternatives, and uses the appropriate ones. If this is true, why do we not have a dedicated target &amp; source file property that I can use to enable precompiled headers instead of using these command line strings directly? Am I misunderstanding something?</div>


</blockquote></div><br>