vcpkg: The target "ClassLibrary" does not currently support add_custom_command
I am getting the following error from cmake 3.26.3:
-- Configuring done (47.0s)
CMake Error in ClassLibrary/CMakeLists.txt:
The target "ClassLibrary" does not currently support add_custom_command as
the Visual Studio generators have not yet learned how to generate custom
commands in .Net SDK-style projects.
It should be noticed that my project does not make explicit use of add_custom_command
. As a side note the error message does not contains a line number right after the :
sign.
Working steps:
Integration of vcpkg triggers the error here:
CSharp project (added as subdirectory because of issue #24867) is:
cmake_minimum_required(VERSION 3.25)
project(DotNet LANGUAGES CSharp)
add_library(ClassLibrary SHARED Class.cs)
set_property(TARGET ClassLibrary PROPERTY DOTNET_SDK "Microsoft.NET.Sdk")
set_property(TARGET ClassLibrary PROPERTY DOTNET_TARGET_FRAMEWORK "net6.0")
set_property(TARGET ClassLibrary PROPERTY VS_PACKAGE_REFERENCES
"Microsoft.Extensions.Logging_7.0.0")
install(
TARGETS ClassLibrary
DESTINATION lib/net6.0
COMPONENT CSharpLibraries)
Edited by Mathieu Malaterre