Copy resources to build folder

I’m doing an OpenGL project where I mostly write shaders and have several texture files. Is there a way I can copy it to the build folder so the binary can access it?

configure_file(COPYONLY) should be able to do it. You can also run it from a script via add_custom_command so that it gets copied at build time and CMake doesn’t need to rerun on any shader/texture changes.

I’ve tackled almost the same issue a dozen times with OpenCL, where I’d need to copy device code next to the executables in both single-config and multi-config cases. I’ve not been able to cook up a robust and simple solution yet. I tried doing my best in the OpenCL-SDK here but it’s both a mouthful and invokes the custom commands more times then strictly necessary (once for each config, no matter which one I’m building). How does one copy source files to build tree when they are likely to change throughout development?

Without requiring 3.20 for genex support in custom command outputs, what you have looks pretty close to what I’d do.