The easiest way to do this is to build all your dlls and exes into the same location by setting the *_OUTPUT_DIRECTORY variables. VTK has a chunk of code like this right at the top of its CMakeLists file to do this:<div><br>
</div><div><div>  if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)</div><div>    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY &quot;${VTK_BINARY_DIR}/bin&quot;)</div><div>  endif()</div><div>  if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)</div><div>
    if(UNIX)</div><div>      set(CMAKE_LIBRARY_OUTPUT_DIRECTORY &quot;${VTK_BINARY_DIR}/lib&quot;)</div><div>    else()</div><div>      set(CMAKE_LIBRARY_OUTPUT_DIRECTORY &quot;${VTK_BINARY_DIR}/bin&quot;)</div><div>    endif()</div>
<div>  endif()</div><div>  if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)</div><div>    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY &quot;${VTK_BINARY_DIR}/lib&quot;)</div><div>  endif()</div><div>  mark_as_advanced(CMAKE_RUNTIME_OUTPUT_DIRECTORY</div>
<div>    CMAKE_LIBRARY_OUTPUT_DIRECTORY</div><div>    CMAKE_ARCHIVE_OUTPUT_DIRECTORY</div><div>    )</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 16, 2012 at 5:18 PM, Thomas Nilsson <span dir="ltr">&lt;<a href="mailto:thomas.nilsson@responsive.se" target="_blank">thomas.nilsson@responsive.se</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On DLL platforms (Windows and Cygwin) shared libraries are found through the PATH and not in some .../lib directory. (There the link stubs are kept.)<br>

<br>
If I build a shared library in one part of my build tree how can I make sure that this is the DLL that will be loaded when I run an executable from some other part of my build tree using cmake?<br>
<br>
This would mean that the PATH need to be set so I can do that if I run from the command line. But is it possible to modify the PATH from within Cmake so that e.g. tests always use the correct DLL?<br>
<br>
/Thomas<br>
<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br></div>