[CMake] Copying files to runtime directory

Jeroen Dierckx jeroen.dierckx at gmail.com
Wed Sep 23 15:09:29 EDT 2009


On Wed, Sep 23, 2009 at 9:06 PM, Anatoly Shirokov <shirokov_a at mail.ru>wrote:

>  We use the RUNTIME_OUTPUT_DIRECTORY property to specify runtime location
> for each target:
>
> set_target_properties(bla-bla-bla
>    PROPERTIES
>    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}*/Execute/*${CMAKE_BUILD_TYPE})
>
> )
> I hope it helps.
>

Thanks, but the problem I was facing was about dlls and other files from
external dependencies that need to be copied to the runtime directory.



> Jeroen Dierckx:
>
> Hi,
>
> 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
>
> - For a certain external dependency, I look for a specific
> platform-dependent directory, with some shared files, and some only
> for debug or release builds. I have to exclude certain files and
> directories (.svn directories in this case). It would be nice to have
> an EXCLUDE parameter for the file(GLOB* functions, like in the install
> function. I worked around this by iterating over all the files in the
> list and removing them when they match a certain REGEX.
>
> - I wanted to create post-build command to copy the necessary files
> after building, because they are only needed when actually
> running/debugging the application. There currently is no way to
> generate different custom commands for different configurations. I
> could work around this by using some if-tests inside the custom
> command itself, but I decided against it because it would be too
> Visual Studio-specific.
>
> - So I copy all files to each build directory (one for each
> configuration that is generated, mind that for Visual Studio no build
> configuration is chosen at configure time) in cmake. This of course is
> not very optimal, as it copies the files for all configurations, also
> the ones I will probably never build. Here I used the cmake command
> with -E copy_if_different. This works, but spawns a new process for
> each file to be copied. I could use configure_file, but that seemed a
> bit hacky to me.
>
> All in all, my method works, but to summarize, the following features
> would be a nice addition to cmake:
> - an EXCLUDE parameter for the file globbing commands
> - configuration-specific custom commands
> - a cmake command to copy files (with a parameter to only do it when
> the files differ)
>
> Greetz,
> JeDi
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:http://www.cmake.org/mailman/listinfo/cmake
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090923/db531269/attachment-0001.htm>


More information about the CMake mailing list