# Troubles with VS generator

**URL:** <https://discourse.cmake.org/t/troubles-with-vs-generator/14051>\
**Category:** Code\
**Created:** [May 6, 2025, 1:34pm UTC](https://discourse.cmake.org/t/troubles-with-vs-generator/14051 "2025-05-06T13:34:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oodini](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Post date:** [May 6, 2025, 1:34pm UTC](https://discourse.cmake.org/t/troubles-with-vs-generator/14051/1 "2025-05-06T13:34:09Z")

</div>

Hello,

I am trying tor resolve a problem about the Visual Studio Generator.

In the CMakeLists, there are the following lines:

```auto
...
add_executable(${PROJECT_NAME} WIN32)
...
add_custom_command(
    TARGET ${PROJECT_NAME}
    POST_BUILD
        COMMAND ...
        COMMAND ...
        COMMAND ...)

```

When I configure the project with the **Visual Studio 17 2022** generator, I get in Visual studio three extra targets: **ALL\_BUILD** , **INSTALL** , **ZERO\_CHECK**.

When I build the **ALL\_BUILD** target, the sources are built, and the custom commands are executed. Fine.  
When I build the **INSTALL** target, the `install()` commands are executed, and the custom commands are also executed. **Not fine**.

- why ?
- how to avoid the **INSTALL** target run also the customs command ?

Thanks.

---

<div class="post-metadata">

**Author:** ![Oodini](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Post date:** [May 7, 2025, 9:41am UTC](https://discourse.cmake.org/t/troubles-with-vs-generator/14051/2 "2025-05-07T09:41:48Z")

</div>

OK, I understood what was the problems, because there are two ones:

- the install command launched a build (I’ll open an other post about this point)
- one the post-build command updated the output dir when doing the first build, so a post-build was run a second time.
