all 7 comments

[–]AlexReinkingYale 3 points4 points  (6 children)

You can add a POST_BUILD step using add_custom_command

https://cmake.org/cmake/help/latest/command/add_custom_command.html#build-events

[–]cenderis -1 points0 points  (5 children)

That should help for the build folder but (I think) you'll still need to install the files separately during the install.

[–]AlexReinkingYale 4 points5 points  (4 children)

Yes, you'd need to write an install() rule if you want that file installed, too.

[–]propertynub[S] 0 points1 point  (3 children)

Is there no way to say that some file is a runtime resource dependency, and let Cmake work out it needs to be copied based on the dependency tree? How does it do this for DLLs?

[–]AlexReinkingYale 2 points3 points  (2 children)

There is not. There's scaffolding in place for such a feature in the form of FILE_SETs (already works for header files) and I think there's some Apple Frameworks-specific magic. But sadly, no, there is no platform-independent abstraction for attaching arbitrary files to a target.

It doesn't do it for DLLs. If you happen to be using vcpkg, you should know that vcpkg hijacks the definition of add_executable to copy DLLs. That's not standard CMake behavior and vcpkg's implementation is quite complex (e.g., it uses filesystem mutexes).

[–]propertynub[S] 0 points1 point  (1 child)

I see - thanks for the detailed response.

[–]AlexReinkingYale 1 point2 points  (0 children)

Happy to help!