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_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).