<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 7, 2019 at 7:11 AM Brad King via cmake-developers <<a href="mailto:cmake-developers@cmake.org">cmake-developers@cmake.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">On 2/6/19 2:40 PM, Joachim Wuttke wrote:<br>
> And combine it with<br>
> <br>
> ```<br>
> link_directories(BEFORE ${PROJECT_BINARY_DIR}/bin)<br>
> ```<br>
> <br>
> so that tests find the libraries?<br>
<br>
No.  CMAKE_RUNTIME_OUTPUT_DIRECTORY only affects the locations of<br>
the .dll files, not .a/.so/.lib.  Also CMake already knows where<br>
the library files will be and links via absolute path.  Link<br>
directories are almost never needed.<br>
<br>
> Anyway, my problem is not at link time, but when _executing_ a test.<br>
> Is there a canonical way of manipulating the Windows PATH from CMake?<br>
<br>
No.  In general one should not depend on PATH for .dll locations<br>
within your own project.<br>
</blockquote></div><div><br></div>That's probably a bit strong, for very large projects it can be quite inconvenient to have to put all executables and DLLs in the same directory. For some scenarios, it's not a viable choice (can depend on the project's directory layout requirements). There are a few ways to get this to work for different scenarios, some depending on a more recent CMake version. For tests run through CTest, The ENVIRONMENT test property can be used to augment PATH on a test-by-test basis. For running under the Visual Studio debugger, CMake 3.13 added the VS_DEBUGGER_ENVIRONMENT target property which again can be used to set the PATH for a particular test executable when run from within the VS IDE. If you need to support an older CMake version, an equivalent functionality can be achieved with CMake 3.8 or later using the VS_USER_PROPS target property, but this is more involved.<br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div><div><br></div><div>Get the hand-book for every CMake user: <a href="https://crascit.com/professional-cmake/" target="_blank">Professional CMake: A Practical Guide</a><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div>