[CMake] Why does CMake use relative linking when I replace a shared object?

Mathias Gaunard mathias.gaunard at ens-lyon.org
Fri Nov 25 06:28:40 EST 2011


There is some strange CMake behaviour I don't quite understand.

In the project attached, I build a shared library for which I want to 
specify a custom build command; to do this I generate a dummy library 
which I then replace by another file in a POST_BUILD command 
(alternatives involving imported libraries do not work properly across 
different scopes).

If I do not replace the library, then the executable correctly links 
against libtest.so.
If I do, it links instead with ../baz/libtest.so (sic), which of course, 
fails when trying to run the program.

Why is it putting a relative path into my executable? Why is it 
different depending on whether I replace the .so by another one or not?

Thank you very much for any insight on what's happening.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.tar.gz
Type: application/x-gzip
Size: 638 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111125/92355ec7/attachment-0001.bin>


More information about the CMake mailing list