# Testing targets with shared libraries on Windows

**URL:** <https://discourse.cmake.org/t/testing-targets-with-shared-libraries-on-windows/707>\
**Category:** Code\
**Created:** [February 26, 2020, 7:20pm UTC](https://discourse.cmake.org/t/testing-targets-with-shared-libraries-on-windows/707 "2020-02-26T19:20:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)\
**Post date:** [February 26, 2020, 7:20pm UTC](https://discourse.cmake.org/t/testing-targets-with-shared-libraries-on-windows/707/1 "2020-02-26T19:20:53Z")

</div>

I have a working build and test set up on Linux (yay!) but Windows continues to pose challenges. Everything builds fine, but all tests fail with “MyProj.dll” not found!

I suppose this is because they are in different directories. Is there some CMake-approved way to make sure that MyProj.dll’s path is in the PATH of the tests (some of which need to have the usual system PATH intact)? Or is there a better way to help my test executables find the DLL?

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [February 28, 2020, 8:39pm UTC](https://discourse.cmake.org/t/testing-targets-with-shared-libraries-on-windows/707/2 "2020-02-28T20:39:46Z")

</div>

I’d place your test binaries in the same place as your DLLs with the `CMAKE_RUNTIME_OUTPUT_DIRECTORY` variable (which defaults the per-target `RUNTIME_OUTPUT_DIRECTORY` property).

---

<div class="post-metadata">

**Author:** ![alex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alex/32/125_2.png) [@alex](https://discourse.cmake.org/u/alex)\
**Post date:** [February 28, 2020, 8:41pm UTC](https://discourse.cmake.org/t/testing-targets-with-shared-libraries-on-windows/707/3 "2020-02-28T20:41:49Z")

</div>

Are there any disadvantages to that? There are also currently a lot of test targets that are simply named “test” from “test.cpp” in different folders…

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [February 28, 2020, 8:43pm UTC](https://discourse.cmake.org/t/testing-targets-with-shared-libraries-on-windows/707/4 "2020-02-28T20:43:54Z")

</div>

They’d have to have different CMake target names anyways, so I’d suggest naming their binaries using the CMake target name.
