[CMake] Link flags not applied to static library

Paul Harris harris.pc at gmail.com
Sat Dec 1 20:08:35 EST 2012


That bug is regarding "CMAKE_STATIC_LINKER_FLAGS

What about this bug report:
http://www.cmake.org/Bug/view.php?id=12295
which is related to STATIC_LIBRARY_FLAGS


On 1 December 2012 16:00, Timothy J. Arrington <sse3ml at gmail.com> wrote:

> The bug is already reported for quite a while:
> http://public.kitware.com/Bug/view.php?id=10094, but so far, hasn't
> been fixed.
>
> 2012/11/28 Paul Harris <harris.pc at gmail.com>:
> > Hi,
> >
> > I set this:
> >
> >    set (STATIC_LIBRARY_FLAGS_RELWITHDEBINFO
> > "${STATIC_LIBRARY_FLAGS_RELWITHDEBINFO} /LTCG")
> >
> > and it didn't seem to work.  MSVC still has no LTCG flag set for any of
> my
> > static libraries.
> >
> > does this feature work?
> > cheers,
> > Paul
> >
> >
> > On 23 June 2011 01:02, Ben Medina <ben.medina at gmail.com> wrote:
> >>
> >> 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.medina at 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.medina at 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
> >
> >
> >
> > --
> >
> > 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20121202/83295945/attachment.htm>


More information about the CMake mailing list