Pārlūkot izejas kodu

Merge topic 'vs-csproj-scripts'

13a7ae2194 VS: Revert "Add missing label in C# project-build events"

Acked-by: Kitware Robot <[email protected]>
Merge-request: !6781
Brad King 3 gadi atpakaļ
vecāks
revīzija
9ecb24b5a7

+ 2 - 2
Source/cmLocalVisualStudio7Generator.cxx

@@ -591,7 +591,7 @@ public:
     } else {
       this->Stream << this->LG->EscapeForXML("\n");
     }
-    std::string script = this->LG->ConstructScript(ccg, unmanaged);
+    std::string script = this->LG->ConstructScript(ccg);
     this->Stream << this->LG->EscapeForXML(script);
   }
 
@@ -1804,7 +1804,7 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(
     }
 
     std::string comment = this->ConstructComment(ccg);
-    std::string script = this->ConstructScript(ccg, unmanaged);
+    std::string script = this->ConstructScript(ccg);
     if (this->FortranProject) {
       cmSystemTools::ReplaceString(script, "$(Configuration)", config);
     }

+ 1 - 10
Source/cmLocalVisualStudioGenerator.cxx

@@ -126,8 +126,7 @@ const char* cmLocalVisualStudioGenerator::GetReportErrorLabel() const
 }
 
 std::string cmLocalVisualStudioGenerator::ConstructScript(
-  cmCustomCommandGenerator const& ccg, IsManaged isManaged,
-  const std::string& newline_text)
+  cmCustomCommandGenerator const& ccg, const std::string& newline_text)
 {
   bool useLocal = this->CustomCommandUseLocal();
   std::string workingDirectory = ccg.GetWorkingDirectory();
@@ -240,14 +239,6 @@ std::string cmLocalVisualStudioGenerator::ConstructScript(
     script += newline;
     script += "if %errorlevel% neq 0 goto ";
     script += this->GetReportErrorLabel();
-    if (isManaged == managed) {
-      // These aren't generated by default for C# projects.
-      script += newline;
-      script += this->GetReportErrorLabel();
-      script += newline;
-      script += "exit /b 0";
-      script += newline;
-    }
   }
 
   return script;

+ 0 - 6
Source/cmLocalVisualStudioGenerator.h

@@ -31,13 +31,7 @@ public:
   virtual ~cmLocalVisualStudioGenerator();
 
   /** Construct a script from the given list of command lines.  */
-  enum IsManaged
-  {
-    unmanaged,
-    managed
-  };
   std::string ConstructScript(cmCustomCommandGenerator const& ccg,
-                              IsManaged isManaged,
                               const std::string& newline = "\n");
 
   /** Label to which to jump in a batch file after a failed step in a

+ 2 - 8
Source/cmVisualStudio10TargetGenerator.cxx

@@ -1514,10 +1514,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
     cmCustomCommandGenerator ccg(command, c, lg, true);
     std::string comment = lg->ConstructComment(ccg);
     comment = cmVS10EscapeComment(comment);
-    cmLocalVisualStudioGenerator::IsManaged isManaged = (this->Managed)
-      ? cmLocalVisualStudioGenerator::managed
-      : cmLocalVisualStudioGenerator::unmanaged;
-    std::string script = lg->ConstructScript(ccg, isManaged);
+    std::string script = lg->ConstructScript(ccg);
     bool symbolic = false;
     // input files for custom command
     std::stringstream additional_inputs;
@@ -4268,10 +4265,7 @@ void cmVisualStudio10TargetGenerator::WriteEvent(
       comment += lg->ConstructComment(ccg);
       script += pre;
       pre = "\n";
-      cmLocalVisualStudioGenerator::IsManaged isManaged = (this->Managed)
-        ? cmLocalVisualStudioGenerator::managed
-        : cmLocalVisualStudioGenerator::unmanaged;
-      script += lg->ConstructScript(ccg, isManaged);
+      script += lg->ConstructScript(ccg);
 
       stdPipesUTF8 = stdPipesUTF8 || cc.GetStdPipesUTF8();
     }

+ 1 - 0
Tests/CMakeLists.txt

@@ -2237,6 +2237,7 @@ if(BUILD_TESTING)
     if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio 9 "
         AND NOT CMAKE_GENERATOR_TOOLSET)
       ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx)
+      ADD_TEST_MACRO(VSManagedCustomCommand)
     endif()
 
     add_test(VSExternalInclude ${CMAKE_CTEST_COMMAND}

+ 15 - 0
Tests/VSManagedCustomCommand/CMakeLists.txt

@@ -0,0 +1,15 @@
+cmake_minimum_required(VERSION 3.20)
+project(VSManagedCustomCommand CXX)
+
+add_custom_command(OUTPUT middle.txt
+  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/example.txt ${CMAKE_CURRENT_BINARY_DIR}/middle.txt
+  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/example.txt
+  )
+
+add_custom_command(OUTPUT example.cxx
+  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/middle.txt ${CMAKE_CURRENT_BINARY_DIR}/example.cxx
+  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/middle.txt
+  )
+
+add_library(example SHARED example.cxx)
+set_property(TARGET example PROPERTY COMMON_LANGUAGE_RUNTIME "")

+ 4 - 0
Tests/VSManagedCustomCommand/example.txt

@@ -0,0 +1,4 @@
+__declspec(dllexport) int example()
+{
+  return 0;
+}