add_custom_command: MSBuild always runs POST_BUILD commands
When the underlying build tool is Visual Studio, add_custom_command gets executed regardless of whether the specified target is rebuilt or not. This behavior seems to be inconsistent with the documentation, "the command becomes part of the target and will only execute when the target itself is built. If the target is already built, the command will not execute."
For example, given the below CMakeLists.txt file, when I run the build multiple times without modifying any files, the custom command gets executed every time. Note that the target was never rebuilt after the very first build.
cmake_minimum_required(VERSION 3.5)
project(test.proj)
add_executable(test.proj main.cpp)
add_custom_command(TARGET test.proj
POST_BUILD
COMMAND echo "RUN POST-BUILD CUSTOM COMMAND"
COMMENT "Run custom command")