[CMake] Copying DLLs to output directory

Robert Dailey rcdailey.lists at gmail.com
Tue Oct 28 13:25:26 EDT 2014


I have a third party library like OpenSSL prebuilt for each platform
and in my own structure in version control. I have a CMake script that
creates an INTERFACE library target for it. I setup the include
directories and link targets. However, I don't see a way to configure
DLLs in the interface library target. How would you do this, and what
would CMake do to these targets to make sure they are copied to the
output directory of the executable I run from Visual Studio for
debugging?

On Tue, Oct 28, 2014 at 12:21 AM, Hendrik Sattler
<post at hendrik-sattler.de> wrote:
> Hi,
>
> you can use generator expression in a post build rule to copy the dll file to the same target dir as the target you link it with. The easiest way to do this is to properly define all 3rd party libraries as imported targets that contains both, the lib and the dll file.
> Sadly, the FindQt4 on Windows doesn't do this and thus make life harder than needed. CMake configuration files should always do this right.
>
> OTOH, you could also write a wrapper batch file or change VS properties to modify PATH to include all libraries before the regular path.
>
> HS
>
>
> Am 28. Oktober 2014 02:55:08 MEZ, schrieb Robert Dailey <rcdailey.lists at gmail.com>:
>>This actually used to be a very difficult problem to solve. However,
>>to debug in visual studio it's essential.
>>
>>If I have DLLs located in third party directories OR from targets that
>>I depend on, those must all be copied to the directory of the
>>executable I'm debugging in order for those DLLs to be found and
>>loaded.
>>
>>Using CMake 3.0.2, I hope this task is simpler, especially with the
>>introduction of a nice suite of generator expressions. Can anyone
>>recommend a good way to do this?
>


More information about the CMake mailing list