<div>Hi,</div><div><br></div><div>I set this:</div><div><br></div>   set (STATIC_LIBRARY_FLAGS_RELWITHDEBINFO &quot;${STATIC_LIBRARY_FLAGS_RELWITHDEBINFO} /LTCG&quot;)<br><br>and it didn&#39;t seem to work.  MSVC still has no LTCG flag set for any of my static libraries.<div>

<br></div><div>does this feature work?</div><div>cheers,</div><div>Paul</div><div><br><br><div class="gmail_quote">On 23 June 2011 01:02, Ben Medina <span dir="ltr">&lt;<a href="mailto:ben.medina@gmail.com" target="_blank">ben.medina@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">So that the answer stays on the list:<br>
<br>
One must use the STATIC_LIBRARY_FLAGS property, rather than<br>
LINK_FLAGS, for static libraries.<br>
<div class="HOEnZb"><div class="h5"><br>
On Tue, Jun 21, 2011 at 3:12 PM, Ben Medina &lt;<a href="mailto:ben.medina@gmail.com">ben.medina@gmail.com</a>&gt; wrote:<br>
&gt; Since I got no feedback, I assume it&#39;s a bug. I&#39;ve filed it here:<br>
&gt;<br>
&gt; 0012295: LINK_FLAGS_RELEASE has no effect on static libraries for MSVC<br>
&gt; generators<br>
&gt;<br>
&gt; <a href="http://www.cmake.org/Bug/view.php?id=12295" target="_blank">http://www.cmake.org/Bug/view.php?id=12295</a><br>
&gt;<br>
&gt; On Mon, Jun 13, 2011 at 11:50 AM, Ben Medina &lt;<a href="mailto:ben.medina@gmail.com">ben.medina@gmail.com</a>&gt; wrote:<br>
&gt;&gt; Hello all,<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m using CMake 2.8.4 and am seeing an odd differenc between static<br>
&gt;&gt; and shared libraries in regard to the LINK_FLAGS property. In<br>
&gt;&gt; particular, I&#39;m enabling &quot;Whole program optimization&quot; in Visual Studio<br>
&gt;&gt; 2010, which is done by add /GL as a compiler flag and /LTCG as a<br>
&gt;&gt; linker flag for the release configuration. However, the link flag is<br>
&gt;&gt; not used for static libraries, leading to a build warning about<br>
&gt;&gt; compiling with /GL but linking without /LTCG.<br>
&gt;&gt;<br>
&gt;&gt; Here&#39;s an example:<br>
&gt;&gt;<br>
&gt;&gt; cmake_minimum_required (VERSION 2.8)<br>
&gt;&gt; project (link_test)<br>
&gt;&gt;<br>
&gt;&gt; set (CMAKE_CXX_FLAGS_RELEASE &quot;${CMAKE_CXX_FLAGS_RELEASE} /GL&quot;)<br>
&gt;&gt;<br>
&gt;&gt; add_library (static_test STATIC a.cpp)<br>
&gt;&gt; set_target_properties (<br>
&gt;&gt;    static_test<br>
&gt;&gt;    PROPERTIES<br>
&gt;&gt;    LINK_FLAGS_RELEASE &quot;/LTCG&quot;<br>
&gt;&gt;    )<br>
&gt;&gt;<br>
&gt;&gt; add_library (shared_test SHARED a.cpp)<br>
&gt;&gt; set_target_properties (<br>
&gt;&gt;    shared_test<br>
&gt;&gt;    PROPERTIES<br>
&gt;&gt;    LINK_FLAGS_RELEASE &quot;/LTCG&quot;<br>
&gt;&gt;    )<br>
&gt;&gt;<br>
&gt;&gt; Just add an empty file called a.cpp to the directory, then build the<br>
&gt;&gt; whole project in release configuration. You&#39;ll get a warning like this<br>
&gt;&gt; for the static_test library:<br>
&gt;&gt;<br>
&gt;&gt; 2&gt;  a.obj : MSIL .netmodule or module compiled with /GL found;<br>
&gt;&gt; restarting link with /LTCG; add /LTCG to the link command line to<br>
&gt;&gt; improve<br>
&gt;&gt;<br>
&gt;&gt; Why is CMake not applying LINK_FLAGS_RELEASE to the static library?<br>
&gt;&gt;<br>
&gt;&gt; Thanks,<br>
&gt;&gt; Ben<br>
&gt;&gt;<br>
&gt;<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br></div>