# Custom command results in MSB8065 warnings in Visual Studio 2019

**URL:** https://discourse.cmake.org/t/custom-command-results-in-msb8065-warnings-in-visual-studio-2019/4893
**Category:** Code
**Tags:** os:windows, gen:vs
**Created:** [January 24, 2022, 2:56pm UTC](https://discourse.cmake.org/t/custom-command-results-in-msb8065-warnings-in-visual-studio-2019/4893 "2022-01-24T14:56:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![bjornblissing](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bjornblissing/32/896_2.png) [@bjornblissing](https://discourse.cmake.org/u/bjornblissing)
#### Post date: [January 24, 2022, 2:56pm UTC](https://discourse.cmake.org/t/custom-command-results-in-msb8065-warnings-in-visual-studio-2019/4893/1 "2022-01-24T14:56:08Z")

</div>

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:

```auto
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:

```auto
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?

---

<div class="post-metadata">

### Author: ![bjornblissing](https://discourse.cmake.org/user_avatar/discourse.cmake.org/bjornblissing/32/896_2.png) [@bjornblissing](https://discourse.cmake.org/u/bjornblissing)
#### Post date: [January 24, 2022, 3:34pm UTC](https://discourse.cmake.org/t/custom-command-results-in-msb8065-warnings-in-visual-studio-2019/4893/2 "2022-01-24T15:34:54Z")

</div>

Found the solution to my own question.

The custom command needs to be marked as SYMBOLIC like this:

```auto
...
set_source_files_properties(my_copy PROPERTIES SYMBOLIC 1)

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

```
