title: cmake build executable with relative paths for dependencies (relocatable executable)
body: <p>I have a package that is using cmake as its compiler. If I install the dependencies it needs first using a package manager then run <code>cmake</code> e.g.</p>
  
  <pre><code>$ sompackage-manager install depend1 depend2
  
  $ wget http://a.b.c/somepackage.tgz
  
  $ tar -xf somepackage.tgz
  
  $ cd somepackage/
  
  $ ls
  </code></pre>
  
  <blockquote>
  <pre><code>CI     CMakeFiles  CONTRIBUTING.md   README.md 
  CMakeCache.txt CMakeLists.txt  doc      LICENSE
  </code></pre>
  </blockquote>
  
  <pre><code>cmake .
  </code></pre>
  
  <p>This will work fine. cmake finds all the dependencies and the project will create a folder in the build directory named <code>bin</code> that the executable will be in. I can then move the executable where ever id like. I assume the executable either knows the full path of the dependencies or has a list of full paths to check.</p>
  
  <p>What id like to do is this:
    create a folder like <code>$HOME/newpackage</code>. Then install the dependencies (the dependencies happens to use a configure script) to that directory e.g. </p>
  
  <pre><code>$ mkdir $HOME/newpackage/depend1
  
  $ wget http://a.b.c/depnd1.tgz
  
  $ tar -xf depend1.tgz
  
  $ cd depend1
  
  $ ./configure --prefix=$HOME/newpackage/depend1
  </code></pre>
  
  <p>Once all the dependencies are installed to <code>$HOME/newpackage/depend1</code>
  Id then like to go back to the <code>somepackage</code> build directory and tell cmake to build the package to <code>$HOME/newpackage/</code> dir but also to look for the dependencies relative to where the executable is i.e a path like <code>./</code>. The end result would allow me to move the <code>newpackage</code> directory with the executable and the dependencies folders without breaking any paths.</p>
  
  <p>I am having trouble finding the right cmake options or wether or not they are available.</p>
  
  <p>Is this possible with cmake and what is the best way to go forward?</p>