summaryrefslogtreecommitdiffstats
path: root/Source/cmAddCustomTargetCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmAddCustomTargetCommand.cxx')
-rw-r--r--Source/cmAddCustomTargetCommand.cxx17
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index a246d06..6339062 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -17,6 +17,7 @@
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
+#include "cmValue.h"
bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
@@ -54,6 +55,7 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
const char* comment = nullptr;
std::vector<std::string> sources;
std::string job_pool;
+ std::string JOB_SERVER_AWARE;
// Keep track of parser state.
enum tdoing
@@ -65,6 +67,7 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
doing_comment,
doing_source,
doing_job_pool,
+ doing_JOB_SERVER_AWARE,
doing_nothing
};
tdoing doing = doing_command;
@@ -102,6 +105,8 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
doing = doing_comment;
} else if (copy == "JOB_POOL") {
doing = doing_job_pool;
+ } else if (copy == "JOB_SERVER_AWARE") {
+ doing = doing_JOB_SERVER_AWARE;
} else if (copy == "COMMAND") {
doing = doing_command;
@@ -148,6 +153,9 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
case doing_job_pool:
job_pool = copy;
break;
+ case doing_JOB_SERVER_AWARE:
+ JOB_SERVER_AWARE = copy;
+ break;
default:
status.SetError("Wrong syntax. Unknown type of argument.");
return false;
@@ -212,6 +220,15 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
return false;
}
+ // If using a GNU Make generator and `JOB_SERVER_AWARE` is set then
+ // prefix all commands with '+'.
+ if (cmIsOn(JOB_SERVER_AWARE) &&
+ mf.GetGlobalGenerator()->IsGNUMakeJobServerAware()) {
+ for (auto& commandLine : commandLines) {
+ commandLine.insert(commandLine.begin(), "+");
+ }
+ }
+
// Add the utility target to the makefile.
auto cc = cm::make_unique<cmCustomCommand>();
cc->SetWorkingDirectory(working_directory.c_str());