I'm trying to copy assets (images, docs, resources, etc.) to the output directory, e.g. build/. Currently I'm using the following method:
add_custom_command(
TARGET my-project POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/assets
${CMAKE_BINARY_DIR}
)
It works just as I need, until the multi-configuration generators (such as Visual Studio) come into play. Since they generate separate Debug and Release directories for my target, I get the following result:
- The executable is put into the
build/Debugdirectory - The assets are put into the
build/directory
Obviously, I want both assets and the executable go either to build/ or build/Debug (the second one is preferred, otherwise we lose the whole point of the multi-configuration generators).
How should I handle this (pretty widespread, in my opinion) case?