[CMake] installing 3rd party libraries and version symlinks

Tyler Roscoe tyler at cryptio.net
Thu Sep 17 16:45:53 EDT 2009


I'm trying to package all the 3rd party libraries needed by my project
so that my project is self-contained (very handy for testing). On Unix,
these 3rd party libraries often have version symlinks that go with them:

[tylermr at alta:/3rdpartylibs/Qt/4.5.1/build/linux/release/lib]$ ls -l libQtCore.*
-rw-r--r-- 1 build build      804 2009-06-08 21:36 libQtCore.la
-rw-r--r-- 1 build build      781 2009-06-08 21:36 libQtCore.prl
lrwxrwxrwx 1 build build       18 2009-06-08 21:36 libQtCore.so -> libQtCore.so.4.5.1
lrwxrwxrwx 1 build build       18 2009-06-08 21:36 libQtCore.so.4 -> libQtCore.so.4.5.1
lrwxrwxrwx 1 build build       18 2009-06-08 21:36 libQtCore.so.4.5 -> libQtCore.so.4.5.1
-rwxr-xr-x 1 build build  2384464 2009-06-08 21:36 libQtCore.so.4.5.1
-rw-r--r-- 1 build build 20913272 2009-06-08 16:07 libQtCore.so.4.5.1.debug

I can't just package libQtCore.so because the linker actually wants
libQtCore.so.4 (and other linkers might want .so.4.5 or .so.4.5.1 or
whatever).

What is The CMake Way to recreate this hierarchy in my application's lib
folder?

Possible solutions:

- Copy libQtCore*. This sucks because it pulls in extra files (the .la
  and .prl and .debug files in my ls output above). Also, cmake -E copy
isn't smart enough to preserve symlinks as symlinks, so I end up with 4
copies of a 2.3M lib, which isn't very nice.

- Destroy the symlinks and force my application to link against
  libQtCore.so with no version info. This sucks because it forces me to
change a 3rd party application in a non-standard way and it's inflexible
and ugly.

- Use a script that finds all the symlinks and recreates them in my
  application's lib directory. This is the approach we're planning to
use but it feels a little hacky.

Thanks,
tyler


More information about the CMake mailing list