summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-01-25 15:34:38 (GMT)
committerBrad King <brad.king@kitware.com>2023-01-25 15:59:44 (GMT)
commit8024c41685f898656c350a503a81acbafacdf452 (patch)
treec43cc2a752e3484c3dd05c7c0d0cdd1422001f5d
parent7a989a581c8da2fe9822096ee00b288c376b6117 (diff)
downloadCMake-8024c41685f898656c350a503a81acbafacdf452.zip
CMake-8024c41685f898656c350a503a81acbafacdf452.tar.gz
CMake-8024c41685f898656c350a503a81acbafacdf452.tar.bz2
VS: Do not concurrently build custom commands with generated MAIN_DEPENDENCY
Since commit 33c15ae2b9 (VS: Build custom commands concurrently when possible, 2023-01-19) several tests have failed intermittently with the VS generator. It seems that if the `BuildInParallel` setting is attached to a generated input: <CustomBuild Include="generated_input.txt"> <BuildInParallel Condition="...">true</BuildInParallel> <Command Condition="...">copy geneated_input.txt output.txt</Command> ... </CustomBuild> then MSBuild does not wait for the input to be generated before running the command. This occurs when using `add_custom_command`'s `MAIN_DEPENDENCY`, so avoid using `BuildInParallel` in that case. Issue: #18405
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx15
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h7
2 files changed, 16 insertions, 6 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 5065876..7b3f348 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1806,9 +1806,13 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
this->WriteCustomRuleCSharp(e0, c, name, script, additional_inputs.str(),
outputs.str(), comment, ccg);
} else {
- this->WriteCustomRuleCpp(*spe2, c, script, additional_inputs.str(),
- outputs.str(), comment, ccg, symbolic,
- command.GetUsesTerminal());
+ this->WriteCustomRuleCpp(
+ *spe2, c, script, additional_inputs.str(), outputs.str(), comment, ccg,
+ symbolic,
+ (command.GetUsesTerminal() ||
+ (command.HasMainDependency() && source->GetIsGenerated()))
+ ? BuildInParallel::No
+ : BuildInParallel::Yes);
}
}
}
@@ -1817,10 +1821,11 @@ void cmVisualStudio10TargetGenerator::WriteCustomRuleCpp(
Elem& e2, std::string const& config, std::string const& script,
std::string const& additional_inputs, std::string const& outputs,
std::string const& comment, cmCustomCommandGenerator const& ccg,
- bool symbolic, bool uses_terminal)
+ bool symbolic, BuildInParallel buildInParallel)
{
const std::string cond = this->CalcCondition(config);
- if (this->GlobalGenerator->IsBuildInParallelSupported() && !uses_terminal) {
+ if (buildInParallel == BuildInParallel::Yes &&
+ this->GlobalGenerator->IsBuildInParallelSupported()) {
e2.WritePlatformConfigTag("BuildInParallel", cond, "true");
}
e2.WritePlatformConfigTag("Message", cond, comment);
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 194fbaa..e00f692 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -152,13 +152,18 @@ private:
void OutputLinkIncremental(Elem& e1, std::string const& configName);
void WriteCustomRule(Elem& e0, cmSourceFile const* source,
cmCustomCommand const& command);
+ enum class BuildInParallel
+ {
+ No,
+ Yes,
+ };
void WriteCustomRuleCpp(Elem& e2, std::string const& config,
std::string const& script,
std::string const& additional_inputs,
std::string const& outputs,
std::string const& comment,
cmCustomCommandGenerator const& ccg, bool symbolic,
- bool uses_terminal);
+ BuildInParallel buildInParallel);
void WriteCustomRuleCSharp(Elem& e0, std::string const& config,
std::string const& commandName,
std::string const& script,