Creation of VS build event

My CMakeLists.txt has this line at the end:
ADD_CUSTOM_COMMAND(TARGET ${PROJECTNAME} POST_BUILD COMMAND copy "$(TargetPath)" "…/bin/exec")

I think this is meant to add a Post-Build Event to the Build Events in VS (2019), but it doesn’t. I think it used to in an earlier version of VS that I was using (now long gone from my system). I have a sneaking feeling that I previously had some extra connection between cmake and VS installed, but I can’t recall what it was. Can anybody enlighten me?
Thanks.