<div>Hi,</div><div><br></div><div>I set this:</div><div><br></div> set (STATIC_LIBRARY_FLAGS_RELWITHDEBINFO "${STATIC_LIBRARY_FLAGS_RELWITHDEBINFO} /LTCG")<br><br>and it didn'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"><<a href="mailto:ben.medina@gmail.com" target="_blank">ben.medina@gmail.com</a>></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 <<a href="mailto:ben.medina@gmail.com">ben.medina@gmail.com</a>> wrote:<br>
> Since I got no feedback, I assume it's a bug. I've filed it here:<br>
><br>
> 0012295: LINK_FLAGS_RELEASE has no effect on static libraries for MSVC<br>
> generators<br>
><br>
> <a href="http://www.cmake.org/Bug/view.php?id=12295" target="_blank">http://www.cmake.org/Bug/view.php?id=12295</a><br>
><br>
> On Mon, Jun 13, 2011 at 11:50 AM, Ben Medina <<a href="mailto:ben.medina@gmail.com">ben.medina@gmail.com</a>> wrote:<br>
>> Hello all,<br>
>><br>
>> I'm using CMake 2.8.4 and am seeing an odd differenc between static<br>
>> and shared libraries in regard to the LINK_FLAGS property. In<br>
>> particular, I'm enabling "Whole program optimization" in Visual Studio<br>
>> 2010, which is done by add /GL as a compiler flag and /LTCG as a<br>
>> linker flag for the release configuration. However, the link flag is<br>
>> not used for static libraries, leading to a build warning about<br>
>> compiling with /GL but linking without /LTCG.<br>
>><br>
>> Here's an example:<br>
>><br>
>> cmake_minimum_required (VERSION 2.8)<br>
>> project (link_test)<br>
>><br>
>> set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL")<br>
>><br>
>> add_library (static_test STATIC a.cpp)<br>
>> set_target_properties (<br>
>> static_test<br>
>> PROPERTIES<br>
>> LINK_FLAGS_RELEASE "/LTCG"<br>
>> )<br>
>><br>
>> add_library (shared_test SHARED a.cpp)<br>
>> set_target_properties (<br>
>> shared_test<br>
>> PROPERTIES<br>
>> LINK_FLAGS_RELEASE "/LTCG"<br>
>> )<br>
>><br>
>> Just add an empty file called a.cpp to the directory, then build the<br>
>> whole project in release configuration. You'll get a warning like this<br>
>> for the static_test library:<br>
>><br>
>> 2> a.obj : MSIL .netmodule or module compiled with /GL found;<br>
>> restarting link with /LTCG; add /LTCG to the link command line to<br>
>> improve<br>
>><br>
>> Why is CMake not applying LINK_FLAGS_RELEASE to the static library?<br>
>><br>
>> Thanks,<br>
>> Ben<br>
>><br>
><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>