[CMake] Link against dynamic library

Eugen-Andrei Gavriloaie shiretu at gmail.com
Fri Sep 25 07:28:44 EDT 2009


Hello,

Is there any way to tell cmake to use relative paths when linking an  
executable? Here some info about a sample exec:

$ otool -L ./rtmpserver/rtmpserver
./rtmpserver/rtmpserver:
	/Users/shiretu/work/crtmpserver/trunk/builders/cmake/thelib/ 
libthelib.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current  
version 0.9.8)
	/usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current  
version 0.9.8)
	/Users/shiretu/work/crtmpserver/trunk/builders/cmake/common/ 
libcommon.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current  
version 7.9.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current  
version 124.1.1)


What I want is to transform

/Users/shiretu/work/crtmpserver/trunk/builders/cmake/thelib/ 
libthelib.dylib (compatibility version 0.0.0, current version 0.0.0)

into

thelib/libthelib.dylib (compatibility version 0.0.0, current version  
0.0.0)

So, when I do

TARGET_LINK_LIBRARIES(rtmpserver thelib.....) is there any way to tell  
cmake to build the Makefile in such a way that the final executable  
will have relative references to the used libraries?

I only want to do that for the libraries in my project, not all of  
them (ibSystem.B.dylib,libstdc++.6.dylib, etc) should remain the same

Thank you




More information about the CMake mailing list