Comment line for custom target has added leading 1>

For example:

    set(name example)
    add_executable(${name} ${...})

    set(customName customTarget)
    add_custom_target(${customName} COMMENT "#${customName}"
        COMMAND ${CMAKE_COMMAND} -E echo $<TARGET_FILE:${name}>
    )
1>#customTarget
<path to build folder>/Debug/example.exe

Is this 1> a bug, intended to redirect it to the standard error?

Can you share more about your build environment? This looks like the way MSBuild prefixes project build output with the ordinal number of the project being built.

As of right now the generator is not explicitly specified, so it defaults:
CMAKE_GENERATOR:INTERNAL=Visual Studio 18 2026

Is it documented that Visual Studio does that? I am not using a full Visual Studio install, only build tools.

This is not the first project I have used a custom target COMMENT, in for printing a marker which indicates the start of the custom target’s output. I can’t remember if I have ever ran in to this issue in the past. If I have, I very much forgot.