[Cmake] Shared library versioning (Take II)

Brad King brad . king at kitware . com
Wed, 2 Jul 2003 10:33:57 -0400 (EDT)


> > SET(CMAKE_SHARED_LIBRARY_SONAME_FLAGS "-rdynamic -Wl,-soname,")
> >
> > Why is -rdynamic here?  Just a typo?
>
> It was in a list of recommended flags I found somewhere, and I was under
> the impression it was to be used with the other flags for building
> shared libs.  If it isn't necessary (and it sounds like it), I'll just
> drop it.

The -rdynamic flag will be added by

  SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "-rdynamic")

so you don't need to add them with your new SONAME_FLAGS variable.

> Ok - I will have a look at this.  The only issue I see is that all rules
> for shared libs would get a redundant "cmake -E" command at the end,
> whether they need it or not.  Wouldn't it be cleaner to add this call
> programmatically only when it is needed?  Or is it more important to
> keep all such rules in CMakeDefaultMakeRuleVariables ?

That is a good point.  Perhaps we should keep the functionality of
CMakeDefaultMakeRuleVariables rules pure...they build a library given the
name and a set of flags.  We could then programmatically add the extra
lines and extra flags in the local-unix-makefile-generator.  The extra
flags would be added to the <LINK_FLAGS> replacement so that the rule
files don't need to worry about versioning.

> To complete this work, I will need to address the 'install' and 'clean'
> targets also, so that the versioned symlinks as well as the .so itself
> are dealt with appropriately.  What would be the best way of adding
> this?

You'll have to find the code that generates the install rule and add
support for copying the versioned libraries and running ln -sf in the
installed location.  The link that is created should be a relative path,
not a full path (in order to make DESTDIR installs work).  This is another
argument for adding the link commands programmatically into the makefiles
instead of using the rule variables.  The logic to do the link commands
correctly should be in as few source files as possible.

-Brad