I am aware of Custom command results in MSB8065 warnings in Visual Studio 2019. That is a different issue. In that case the custom command OUTPUT is not a real file. In this case it is a real file, actually a directory. Setting the SYMBOLIC property does not help.
With the following very simple CMake project that has a single custom target to create a directory I am getting the subject warning.
cmake_minimum_required(VERSION 3.25)
include(CMakePrintHelpers)
project(TestDirCreation
VERSION 1.0
DESCRIPTION "Simple test of creating a directory"
)
set(BUILDTIME_RESOURCES_DIR resources)
add_custom_command(
OUTPUT ${BUILDTIME_RESOURCES_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory "${BUILDTIME_RESOURCES_DIR}"
COMMENT "Make resources directory"
VERBATIM
)
add_custom_target(
buildtime_resources_dir
DEPENDS ${BUILDTIME_RESOURCES_DIR}
)
When running the build with this
cmake --build build --config Release --target buildtime_resources_dir
the projects created by both the VS2022 and VS2026 generators give the warning
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(254,5): w
arning MSB8065: Custom build for item "C:\Users\mark\Projects\khronos\github\test_create_dir\build\CMakeFiles\50efc16c9
d132abaa8a164aece7e2f3a\resources.rule" succeeded, but specified output "c:\users\mark\projects\khronos\github\test_cre
ate_dir\build\resources" has not been created. This may cause incremental build to work incorrectly. [C:\Users\mark\Pro
jects\khronos\github\test_create_dir\build\buildtime_resources_dir.vcxproj]
But the output file resources (actually a directory) is created.
There is no problem when using the Ninja generator.
This is with CMake 4.4. It was happening with earlier versions too.
Any idea what the problem is and how to fix it?