Yes. Sorry.
Thank you for the answer. The suggested approach is definitely one I have considered (apart from the SYMBOLIC property), but it results in a proliferation of targets since there would be one for each file. A much more maintainable approach is to have add_custom_command
per file and one target that depends on them.
Regarding issue #12877 (closed) - you mentioned elsewhere that #21364 is the right one. Sorry for that.
Just wanted to add another +1 for this feature as it is very useful when trying to compile shaders/move assets to the target directory using code along the following lines (and having it support clear, not running unless needed etc.):
add_custom_command(
OUTPUT "$<TARGET_FILE_DIR:tgt>/assets/shader.spv"
COMMAND glslc.exe -o "$<TARGET_FILE_DIR:tgt>/assets/shader.spv" "${PROJECT_SOURCE_DIR}/resources/shader.vert"
DEPENDS "${PROJECT_SOURCE_DIR}/resources/shader.vert"
)
add_custom_target(res_tgt
DEPENDS "$<TARGET_FILE_DIR:tgt>/assets/shader.spv"
)
Currently all the commands to add_custom_target
need to be specified up front. It makes writing helper functions difficult without proliferation of targets.
function(generate_file from to)
...
endfunction()
With some method of adding commands to an already existing custom target this type of interface cloud be build.
This again related to working around #12877
ADDITIONAL_CLEAN_FILES
property is currently respected by Ninja and Makefile generators. It could be added to MSVC via MSBuild target AfterClean
section:
<Target Name="AfterClean">
<Delete Files="$(OutDir)\$(TargetName).exe" ContinueOnError="true" />
</Target>
It is a useful tool to have while #12877 is still worked on.