summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmGeneratorTarget.cxx8
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx36
-rw-r--r--Tests/RunCMake/VS10Project/VsCSharpCustomTags-stderr.txt3
-rw-r--r--Tests/RunCMake/VS10Project/VsCSharpReferenceProps-stderr.txt8
4 files changed, 41 insertions, 14 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index bf5ff65..799ae95 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -5510,12 +5510,14 @@ cmGeneratorTarget::ManagedType cmGeneratorTarget::GetManagedType(
const std::string& config) const
{
// Only libraries and executables can be managed targets.
- if (this->GetType() != cmStateEnums::SHARED_LIBRARY &&
- this->GetType() != cmStateEnums::STATIC_LIBRARY &&
- this->GetType() != cmStateEnums::EXECUTABLE) {
+ if (this->GetType() > cmStateEnums::SHARED_LIBRARY) {
return ManagedType::Undefined;
}
+ if (this->GetType() == cmStateEnums::STATIC_LIBRARY) {
+ return ManagedType::Native;
+ }
+
// Check imported target.
if (this->IsImported()) {
if (cmGeneratorTarget::ImportInfo const* info =
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");
}
}
diff --git a/Tests/RunCMake/VS10Project/VsCSharpCustomTags-stderr.txt b/Tests/RunCMake/VS10Project/VsCSharpCustomTags-stderr.txt
new file mode 100644
index 0000000..1ea3b51
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpCustomTags-stderr.txt
@@ -0,0 +1,3 @@
+^CMake Deprecation Warning in CMakeLists.txt:
+ The C# target "foo" is of type STATIC_LIBRARY. This is discouraged \(and
+ may be disabled in future\). Make it a SHARED library instead.$
diff --git a/Tests/RunCMake/VS10Project/VsCSharpReferenceProps-stderr.txt b/Tests/RunCMake/VS10Project/VsCSharpReferenceProps-stderr.txt
new file mode 100644
index 0000000..4402b8f
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpReferenceProps-stderr.txt
@@ -0,0 +1,8 @@
+^CMake Deprecation Warning in CMakeLists.txt:
+ The C# target "foo2" is of type STATIC_LIBRARY. This is discouraged \(and
+ may be disabled in future\). Make it a SHARED library instead.
+
+
+CMake Deprecation Warning in CMakeLists.txt:
+ The C# target "foo" is of type STATIC_LIBRARY. This is discouraged \(and
+ may be disabled in future\). Make it a SHARED library instead.$