Browse Source

remove TargetIsCSharpOnly() and use methods from cmGeneratorTarget

Michael Stürmer 7 years ago
parent
commit
f9042d807d

+ 1 - 1
Source/cmGlobalVisualStudio71Generator.cxx

@@ -98,7 +98,7 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
     ext = ".vfproj";
     project = "Project(\"{6989167D-11E4-40FE-8C1A-2192A86A7E90}\") = \"";
   }
-  if (this->TargetIsCSharpOnly(t)) {
+  if (t->HasLanguage("CSharp", "")) {
     ext = ".csproj";
     project = "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"";
   }

+ 1 - 24
Source/cmGlobalVisualStudioGenerator.cxx

@@ -734,33 +734,10 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(
   return false;
 }
 
-bool cmGlobalVisualStudioGenerator::TargetIsCSharpOnly(
-  cmGeneratorTarget const* gt)
-{
-  // C# targets can be defined with add_library() (using SHARED or STATIC) and
-  // also using add_executable(). We do not treat imported C# targets the same
-  // (these come in as UTILITY)
-  if (gt->GetType() != cmStateEnums::SHARED_LIBRARY &&
-      gt->GetType() != cmStateEnums::STATIC_LIBRARY &&
-      gt->GetType() != cmStateEnums::EXECUTABLE) {
-    return false;
-  }
-
-  // Issue diagnostic if the source files depend on the config.
-  std::vector<cmSourceFile*> sources;
-  if (!gt->GetConfigCommonSourceFiles(sources)) {
-    return false;
-  }
-
-  std::set<std::string> languages;
-  gt->GetLanguages(languages, "");
-  return languages.size() == 1 && languages.count("CSharp") > 0;
-}
-
 bool cmGlobalVisualStudioGenerator::TargetCanBeReferenced(
   cmGeneratorTarget const* gt)
 {
-  if (this->TargetIsCSharpOnly(gt)) {
+  if (gt->GetManagedType("") != cmGeneratorTarget::ManagedType::Native) {
     return true;
   }
   if (gt->GetType() != cmStateEnums::SHARED_LIBRARY &&

+ 0 - 3
Source/cmGlobalVisualStudioGenerator.h

@@ -81,9 +81,6 @@ public:
   // return true if target is fortran only
   bool TargetIsFortranOnly(const cmGeneratorTarget* gt);
 
-  // return true if target is C# only
-  static bool TargetIsCSharpOnly(cmGeneratorTarget const* gt);
-
   // return true if target can be referenced by C# targets
   bool TargetCanBeReferenced(cmGeneratorTarget const* gt);
 

+ 12 - 12
Source/cmVisualStudio10TargetGenerator.cxx

@@ -188,9 +188,7 @@ static std::string computeProjectFileExtension(cmGeneratorTarget const* t,
 {
   std::string res;
   res = ".vcxproj";
-  std::string lang = t->GetLinkerLanguage(config);
-  if (cmGlobalVisualStudioGenerator::TargetIsCSharpOnly(t) ||
-      lang == "CSharp") {
+  if (t->HasLanguage("CSharp", config)) {
     res = ".csproj";
   }
   return res;
@@ -3483,15 +3481,17 @@ void cmVisualStudio10TargetGenerator::AddLibraries(
   std::string currentBinDir =
     this->LocalGenerator->GetCurrentBinaryDirectory();
   for (cmComputeLinkInformation::Item const& l : libs) {
-    // Do not allow C# targets to be added to the LIB listing. LIB files are
-    // used for linking C++ dependencies. C# libraries do not have lib files.
-    // Instead, they compile down to C# reference libraries (DLL files). The
-    // `<ProjectReference>` elements added to the vcxproj are enough for the
-    // IDE to deduce the DLL file required by other C# projects that need its
-    // reference library.
-    if (l.Target &&
-        cmGlobalVisualStudioGenerator::TargetIsCSharpOnly(l.Target)) {
-      continue;
+    if (l.Target) {
+      auto managedType = l.Target->GetManagedType("");
+      // Do not allow C# targets to be added to the LIB listing. LIB files are
+      // used for linking C++ dependencies. C# libraries do not have lib files.
+      // Instead, they compile down to C# reference libraries (DLL files). The
+      // `<ProjectReference>` elements added to the vcxproj are enough for the
+      // IDE to deduce the DLL file required by other C# projects that need its
+      // reference library.
+      if (managedType == cmGeneratorTarget::ManagedType::Managed) {
+        continue;
+      }
     }
 
     if (l.IsPath) {