# Creation of VS build event

**URL:** https://discourse.cmake.org/t/creation-of-vs-build-event/10969
**Category:** Usage
**Created:** [June 7, 2024, 2:35am UTC](https://discourse.cmake.org/t/creation-of-vs-build-event/10969 "2024-06-07T02:35:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![gibbogle](https://discourse.cmake.org/user_avatar/discourse.cmake.org/gibbogle/32/4648_2.png) [@gibbogle](https://discourse.cmake.org/u/gibbogle)
#### Post date: [June 7, 2024, 2:35am UTC](https://discourse.cmake.org/t/creation-of-vs-build-event/10969/1 "2024-06-07T02:35:27Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 13, 2025, 6:29pm UTC](https://discourse.cmake.org/t/creation-of-vs-build-event/10969/2 "2025-03-13T18:29:40Z")

</div>

I think you want `POST_LINK` because the target won’t (be guaranteed to) exist just at `POST_BUILD` time. However, why not set [`RUNTIME_OUTPUT_DIRECTORY`](https://cmake.org/cmake/help/latest/prop_tgt/RUNTIME_OUTPUT_DIRECTORY.html) to just have CMake put it in the place you want it?
