mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 22:37:30 +08:00
VS: Revert "Add missing label in C# project-build events"
Revert commit b284a21fee
(VS: Add missing label in C# project-build
events, 2021-09-03, v3.22.0-rc1~156^2). The change broke cases using
multiple successful custom commands. Revert it pending further
investigation into the interaction of the generated script code with
`Microsoft.Common.CurrentVersion.targets`, and whether this is needed
for all managed projects or just C# projects.
Also add a test covering the case that was broken.
Fixes: #22964
Issue: #21440
This commit is contained in:
@@ -567,7 +567,7 @@ public:
|
|||||||
} else {
|
} else {
|
||||||
this->Stream << this->LG->EscapeForXML("\n");
|
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);
|
this->Stream << this->LG->EscapeForXML(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1780,7 +1780,7 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string comment = this->ConstructComment(ccg);
|
std::string comment = this->ConstructComment(ccg);
|
||||||
std::string script = this->ConstructScript(ccg, unmanaged);
|
std::string script = this->ConstructScript(ccg);
|
||||||
if (this->FortranProject) {
|
if (this->FortranProject) {
|
||||||
cmSystemTools::ReplaceString(script, "$(Configuration)", config);
|
cmSystemTools::ReplaceString(script, "$(Configuration)", config);
|
||||||
}
|
}
|
||||||
|
@@ -124,8 +124,7 @@ const char* cmLocalVisualStudioGenerator::GetReportErrorLabel() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string cmLocalVisualStudioGenerator::ConstructScript(
|
std::string cmLocalVisualStudioGenerator::ConstructScript(
|
||||||
cmCustomCommandGenerator const& ccg, IsManaged isManaged,
|
cmCustomCommandGenerator const& ccg, const std::string& newline_text)
|
||||||
const std::string& newline_text)
|
|
||||||
{
|
{
|
||||||
bool useLocal = this->CustomCommandUseLocal();
|
bool useLocal = this->CustomCommandUseLocal();
|
||||||
std::string workingDirectory = ccg.GetWorkingDirectory();
|
std::string workingDirectory = ccg.GetWorkingDirectory();
|
||||||
@@ -238,14 +237,6 @@ std::string cmLocalVisualStudioGenerator::ConstructScript(
|
|||||||
script += newline;
|
script += newline;
|
||||||
script += "if %errorlevel% neq 0 goto ";
|
script += "if %errorlevel% neq 0 goto ";
|
||||||
script += this->GetReportErrorLabel();
|
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;
|
return script;
|
||||||
|
@@ -31,13 +31,7 @@ public:
|
|||||||
virtual ~cmLocalVisualStudioGenerator();
|
virtual ~cmLocalVisualStudioGenerator();
|
||||||
|
|
||||||
/** Construct a script from the given list of command lines. */
|
/** Construct a script from the given list of command lines. */
|
||||||
enum IsManaged
|
|
||||||
{
|
|
||||||
unmanaged,
|
|
||||||
managed
|
|
||||||
};
|
|
||||||
std::string ConstructScript(cmCustomCommandGenerator const& ccg,
|
std::string ConstructScript(cmCustomCommandGenerator const& ccg,
|
||||||
IsManaged isManaged,
|
|
||||||
const std::string& newline = "\n");
|
const std::string& newline = "\n");
|
||||||
|
|
||||||
/** Label to which to jump in a batch file after a failed step in a
|
/** Label to which to jump in a batch file after a failed step in a
|
||||||
|
@@ -1488,10 +1488,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
|
|||||||
cmCustomCommandGenerator ccg(command, c, lg, true);
|
cmCustomCommandGenerator ccg(command, c, lg, true);
|
||||||
std::string comment = lg->ConstructComment(ccg);
|
std::string comment = lg->ConstructComment(ccg);
|
||||||
comment = cmVS10EscapeComment(comment);
|
comment = cmVS10EscapeComment(comment);
|
||||||
cmLocalVisualStudioGenerator::IsManaged isManaged = (this->Managed)
|
std::string script = lg->ConstructScript(ccg);
|
||||||
? cmLocalVisualStudioGenerator::managed
|
|
||||||
: cmLocalVisualStudioGenerator::unmanaged;
|
|
||||||
std::string script = lg->ConstructScript(ccg, isManaged);
|
|
||||||
bool symbolic = false;
|
bool symbolic = false;
|
||||||
// input files for custom command
|
// input files for custom command
|
||||||
std::stringstream additional_inputs;
|
std::stringstream additional_inputs;
|
||||||
@@ -4241,10 +4238,7 @@ void cmVisualStudio10TargetGenerator::WriteEvent(
|
|||||||
comment += lg->ConstructComment(ccg);
|
comment += lg->ConstructComment(ccg);
|
||||||
script += pre;
|
script += pre;
|
||||||
pre = "\n";
|
pre = "\n";
|
||||||
cmLocalVisualStudioGenerator::IsManaged isManaged = (this->Managed)
|
script += lg->ConstructScript(ccg);
|
||||||
? cmLocalVisualStudioGenerator::managed
|
|
||||||
: cmLocalVisualStudioGenerator::unmanaged;
|
|
||||||
script += lg->ConstructScript(ccg, isManaged);
|
|
||||||
|
|
||||||
stdPipesUTF8 = stdPipesUTF8 || cc.GetStdPipesUTF8();
|
stdPipesUTF8 = stdPipesUTF8 || cc.GetStdPipesUTF8();
|
||||||
}
|
}
|
||||||
|
@@ -2236,6 +2236,7 @@ if(BUILD_TESTING)
|
|||||||
if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio 9 "
|
if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio 9 "
|
||||||
AND NOT CMAKE_GENERATOR_TOOLSET)
|
AND NOT CMAKE_GENERATOR_TOOLSET)
|
||||||
ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx)
|
ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx)
|
||||||
|
ADD_TEST_MACRO(VSManagedCustomCommand)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_test(VSExternalInclude ${CMAKE_CTEST_COMMAND}
|
add_test(VSExternalInclude ${CMAKE_CTEST_COMMAND}
|
||||||
|
15
Tests/VSManagedCustomCommand/CMakeLists.txt
Normal file
15
Tests/VSManagedCustomCommand/CMakeLists.txt
Normal file
@@ -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
Tests/VSManagedCustomCommand/example.txt
Normal file
4
Tests/VSManagedCustomCommand/example.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
__declspec(dllexport) int example()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
Reference in New Issue
Block a user