[CMake] running executables linked to a dll in the build directory

Philip Lowman philip at yhbt.com
Wed Dec 17 01:06:35 EST 2008


On Tue, Dec 16, 2008 at 3:58 PM, Brad Aisa <Brad.Aisa at colorado.edu> wrote:

> From: "Ladanyi, Akos" <ladanyi at tmit.bme.hu>
>> Subject: [CMake] running executables linked to a dll in the build
>>        directory
>>
>> My source tree consists of a library, and some test programs for the
>> library. The library is built as a dll, and the test programs link
>> against the import library of this dll. When I try to run the test
>> programs (in the build tree), they fail, because they can not find the
>> dll. What is the proper way of solving this with CMake?
>>
>> The only solution I found in the archives is setting
>> RUNTIME_OUTPUT_DIRECTORY so that the dll and the executables end up in
>> the same folder. Is there a better way?
>>
>
> YIKES! Some of those other answers were very complicated. Your suggestion
> is the best approach -- Windows automatically looks in the current folder
> for dlls (unlike Unix which has no default), so this is by far the easiest
> way.
>  See also the CMAKE_RUNTIME_OUTPUT_DIRECTORY (I think that is what it is
> called) that you can set once, which then sets the RUNTIME_... automatically
> for your targets.


I agree that's the best option.

One other option (hardly worth mentioning) might be to run your test
binaries within CTest and use the latest support in CMake CVS for setting
environment variables for tests (i.e. set PATH to be
"$ENV{PATH};${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" ).

http://cmake.org/Bug/view.php?id=7885


-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20081217/2766d51d/attachment.htm>


More information about the CMake mailing list