When I migrated some old source I got MSB8065 warnings from Visual Studio 2019.
I have managed to reproduce this behavior in a simple example:
cmake_minimum_required(VERSION 3.22)
# set the project name
project(Test)
add_custom_command(OUTPUT my_copy
COMMAND ${CMAKE_COMMAND} -E make_directory foobar
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/test.cpp foobar/test.cpp
)
add_custom_target(myCustomTarget
DEPENDS my_copy)
Will give the following warning:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): warning MSB8065: Custom build for item "C:\Users\alfa\test_build\CMakeFiles\542a2713b6a5fcbc72b938b8e551b81d\my_copy.rule" succeeded, but specified output "c:\users\alfa\test_build\my_copy" has not been created. This may cause incremental build to work incorrectly.
Is there a known workaround for these types of warnings?