[CMake] Dealing with dll PATH on Windows

Bill Hoffman bill.hoffman at kitware.com
Fri May 23 12:27:54 EDT 2008


KSpam wrote:
> Bill,
> 
> On Friday 23 May 2008 06:14:27 Bill Hoffman wrote:
>> So, there is not much CMake can do for you.  The only thing you can do
>> on windows is make sure that .exe and .dll files are all in the same
>> directory.  Windows always looks first in the directory of the .exe for
>> any .dll files it needs.  CMake can put the files in the same directory.
>>   That is what we do for software development and distribution on Windows.
> 
> Since the developers can use different versions of the same third-party 
> library, I do not have the option to put all dlls in the same directory.
> 
> I could potentially create custom commands to copy all of the runtime-required 
> dlls to a single directory, but I really do not want to do this.
> 
> The slnenv add-in (mentioned in previous posts) would give me the capability 
> that I need.  I could simply add a single line to the slnenv file in order to 
> set PATH.  My only problem is trying to generate a slnenv file for each sln 
> file generated.  My project has a hierarchical structure, and I can build 
> from lower-level solution files if I only want to build subportions of the 
> overall project.  This means I would have to generate a slnenv file for the 
> lower-level sln files in addition to the top-level sln file.
> 
> I would just like to know the best way to generate the slnenv files.
> 

But that would only work if they are using the IDE, nmake and make 
builds would still not work.  Another approach is to use a forwarding 
executable.  Have a wrapper program that sets PATH as needed to run 
things, and then execs the program once the path is setup.

-Bill


More information about the CMake mailing list