# How use custom Post Build Steps with Multi Config Generators

**URL:** https://discourse.cmake.org/t/how-use-custom-post-build-steps-with-multi-config-generators/5554
**Category:** Usage
**Created:** [April 27, 2022, 9:14am UTC](https://discourse.cmake.org/t/how-use-custom-post-build-steps-with-multi-config-generators/5554 "2022-04-27T09:14:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![JuliusCaesar](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@JuliusCaesar](https://discourse.cmake.org/u/JuliusCaesar)
#### Post date: [April 27, 2022, 9:14am UTC](https://discourse.cmake.org/t/how-use-custom-post-build-steps-with-multi-config-generators/5554/1 "2022-04-27T09:14:00Z")

</div>

Hey guys,  
we are using Ninja Multi Config for Windows and Cross Platform ARM embedded builds.  
On Windows (native) Ninja multi Config Works fine, however our Cross Platform Target Build needs some extra custom commands.

The simplified syntax is as follows

```auto

add_executable( ${APP_NAME} ${APP_SRC} )
target_include_directories(${APP_NAME} PRIVATE ...)
target_link_libraries(${APP_NAME} PRIVATE ...)

      # ###########################################################
      # create map files
      # ###########################################################

add_custom_command(
TARGET "${APP_NAME}"
   POST_BUILD
    COMMAND ${CMAKE_NM} --format=sysv --demangle --line-numbers "${PROJECT_BINARY_DIR}/bin/${APP_NAME}${CMAKE_EXECUTABLE_SUFFIX}" > "${PROJECT_BINARY_DIR}/bin/map/${APP_NAME}.nmap")

```

Now as you can see the custom command expects the binary to be located in ./bin.

However - due to the multi config generator - the binary is now located in  
./bin/Debug  
or  
./bin/Release

How can I get the actual binary path? CMAKE\_CURRENT\_BINARY points to the ./bin folder and not the ./bin/Debug folder.

Thx for your help 🙂

---

<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: [April 27, 2022, 10:23am UTC](https://discourse.cmake.org/t/how-use-custom-post-build-steps-with-multi-config-generators/5554/2 "2022-04-27T10:23:23Z")

</div>

You can replace all of that with `$<TARGET_FILE:${APP_NAME}>` and it’ll work everywhere including when `CMAKE_RUNTIME_DESTINATION` changes where binaries end up or `OUTPUT_NAME` changes the name of the file on disk. You can also use `$<TARGET_FILE_DIR>` to compute the destination file path.

---

<div class="post-metadata">

### Author: ![JuliusCaesar](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/85e7bf/32.png) [@JuliusCaesar](https://discourse.cmake.org/u/JuliusCaesar)
#### Post date: [April 27, 2022, 11:28am UTC](https://discourse.cmake.org/t/how-use-custom-post-build-steps-with-multi-config-generators/5554/3 "2022-04-27T11:28:22Z")

</div>

Thank you Ben, that worked nicely 🙂
