[CMake] How to make a shared library to use relative paths to the executable

Renato Utsch renatoutsch at gmail.com
Tue Oct 25 11:10:14 EDT 2011


Hello!

I am learning to use CMake and I found it very easy to use, very and very
good. But I don't understand why it uses full paths instead of relative
paths when linking shared/dynamic libraries. I am currently making a program
that is only compiled to a folder, but not installed to the system (on
linux), much like a folder containing all the software in windows. It has
the following structure (when compiled):

---- program <-- Main folder of the project
-------- bin <-- Executable and shared libraries of the executable
-------- data <-- Stores data files and information for runtime
-------- plugins <-- Stores shared libraries which (I want) can be added or
removed after the compilation process which adds custom behaviour to the
program.

The real problem is: I can't link these shared libraries from the folder
/program/plugins to the application at the /program/bin folder. I want this
to be organized. How can I link by that?

Other problem: the compilation has a lot of dependencies (qt, compiled boost
libraries, opengl, between others), and this makes the compilation a bit
difficult on Windows. So, I wanted to be able to zip the compiled folder
(with all the needed libraries) and distribute the folder for the users. But
when I move the program from one directory to another, it stops working. Is
there any way, even hacky, to make CMake to use relative paths? Because all
IDE's, other makes, allow doing this, so why CMake obligates us to use full
paths? It would be so perfect by that...

There is any way or I will have to use a non-portable way of compiling?


Thanks for the help!

Renato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111025/d2e79abb/attachment.htm>


More information about the CMake mailing list