[CMake] Copying files to runtime directory

Jeroen Dierckx jeroen.dierckx at gmail.com
Mon Sep 21 11:48:38 EDT 2009


On Mon, Sep 21, 2009 at 5:29 PM, Tyler Roscoe <tyler at cryptio.net> wrote:
> On Mon, Sep 21, 2009 at 02:54:04PM +0200, Jeroen Dierckx wrote:
>> In Windows, we need to copy a bunch of files (dlls and other runtime
>> dependencies) to the runtime directory, mostly belonging to external
>> dependencies. Those files are different for debug and release builds.
>> So I created a function to do just that. I came across several
>> problems or limitations in cmake while doing that. Here is how I did
>> it, and some remarks for each step
>
> I posted a thread last Thursday with similar questions.
>
> The short version, I think, is that you really want to use install() for
> these kinds of operations. install() already knows how to EXCLUDE, copy
> files on a per-configuration basis, and update files when they are
> out-of-date.
>
> If you don't use install(), I think the types of hacks you mentioned
> (copy all files, debug and release; manually handle exclusions) are the
> only way to do what you want.

I understand your reasoning, but I don't completely agree.

We do use the install commands, but for preparing the build for
packaging. That way, we can use cpack later on to release our SDK or
applications. The problem is that I have to build the install target
every time I want to debug something, which is not exactly ideal. But
maybe doing that is easier than what I am trying to achieve now :-)

How do other windows users do this kind of thing? The problem is that,
when linking with external dynamic libraries, the dlls belonging to
that library have to be in the runtime directory in order for the
application to start.

One of the problems I have with using install for this, is that I
don't want to clutter the install directory with files generated at
runtime. Also, I'm not sure Visual Studio would find all debug files
(which are not installed, so inside the build directories). But I am
going to try this method and see how it works out.

Thanks for the info!

Greetings,
JeDi


More information about the CMake mailing list