[CMake] Copying of 3rd party DLLs in a POST-BUILD step

John Drescher drescherjm at gmail.com
Mon Jan 9 09:51:05 EST 2012


2012/1/9 Hauke Heibel <hauke.heibel at googlemail.com>:
> Hi Michael,
>
> What I do is running a custom command which itself executes a CMake
> script. Usually similar to
>
> add_custom_command(TARGET CopyDlls
>  COMMAND ${CMAKE_COMMAND}
>        -DMSVC_BUILD_CONFIG_DIR=${CMAKE_CFG_INTDIR}
>        -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
>        -P "<pathto>/yourCopyDlls.cmake"
>  VERBATIM
> )
>
> In the "yourCopyDlls.cmake", you can GLOB your DLLs with or without
> the "d" postfix depending on MSVC_BUILD_CONFIG_DIR. You can now even
> copy additional files such as e.g. PDB files.
>

Thanks for sharing this. I use cmake generate a batch file (using
FILE(append ...) ) that calls cmake -E copy_if_different for each
file. then add this as a custom target however your method looks much
cleaner..


John


More information about the CMake mailing list