[Cmake] Shared library versioning (Take II)

Brad King brad . king at kitware . com
Tue, 24 Jun 2003 13:32:40 -0400 (EDT)


Gavin,

> Here is Take II on adding versioning support for shared libraries in
> CMake.  The patch is made against the latest release tarball 1.6.7.

This looks pretty good.  You're definately getting close.  Here is some
more feedback.

One quick comment:

SET(CMAKE_SHARED_LIBRARY_SONAME_FLAGS "-rdynamic -Wl,-soname,")

Why is -rdynamic here?  Just a typo?

> 	 ln -sf libfoo.so.1.5.4 libfoo.so.7
> 	 ln -sf libfoo.so.7 libfoo.so
[snip]
> But - the symlink commands get left behind.  Since they are not added
> programmatically (but appear in the default rules file) they are
> currently always there.  Any suggestions on how to clean this up?

There is a way.  See below.

> I noticed that if I made the rules in the
> CMakeDefaultMakeRuleVariables.cmake multi-line (ie. in several strings)
> it only took the first one, while using a semicolon separator worked.
> The multiline style is used further down in another rule, so I thought
> this should have worked.

That should work.  I've written several multiline rule replacements.
I'll look at this when I merge your changes into the CVS version.

> I added a CMAKE_SYMLINK command, which should probably have an
> associated Find* command with it.  Is that the right approach?

There is another approach that will solve both this problem and the
non-versioned library problem.  The command "cmake -E" will perform some
system functions like copying files.  We can add a library-symlinking
command to that that figures out whether to create symlinks based on the
arguments it is given.

Then the command might look like:

<CMAKE_COMMAND> -E library_symlink <TARGET> <TARGET_VERSION_SUFFIX> <TARGET_SOVERSION_SUFFIX>

Then the "library_symlink" command would check the rest of the arguments.
If the versions are present, it would create the symlinks to the library
if it exists.  Otherwise, it would do nothing and the old behavior would
be preserved.  It could even be expanded later to do something fancy for
nmake builds on windows.

Thanks for your work so far!
-Brad