diff options
author | Vedran Vujinovic <vedran.vujinovic@gmail.com> | 2019-09-04 09:11:45 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-09-19 15:47:15 (GMT) |
commit | acdb326610416ea3a559740fa79ad807a44838ee (patch) | |
tree | 5726036312ab20f743f38db40ffb8f3b24dec6bb /Source/cmVisualStudio10TargetGenerator.cxx | |
parent | 9c31d83aa2a3d3f5921f4a5a559e126e285b96c5 (diff) | |
download | CMake-acdb326610416ea3a559740fa79ad807a44838ee.zip CMake-acdb326610416ea3a559740fa79ad807a44838ee.tar.gz CMake-acdb326610416ea3a559740fa79ad807a44838ee.tar.bz2 |
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
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 28 |
1 files 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"); } |