summaryrefslogtreecommitdiffstats
path: root/Source/cmAddCustomCommandCommand.cxx
diff options
context:
space:
mode:
authorChris Mahoney <chris.mahoney@kitware.com>2023-06-05 19:59:13 (GMT)
committerBrad King <brad.king@kitware.com>2023-07-19 14:45:33 (GMT)
commit95941fd99020bb2345869ed393abde1a44529837 (patch)
tree4e809b9c121ce0e5745c1030d6a7c62b1c09bf2e /Source/cmAddCustomCommandCommand.cxx
parentaf9489a4f2858db0bf666c29f99dd332426f5ca1 (diff)
downloadCMake-95941fd99020bb2345869ed393abde1a44529837.zip
CMake-95941fd99020bb2345869ed393abde1a44529837.tar.gz
CMake-95941fd99020bb2345869ed393abde1a44529837.tar.bz2
add_custom_{target,command}: Add argument JOB_SERVER_AWARE
Issue: #16273
Diffstat (limited to 'Source/cmAddCustomCommandCommand.cxx')
-rw-r--r--Source/cmAddCustomCommandCommand.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index b1398db..044b5df 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -19,6 +19,7 @@
#include "cmPolicies.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
+#include "cmValue.h"
bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
@@ -39,6 +40,7 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
std::string working;
std::string depfile;
std::string job_pool;
+ std::string job_server_aware;
std::string comment_buffer;
const char* comment = nullptr;
std::vector<std::string> depends;
@@ -78,6 +80,7 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
doing_working_directory,
doing_depfile,
doing_job_pool,
+ doing_job_server_aware,
doing_nothing
};
@@ -95,6 +98,7 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
MAKE_STATIC_KEYWORD(DEPFILE);
MAKE_STATIC_KEYWORD(IMPLICIT_DEPENDS);
MAKE_STATIC_KEYWORD(JOB_POOL);
+ MAKE_STATIC_KEYWORD(JOB_SERVER_AWARE);
MAKE_STATIC_KEYWORD(MAIN_DEPENDENCY);
MAKE_STATIC_KEYWORD(OUTPUT);
MAKE_STATIC_KEYWORD(OUTPUTS);
@@ -126,6 +130,7 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
keyPRE_BUILD,
keyPRE_LINK,
keySOURCE,
+ keyJOB_SERVER_AWARE,
keyTARGET,
keyUSES_TERMINAL,
keyVERBATIM,
@@ -190,6 +195,8 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
}
} else if (copy == keyJOB_POOL) {
doing = doing_job_pool;
+ } else if (copy == keyJOB_SERVER_AWARE) {
+ doing = doing_job_server_aware;
}
} else {
std::string filename;
@@ -226,6 +233,9 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
case doing_job_pool:
job_pool = copy;
break;
+ case doing_job_server_aware:
+ job_server_aware = copy;
+ break;
case doing_working_directory:
working = copy;
break;
@@ -324,6 +334,15 @@ bool cmAddCustomCommandCommand(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(), "+");
+ }
+ }
+
// Choose which mode of the command to use.
auto cc = cm::make_unique<cmCustomCommand>();
cc->SetByproducts(byproducts);