CMake: Copy files after build

If you need to e.g. bundle/copy data along your build you can use a call similar to this. Just make sure to select the target you want to 'target'.

Possible copy hooks are: PRE_BUILD | PRE_LINK | POST_BUILD

Single files

add_custom_command(
        TARGET ${PROJECT_NAME}  POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy
                ${CMAKE_CURRENT_BINARY_DIR}/config/config.yaml
                ${CMAKE_CURRENT_BINARY_DIR}/bin/config/config.yaml)

Directories:

add_custom_command(TARGET ${PROJECT_NAME}  POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy_directory
                ${CMAKE_CURRENT_SOURCE_DIR}/res
                ${CMAKE_CURRENT_BINARY_DIR}/res)

More read: https://cmake.org/cmake/help/v3.0/command/add_custom_command.html