[CMake] make install/strip does not strip static libraries

Kyle Leber kleber at fastemail.us
Tue Mar 27 11:13:08 EDT 2012


On Tue, Mar 27, 2012 at 10:23 AM, Andreas Pakulat <apaku at gmx.de> wrote:

> On 27.03.12 09:45:47, Kyle Leber wrote:
> > On Fri, Mar 23, 2012 at 4:20 PM, Kyle Leber <kleber at fastemail.us> wrote:
> >
> > > Hi,
> > >
> > > I'm using cmake 2.8 and having an issue when I issue a 'make
> > > install/strip'.  My project includes two libraries: one static and one
> > > shared. The shared library gets properly stripped, but the static one
> does
> > > not.  Do I need to specify a special parameter to get the static
> library to
> > > be stripped or am I doing something else wrong?
> > >
> > > Thanks for the help!
> > >
> > > OS: Ubuntu 10.10
> > > Compiler: g++ 4.4.5
> > >
> > > Kyle
> > >
> >
> > OK, I've done a little more research.  It looks like cmake_install.cmake
> > that is generated in my build directory has install lines handling the
> > shared libraries and the static libraries.
> >
> > After the shared library is installed, there's a section like this:
> >
> > IF(EXISTS "${file}" AND
> >        NOT IS_SYMLINK "${file}")
> >       IF(CMAKE_INSTALL_DO_STRIP)
> >         EXECUTE_PROCESS(COMMAND "/usr/bin/strip" "${file}")
> >       ENDIF(CMAKE_INSTALL_DO_STRIP)
> >     ENDIF()
> >
> > That clearly strips the files after they are installed.  However, in the
> > section that installs my static library there is no such check to handle
> > stripping the library.  Is this a missing feature in CMake, or is there a
> > reason this is not supported?  I can run /usr/bin/strip on my .a static
> > library without issue so I think it's a reasonable thing to expect.
>
> Did you actually try linking against such a stripped static library? A
> simple call of strip libfoo.a will remove all symbols from that library,
> making it totally useless since you cannot link against it anymore. For
> a shared library things are different since its not just a bundle of
> object files (like a static library is), but rather contains additional
> information allowing strip to just strip the stuff that cannot be used
> from outside (i.e. private functions/classes etc.).
>
> Looking at strip's commandline parameters it might be possible to
> manually strip just the symbols you don't want in the static library,
> but this cannot be done by cmake automatically. So you'll have to create
> a custom post-install command to do this for you.
>
> Andreas
>
> --
>
> 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
>

Andreas,

Thanks much for the reply.  I did not realize the limitations of stripping
static libraries.  I think what I really want is the "strip
--strip-unneeded" option.  I will look into the post-install options to
take care of this.

Thanks again,
Kyle
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120327/81c639ae/attachment.htm>


More information about the CMake mailing list