On Thu, Feb 7, 2019 at 7:11 AM Brad King via cmake-developers <
cmake-developers@cmake.org> wrote:

> On 2/6/19 2:40 PM, Joachim Wuttke wrote:
> > And combine it with
> >
> > ```
> > link_directories(BEFORE ${PROJECT_BINARY_DIR}/bin)
> > ```
> >
> > so that tests find the libraries?
>
> No.  CMAKE_RUNTIME_OUTPUT_DIRECTORY only affects the locations of
> the .dll files, not .a/.so/.lib.  Also CMake already knows where
> the library files will be and links via absolute path.  Link
> directories are almost never needed.
>
> > Anyway, my problem is not at link time, but when _executing_ a test.
> > Is there a canonical way of manipulating the Windows PATH from CMake?
>
> No.  In general one should not depend on PATH for .dll locations
> within your own project.
>

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.

-- 
Craig Scott
Melbourne, Australia
https://crascit.com

Get the hand-book for every CMake user: Professional CMake: A Practical
Guide <https://crascit.com/professional-cmake/>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers

Reply via email to