[CMake] add_test and locating dependent DLL's on Windows

Scott Gray sgray at inventa.com
Tue May 12 11:18:32 EDT 2009


Werner Smekal wrote:
> Hi.
>   
>> As I said, on Linux when I do "make test", my_test gets run fine--I
>> think because rpath is properly recording the location of the shared
>> libraries.   On windows (Visual Studio 2005), my_test will not run.
>> When I execute ctest by hand, I am told that it cannot locate
>> 'util.dll' (as well as icuuc.dll, etc.)
>>     
> You must now add this directory (${CMAKE_CURRENT_BINARY_DIR}/dll) to
> the PATH environment variable, the easiest way, since you use VS 2005)
> is to go to Start->Control Panel->System->Advanced->Environment
> Variables and change the PATH variable there. You must at least quit
> Visual C++ and restart to recognize the new PATH variable and
> sometimes even this doesn't suffice - you must restart the system.
> Then the dlls will be found since they are located in a path listed in
> the PATH variable.
>   

Thanks for the quick response, Werner.

Setting the PATH externally is a little bit of a pain as we will 
ultimately end up with quite a few directories with DLL's in them as our 
project moves forward and it will be a hassle for each engineer to 
manage their PATH to ensure things work correct.  Also, I have managed 
to construct our build system such that there virtually no external 
dependencies upon the developer.

So, I guess I have two choices:

1. I can copy the tests into a staging environment so that they are 
sitting along side the DLL's prior to running them.
2. I saw that there is an upcoming feature in the CVS tree in which 
environment variables can be set for tests.  If this is the case, then I 
could see if setting the PATH for the test case can work.

Has anyone tried #2?

> There is actually a possibility to tell Visual C++ directly where the
> DLL is located (by changing the PATH variable for one configuration
> inside VS), but I don't remember right now how and I'm just on the
> wrong OS right now to have a look.
>   

Obviously I want to avoid having the developer manually editing the 
project that cmake has produced, so if such a feature exists, I'd like 
to track down how to make cmake spit it out for me.

Once again, thanks for the quick response!
-scott

-- 
Scott C. Gray
Chief Technologist
ANTs Software, Inc.
Inventa Technologies, Inc.
(W) 856-914-5212
(C) 609-304-3429



More information about the CMake mailing list