# What is the proper configuration-dependent location for files created by add\_custom\_target or add\_custom\_command?

**URL:** https://discourse.cmake.org/t/what-is-the-proper-configuration-dependent-location-for-files-created-by-add-custom-target-or-add-custom-command/15198
**Category:** Code
**Tags:** gen:vs
**Created:** [September 25, 2025, 7:02pm UTC](https://discourse.cmake.org/t/what-is-the-proper-configuration-dependent-location-for-files-created-by-add-custom-target-or-add-custom-command/15198 "2025-09-25T19:02:31Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![AytonDew](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/a9adbd/32.png) [@AytonDew](https://discourse.cmake.org/u/AytonDew)
#### Post date: [September 25, 2025, 7:02pm UTC](https://discourse.cmake.org/t/what-is-the-proper-configuration-dependent-location-for-files-created-by-add-custom-target-or-add-custom-command/15198/1 "2025-09-25T19:02:31Z")

</div>

Hello,

I have been struggling with intermediate directories and where to place temporary files during the build when running custom commands. Is there a configuration-dependent location that a custom command can create configuration-dependent files when using a Multi-Config generator? In other words, how can I reference, for example, the intermediate directory that visual studio creates?

`$(Platform)$(Configuration)$(ProjectName)`

If I create a minimal example, this command fails because the `$<CONFIG>` dir does not exist when Visual Studio runs the command (it tries to CD to the dir, but it does not yet exist).

```cmake
cmake_minimum_required(VERSION 3.25)
project(myFileMaker)

add_custom_target(dummy ALL
    COMMENT "Dummy target"
    DEPENDS $<CONFIG>/someFile.txt
)

add_custom_command(OUTPUT $<CONFIG>/someFile.txt
    COMMAND ${CMAKE_COMMAND} -E touch someFile.txt # imagine a more complex command, perhaps referencing another target's executable
    COMMENT "Creating someFile.txt"
    WORKING_DIRECTORY $<CONFIG>
)

```

I could, of course, create this directory, but it seems like I am missing something more straightforward.

You should assume that I must run the command from my desired directory (because the actual command creates the file in the current directory, and I cannot give the output file name to this particular command).
