You can use add_custom_command.
Say your target is called MyTarget, then you can do this:
add_custom_command(TARGET MyTarget PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/config/ $<TARGET_FILE_DIR:MyTarget>)
This executes every time you build MyTarget and copies the contents of “/config” into the directory where the target exe/lib will end up.
As Mark Lakata points out in a comment below, replacing PRE_BUILD with POST_BUILD in the add_custom_command ensures that copying will only happen if the build succeeds.
Explanation
${CMAKE_COMMAND}is the path to CMake-Emakes CMake run commands instead of buildingcopy_directoryis a Command-Line Toolconfigis the directory (that falls under the root of the project) whose contents will be copied into the build target$<TARGET_FILE_DIR:MyTarget>is a generator expression, described in theadd_custom_commanddocumentation.