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