[Cmake] Question about shared library versioning
Brian Bassett
bbassett at bbassett.net
Thu Mar 27 14:36:45 EST 2003
Andy:
Thanks for the quick reply. The main problem with this is that it fails
to set the libraries' soname. Right now, the ADD_LIBRARY call will
generate the following call:
gcc -fPIC -shared -o libnjs.so ${NJS_SRCS}
whereas, I need something like:
gcc -fPIC -shared -Wl,-soname=libnjs.so.${NJSVERSION_MAJOR} -o libnjs.so
${NJS_SRCS}
Is something like this possible?
Thanks.
Brian
On Thu, 2003-03-27 at 11:16, Andy Cedilnik wrote:
> Hi Brian,
>
> Here is an example, but it may not be what you want:
>
> # Version of library
> SET(NJSVERSION_MAJOR 0)
> SET(NJSVERSION_MINOR 1)
> SET(NJSVERSION_PATCH 0)
>
> # Create library
> ADD_LIBRARY(njs ${NJS_SRCS})
>
> # This will only work on unix
> IF(UNIX)
> # Get library name
> SET(lib
> ${CMAKE_SHARED_MODULE_PREFIX}njs${CMAKE_SHARED_MODULE_SUFFIX})
>
> # Get the path to the library
> IF(EXECUTABLE_OUTPUT_PATH)
> SET(lib ${EXECUTABLE_OUTPUT_PATH}/${lib})
> ELSE(EXECUTABLE_OUTPUT_PATH)
> SET(lib ${CMAKE_CURRENT_OUTPUT_PATH}/${lib})
> ENDIF(EXECUTABLE_OUTPUT_PATH)
>
> # Add custom command for making softlink
> ADD_CUSTOM_COMMAND(
> SOURCE njs
> TARGET njs
> COMMAND ln
> ARGS -s ${lib} ${lib}.${NJSVERSION_MAJOR})
> ADD_CUSTOM_COMMAND(
> SOURCE njs
> TARGET njs
> COMMAND ln
> ARGS -s ${lib} ${lib}.${NJSVERSION_MAJOR}.${NJSVERSION_MINOR})
> ADD_CUSTOM_COMMAND(
> SOURCE njs
> TARGET njs
> COMMAND ln
> ARGS -s ${lib}
> ${lib}.${NJSVERSION_MAJOR}.${NJSVERSION_MINOR}.${NJSVERSION_PATCH})
> ENDIF(UNIX)
>
> Andy
>
> On Thu, 2003-03-27 at 14:03, Brian Bassett wrote:
> > Hello,
> >
> > I am looking at converting a project from the autoconf/automake/libtool
> > trio to CMake and have noticed what appears to be a rather large
> > deficiency in CMake. It appears to be impossible to specify an soname
> > for the UNIX dynamic linker or any kind of versioning info (i.e. for
> > when a binary-incompatible change is made between two releases). I have
> > been able to specify this kind of thing with libtool's --version-info
> > flag.
> >
> > Right now, I simply get a "libnjs.so" with no soname when I set up an
> > ADD_LIBRARY line in the CMakeLists.txt file. What I'm after is
> > something more like what libtool outputs:
> >
> > lrwxrwxrwx 1 brian brian 15 Dec 6 13:40 libnjs.so ->
> > libnjs.so.0.1.0
> > lrwxrwxrwx 1 brian brian 15 Dec 6 13:40 libnjs.so.0 ->
> > libnjs.so.0.1.0
> > -rwxr-xr-x 1 brian brian 800719 Feb 15 2001 libnjs.so.0.1.0
> >
> > (It's not even necessary to have the third level (i.e. the .so.0.1.0);
> > the .so -> .so.0 link and the library libnjs.so.0 linked with an soname
> > of libnjs.so.0 would suit my purposes enough to switch to CMake.)
> >
> > I realize that all this is not possible for all platforms that CMake
> > supports (Windows comes to mind). It might be nice to be able to encode
> > this information into the name of the dll file, for instance.
More information about the CMake
mailing list