Run custom shell script with CMake : <p>I am having the following directory structure:</p>

<pre><code>/CMakeLists.txt
/component-a/CMakeLists.txt
           /...
/component-b/CMakeLists.txt
           /...
/doc/CMakeLists.txt
    /create-doc.sh
</code></pre>

<p>The shell script <code>create-doc.sh</code> creates a documentation file (<code>doc.pdf</code>). How can I use CMake to execute this shell script at build time and copy the file <code>doc.pdf</code> to the build directory?</p>

<p>I tried it by using <code>add_custom_command</code> in the <code>CMakeLists.txt</code> file inside the directory <code>doc</code>:</p>

<pre><code>add_custom_command ( OUTPUT doc.pdf 
                     COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/create-doc.sh 
                     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/)
</code></pre>

<p>Unfortunately the command is never run.</p>

<p>I also tried <code>execute_process</code>:</p>

<pre><code>execute_process ( COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/create-doc.sh  
                  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ ) 
</code></pre>

<p>Now the script is executed during the configuration phase, but not at build time.</p>
