diff options
author | Brad King <brad.king@kitware.com> | 2018-05-08 12:36:10 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-05-08 12:36:20 (GMT) |
commit | 42d198744b8645ee35633c7af6e122d152bda8e9 (patch) | |
tree | 118069052b6e13358d23ba1f37f1aede2b6fe9c0 /Source/cmVisualStudio10TargetGenerator.cxx | |
parent | 65431c727b53ff092ad6f2f8c081982bdde52385 (diff) | |
parent | b7c2b2cd78a8bc16cd7e294c2ae9d5d45f029e22 (diff) | |
download | CMake-42d198744b8645ee35633c7af6e122d152bda8e9.zip CMake-42d198744b8645ee35633c7af6e122d152bda8e9.tar.gz CMake-42d198744b8645ee35633c7af6e122d152bda8e9.tar.bz2 |
Merge topic 'deprecate_static_managed_targets'
b7c2b2cd78 cmVisualStudio10TargetGenerator: add handling of static C# targets
d244f2cad3 cmVisualStudio10TargetGenerator: add handling of manual /clr setting
1e5a8f882f cmVisualStudio10TargetGenerator: fix checking for managed target
8d7ffed048 cmVisualStudio10TargetGenerator: issue warning when adding static C# lib
73ee599a82 cmGeneratorTarget: make GetManagedType() return 'Native' for static targets
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2014
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2e8a2eb..405d2ca 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -333,6 +333,14 @@ void cmVisualStudio10TargetGenerator::Generate() this->ProjectType = vcxproj; this->Managed = false; } else if (this->ProjectFileExtension == ".csproj") { + if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) { + std::string message = "The C# target \"" + + this->GeneratorTarget->GetName() + + "\" is of type STATIC_LIBRARY. This is discouraged (and may be " + "disabled in future). Make it a SHARED library instead."; + this->Makefile->IssueMessage(cmake::MessageType::DEPRECATION_WARNING, + message); + } this->ProjectType = csproj; this->Managed = true; } @@ -3803,18 +3811,24 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0) // If the dependency target is not managed (compiled with /clr or // C# target) we cannot reference it and have to set // 'ReferenceOutputAssembly' to false. - cmGeneratorTarget::ManagedType check = - cmGeneratorTarget::ManagedType::Mixed; - // FIXME: These (5) lines should be removed. They are here to allow - // manual setting of the /clr flag in compiler options. Setting - // /clr manually makes cmGeneratorTarget::GetManagedType() return - // 'Native' instead of 'Mixed' or 'Managed'. - check = cmGeneratorTarget::ManagedType::Native; - bool unmanagedStatic = false; - if (dt->GetType() == cmStateEnums::STATIC_LIBRARY) { - unmanagedStatic = !dt->HasLanguage("CSharp", ""); + 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->HasLanguage("CSharp", ""); } - if (dt->GetManagedType("") < check || unmanagedStatic) { + if (referenceNotManaged) { e2.Element("ReferenceOutputAssembly", "false"); } } |