Sorry, It&#39;s wrong. Here is the correct function:<br><span style="color:#808000">function</span>(use_msvc_precompiled_header<span style="color:#c0c0c0"> </span>target<span style="color:#c0c0c0"> </span>sources)
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">    </span><span style="color:#808000">if</span>(NOT<span style="color:#c0c0c0"> </span><span style="color:#800000">${target}</span>_PCH_BINARY_FILE)</pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">        </span><span style="color:#808000">message</span>(FATAL_ERROR<span style="color:#c0c0c0"> </span><span style="color:#008000">&quot;[</span><span style="color:#800000">${target}</span><span style="color:#008000">]</span><span style="color:#c0c0c0"> </span><span style="color:#008000">Precompiled</span><span style="color:#c0c0c0"> </span><span style="color:#008000">binary</span><span style="color:#c0c0c0"> </span><span style="color:#008000">does</span><span style="color:#c0c0c0"> </span><span style="color:#008000">not</span><span style="color:#c0c0c0"> </span><span style="color:#008000">exist&quot;</span>)</pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">        </span><span style="color:#808000">return</span>()</pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">    </span><span style="color:#808000">endif</span>()</pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">    </span><span style="color:#808000">get_target_property</span>(targetSources<span style="color:#c0c0c0"> </span><span style="color:#800000">${target}</span><span style="color:#c0c0c0"> </span>SOURCES)</pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">    </span><span style="color:#808000">list</span>(FIND<span style="color:#c0c0c0"> </span>targetSources<span style="color:#c0c0c0"> </span>${${<span style="color:#800000">${target}</span>_PCH_SOURCE_VAR}}<span style="color:#c0c0c0"> </span>result)</pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">    </span><span style="color:#808000">if</span>(result<span style="color:#c0c0c0"> </span>EQUAL<span style="color:#c0c0c0"> </span>-1)</pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">        </span><span style="color:#808000">message</span>(FATAL_ERROR<span style="color:#c0c0c0"> </span><span style="color:#008000">&quot;[</span><span style="color:#800000">${target}</span><span style="color:#008000">]</span><span style="color:#c0c0c0"> </span><span style="color:#008000">Please</span><span style="color:#c0c0c0"> </span><span style="color:#008000">add</span><span style="color:#c0c0c0"> </span><span style="color:#008000">&#39;\${${</span><span style="color:#800000">${target}</span><span style="color:#008000">_PCH_SOURCE_VAR}}&#39;</span><span style="color:#c0c0c0"> </span><span style="color:#008000">or</span><span style="color:#c0c0c0"> </span><span style="color:#008000">&#39;${${</span><span style="color:#800000">${target}</span><span style="color:#008000">_PCH_SOURCE_VAR}}&#39;</span><span style="color:#c0c0c0"> </span><span style="color:#008000">to</span><span style="color:#c0c0c0"> </span><span style="color:#008000">target&quot;</span>)</pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">        </span><span style="color:#808000">return</span>()</pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">    </span><span style="color:#808000">endif</span>()</pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">    </span><span style="color:#808000">set</span>(pchBinaryFile<span style="color:#c0c0c0"> </span>${<span style="color:#800000">${target}</span>_PCH_BINARY_FILE})</pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><b><span style="color:#c0c0c0">    </span><span style="color:#808000">foreach</span>(src<span style="color:#c0c0c0"> </span><span style="color:#800000">${sources}</span>)</b></pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><b><span style="color:#c0c0c0">        </span><span style="color:#808000">set_source_files_properties</span>(<span style="color:#800000">${src}</span><span style="color:#c0c0c0"> </span>PROPERTIES</b></pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><b><span style="color:#c0c0c0">            </span>COMPILE_FLAGS<span style="color:#c0c0c0"> </span><span style="color:#008000">&quot;/Yu\&quot;</span><span style="color:#800000">${pchBinaryFile}</span><span style="color:#008000">\&quot;</span><span style="color:#c0c0c0"> </span><span style="color:#008000">/FI\&quot;</span><span style="color:#800000">${pchBinaryFile}</span><span style="color:#008000">\&quot;</span><span style="color:#c0c0c0"> </span><span style="color:#008000">/Fp\&quot;</span><span style="color:#800000">${pchBinaryFile}</span><span style="color:#008000">\&quot;&quot;</span></b></pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><b><span style="color:#c0c0c0">            </span>OBJECT_DEPENDS<span style="color:#c0c0c0"> </span><span style="color:#800000">${pchBinaryFile}</span></b></pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><b><span style="color:#c0c0c0">        </span>)</b></pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><b><span style="color:#c0c0c0">    </span><span style="color:#808000">endforeach</span>()</b></pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#808000">endfunction</span>()</pre><br><br><div class="gmail_quote">2012/9/25 Loaden <span dir="ltr">&lt;<a href="mailto:loaden@gmail.com" target="_blank">loaden@gmail.com</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I don&#39;t think so.<br>See:<br><span style="color:#808000">function</span>(add_msvc_precompiled_header<span style="color:#c0c0c0"> </span>target)
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">    </span><span style="color:#808000">set</span>(pchBinaryFile<span style="color:#c0c0c0"> </span><span style="color:#800000">${CMAKE_CURRENT_BINARY_DIR}</span>/<span style="color:#800000">${target}</span>_pch.pch)</pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><b><span style="color:#c0c0c0">    </span><span style="color:#808000">set_source_files_properties</span>(${${<span style="color:#800000">${target}</span>_PCH_SOURCE_VAR}}<span style="color:#c0c0c0"> </span>PROPERTIES</b></pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><b><span style="color:#c0c0c0">        </span>COMPILE_FLAGS<span style="color:#c0c0c0"> </span><span style="color:#008000">&quot;/Yc\&quot;${</span><span style="color:#800000">${target}</span><span style="color:#008000">_PCH_HEADER_FILE}\&quot;</span><span style="color:#c0c0c0"> </span><span style="color:#008000">/Fp\&quot;</span><span style="color:#800000">${pchBinaryFile}</span><span style="color:#008000">\&quot;&quot;</span></b></pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><b><span style="color:#c0c0c0">        </span>OBJECT_OUTPUTS<span style="color:#c0c0c0"> </span><span style="color:#800000">${pchBinaryFile}</span></b></pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><b><span style="color:#c0c0c0">    </span>)</b></pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">    </span><span style="color:#808000">message</span>(STATUS<span style="color:#c0c0c0"> </span><span style="color:#008000">&quot;[</span><span style="color:#800000">${target}</span><span style="color:#008000">]</span><span style="color:#c0c0c0"> </span><span style="color:#008000">Precompiled</span><span style="color:#c0c0c0"> </span><span style="color:#008000">binary</span><span style="color:#c0c0c0"> </span><span style="color:#008000">is</span><span style="color:#c0c0c0"> </span><span style="color:#008000">\&quot;</span><span style="color:#800000">${pchBinaryFile}</span><span style="color:#008000">\&quot;&quot;</span>)</pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">    </span><span style="color:#808000">set</span>(<span style="color:#800000">${target}</span>_PCH_BINARY_FILE<span style="color:#c0c0c0"> </span><span style="color:#800000">${pchBinaryFile}</span></pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">        </span>CACHE<span style="color:#c0c0c0"> </span>INTERNAL<span style="color:#c0c0c0"> </span><span style="color:#008000">&quot;Precompiled</span><span style="color:#c0c0c0"> </span><span style="color:#008000">binary</span><span style="color:#c0c0c0"> </span><span style="color:#008000">file&quot;</span></pre>



<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">    </span>)</pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#808000">endfunction</span>()</pre><div class="im HOEnZb"><br><br><div class="gmail_quote">2012/9/25 Peter Kümmel <span dir="ltr">&lt;<a href="mailto:syntheticpp@gmx.net" target="_blank">syntheticpp@gmx.net</a>&gt;</span><br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Maybe by &quot;accident&quot;. Which cmake command do you use to add the dependency?</blockquote></div><br><br clear="all">


<br></div><div class="HOEnZb"><div class="h5">-- <br><div><span style="color:rgb(255,0,0)"><u><i>Please don&#39;t ask where I come from, It&#39;s a shame!</i></u></span><br>Best Regards</div>
<div>Yuchen</div><div></div><br>
<div></div>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div><span style="color:rgb(255,0,0)"><u><i>Please don&#39;t ask where I come from, It&#39;s a shame!</i></u></span><br>Best Regards</div>
<div>Yuchen</div><div></div><br>
<div></div>