From acdb326610416ea3a559740fa79ad807a44838ee Mon Sep 17 00:00:00 2001 From: Vedran Vujinovic Date: Wed, 4 Sep 2019 11:11:45 +0200 Subject: VS: Do not reference output assemblies of targets with no output Our logic that sets `ReferenceOutputAssembly` in `ProjectReference` has accumulated a series of conditions for different cases in which the referenced target has no output. Simplify the condition to check `GetManagedType` directly for cases with no output. This will explicitly turn off `ReferenceOutputAssembly` in `ProjectReference` for utility (i.e. `add_custom_target`) and special targets (i.e. `ZERO_CHECK`, etc.), and allowing reference of target dependencies that produce some output. Fixes: #19665 --- Source/cmVisualStudio10TargetGenerator.cxx | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ba72294..b1acccb 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -4092,32 +4092,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0) e2.Element("Name", name); this->WriteDotNetReferenceCustomTags(e2, name); - // If the dependency target is not managed (compiled with /clr or - // C# target) and not a WinRT component we cannot reference it and - // have to set 'ReferenceOutputAssembly' to false. - auto referenceNotManaged = - dt->GetManagedType("") < cmGeneratorTarget::ManagedType::Mixed; - // Workaround to check for manually set /clr flags. - if (referenceNotManaged) { - if (const auto* flags = dt->GetProperty("COMPILE_OPTIONS")) { - std::string flagsStr = flags; - if (flagsStr.find("clr") != std::string::npos) { - // There is a warning already issued when building the flags. - referenceNotManaged = false; - } - } - } - // Workaround for static library C# targets - if (referenceNotManaged && dt->GetType() == cmStateEnums::STATIC_LIBRARY) { - referenceNotManaged = !dt->IsCSharpOnly(); - } - - // Referencing WinRT components is okay. - if (referenceNotManaged) { - referenceNotManaged = !dt->GetPropertyAsBool("VS_WINRT_COMPONENT"); - } - - if (referenceNotManaged) { + // Don't reference targets that don't produce any output. + if (dt->GetManagedType("") == cmGeneratorTarget::ManagedType::Undefined) { e2.Element("ReferenceOutputAssembly", "false"); e2.Element("CopyToOutputDirectory", "Never"); } -- cgit v0.12