Copy .dll file to the same folder as that of .exe file using CMake
<p>I am working on CMake for generating the visual studio files. I would like to add the xyz.dll in the same folder where abc.exe is residing. </p>

<p>I had read somewhere that when i manually copy the <code>xyz.dll</code> file into the same folder where <code>abc.exe</code> is residing then the problem would be solved. But every time it is not possible.. I want to write the CMake command so that it will find the <code>xyz.dll</code> file and copy into the same folder where the <code>abc.exe</code> is residing..</p>

<p>Following mentioned are the paths where the <code>.exe</code> and <code>.dll</code> file is residing in my PC.</p>

<pre><code>  ${MyWorkSpace_ROOT_DIR}/algoCommon/pthread/dll/xyz.dll
  ${MyWorkSpace_ROOT_DIR}/xml/addAlgo/.../cmakeOut.VS12/Debug/abc.exe
</code></pre>

<p>abc is my Project and i would like to confirm whether the following mentioned is wrong or not.</p>

<pre><code>add_custom_command(TARGET abc PRE_BUILD 
                   COMMAND ${CMAKE_COMMAND} -E copy_if_different
                   "${MyWorkSpace_ROOT_DIR}/algoCommon/pthread/dll"              
$&lt;{MyWorkSpace_ROOT_DIR}/xml/addAlgo/.../cmakeOut.VS12/Debug/:abc&gt;)
</code></pre>

<p>If this is wrong kindly correct me. 
If it is correct then I would like to ask few doubts..
will this command automatically copies the <code>xyz.dll</code> files into the folder <code>abc.exe</code> is residing or something else is happening here??</p>