I have a CMake project with next post_build command:
add_custom_command(TARGET ncd_json
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/ncd.json
$<TARGET_FILE_DIR:ncd_json>/ncd.json
COMMENT "Copy ncd.json into binaries folder"
)
ncd.json
is copied every time target build. But I really need to copy this file only if it is changed, and even if target is already built and this is the main problem.
I think this question is not full duplicate of CMake copy if original file changed but supplements it.