title: How to get a relative path to a target with CMake?
body: <p>I have a project that uses CMake to generate build scripts, and each platform puts the executable that are generated in a different place. We have a non-programmer on our team who does not have build tools and I want to be able to bundle up all the files, scripts and executables necessary to run the project so that he can run the project. </p>
  
  <p>To do that, I've added a custom target that takes all the necessary files and zips them up. It also generates a very simple script (which is included in the zip file) that he can just click on that should run a script then launch the executable, like so:</p>
  
  <pre><code>add_custom_target(runcommand
    COMMAND echo '\#!/bin/bash -eu' &gt; run.command &amp;&amp;
            echo 'cd `dirname $$0`' &gt;&gt; run.command &amp;&amp;
            echo './scripts/prerun_script.sh &amp;&amp; ${MY_EXECUTABLE}' &gt;&gt; run.command &amp;&amp;
            chmod +x run.command)
  </code></pre>
  
  <p>The problem with this is that MY_EXECUTABLE is a hardcoded path to the executable on my system. I would like it to be a relative path so that I can just take this resultant zip file, unzip it anywhere and run it from there. What I would like is to get the path to MY_EXECUTABLE relative to the root directory of my project so that this script can be run from anywhere.  </p>