summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-11-27 13:51:42 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-11-27 13:52:06 (GMT)
commit08f66764b320efb6b023febb3e2e4787f2e6c976 (patch)
tree051a6bf968d35109bfd56e734337279496322130
parent0c1912e3e58bebe9eb7c6dcac7a478dc607dba66 (diff)
parentafd9a339a1d7cbdf9aafff4ee6c454382e923aa9 (diff)
downloadCMake-08f66764b320efb6b023febb3e2e4787f2e6c976.zip
CMake-08f66764b320efb6b023febb3e2e4787f2e6c976.tar.gz
CMake-08f66764b320efb6b023febb3e2e4787f2e6c976.tar.bz2
Merge topic 'server-target-isGeneratorProvided'
afd9a339 server: return whether or not a target is generator provided Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1475
-rw-r--r--Help/manual/cmake-server.7.rst2
-rw-r--r--Source/cmAddCustomTargetCommand.cxx6
-rw-r--r--Source/cmCPluginAPI.cxx4
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx6
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx4
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx12
-rw-r--r--Source/cmMakefile.cxx19
-rw-r--r--Source/cmMakefile.h13
-rw-r--r--Source/cmQtAutoGeneratorInitializer.cxx11
-rw-r--r--Source/cmServerDictionary.h1
-rw-r--r--Source/cmServerProtocol.cxx2
-rw-r--r--Source/cmTarget.cxx1
-rw-r--r--Source/cmTarget.h7
13 files changed, 55 insertions, 33 deletions
diff --git a/Help/manual/cmake-server.7.rst b/Help/manual/cmake-server.7.rst
index b373456..c2aef99 100644
--- a/Help/manual/cmake-server.7.rst
+++ b/Help/manual/cmake-server.7.rst
@@ -486,6 +486,8 @@ Each target object can have the following keys:
contains the current source directory.
"buildDirectory"
contains the current build directory.
+"isGeneratorProvided"
+ true if the target is auto-created by a generator, false otherwise
"hasInstallRule"
true if the target contains any install rules, false otherwise.
"installPaths"
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index f4b4f66..819c781 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -209,9 +209,9 @@ bool cmAddCustomTargetCommand::InitialPass(
// Add the utility target to the makefile.
bool escapeOldStyle = !verbatim;
cmTarget* target = this->Makefile->AddUtilityCommand(
- targetName, excludeFromAll, working_directory.c_str(), byproducts, depends,
- commandLines, escapeOldStyle, comment, uses_terminal,
- command_expand_lists);
+ targetName, cmMakefile::TargetOrigin::Project, excludeFromAll,
+ working_directory.c_str(), byproducts, depends, commandLines,
+ escapeOldStyle, comment, uses_terminal, command_expand_lists);
// Add additional user-specified source files to the target.
target->AddSources(sources);
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index e1e11af..18a1022 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -218,8 +218,8 @@ void CCONV cmAddUtilityCommand(void* arg, const char* utilityName,
}
// Pass the call to the makefile instance.
- mf->AddUtilityCommand(utilityName, (all ? false : true), nullptr, depends2,
- commandLines);
+ mf->AddUtilityCommand(utilityName, cmMakefile::TargetOrigin::Project,
+ (all ? false : true), nullptr, depends2, commandLines);
}
void CCONV cmAddCustomCommand(void* arg, const char* source,
const char* command, int numArgs,
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index dee874f..1743b18 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -225,9 +225,9 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
}
cmCustomCommandLines noCommandLines;
- cmTarget* tgt =
- mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false,
- no_working_directory, no_depends, noCommandLines);
+ cmTarget* tgt = mf->AddUtilityCommand(
+ CMAKE_CHECK_BUILD_SYSTEM_TARGET, cmMakefile::TargetOrigin::Generator,
+ false, no_working_directory, no_depends, noCommandLines);
cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg);
lg->AddGeneratorTarget(gt);
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 99600df..c89c2c4 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -69,8 +69,8 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
// Use no actual command lines so that the target itself is not
// considered always out of date.
cmTarget* allBuild = gen[0]->GetMakefile()->AddUtilityCommand(
- "ALL_BUILD", true, no_working_dir, no_depends, no_commands, false,
- "Build all projects");
+ "ALL_BUILD", cmMakefile::TargetOrigin::Generator, true, no_working_dir,
+ no_depends, no_commands, false, "Build all projects");
cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]);
gen[0]->AddGeneratorTarget(gt);
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 41fe5d2..c376c8d 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -440,9 +440,9 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
// Add ALL_BUILD
const char* no_working_directory = nullptr;
std::vector<std::string> no_depends;
- cmTarget* allbuild =
- mf->AddUtilityCommand("ALL_BUILD", true, no_depends, no_working_directory,
- "echo", "Build all projects");
+ cmTarget* allbuild = mf->AddUtilityCommand(
+ "ALL_BUILD", cmMakefile::TargetOrigin::Generator, true, no_depends,
+ no_working_directory, "echo", "Build all projects");
cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root);
root->AddGeneratorTarget(allBuildGt);
@@ -464,9 +464,9 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
std::string file =
this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile.c_str());
cmSystemTools::ReplaceString(file, "\\ ", " ");
- cmTarget* check =
- mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, true, no_depends,
- no_working_directory, "make", "-f", file.c_str());
+ cmTarget* check = mf->AddUtilityCommand(
+ CMAKE_CHECK_BUILD_SYSTEM_TARGET, cmMakefile::TargetOrigin::Generator,
+ true, no_depends, no_working_directory, "make", "-f", file.c_str());
cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root);
root->AddGeneratorTarget(checkGt);
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 9678a66..a9de3f5 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1007,7 +1007,7 @@ void cmMakefile::AddCustomCommandOldStyle(
}
cmTarget* cmMakefile::AddUtilityCommand(
- const std::string& utilityName, bool excludeFromAll,
+ const std::string& utilityName, TargetOrigin origin, bool excludeFromAll,
const std::vector<std::string>& depends, const char* workingDirectory,
const char* command, const char* arg1, const char* arg2, const char* arg3,
const char* arg4)
@@ -1031,25 +1031,25 @@ cmTarget* cmMakefile::AddUtilityCommand(
commandLines.push_back(commandLine);
// Call the real signature of this method.
- return this->AddUtilityCommand(utilityName, excludeFromAll, workingDirectory,
- depends, commandLines);
+ return this->AddUtilityCommand(utilityName, origin, excludeFromAll,
+ workingDirectory, depends, commandLines);
}
cmTarget* cmMakefile::AddUtilityCommand(
- const std::string& utilityName, bool excludeFromAll,
+ const std::string& utilityName, TargetOrigin origin, bool excludeFromAll,
const char* workingDirectory, const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, bool escapeOldStyle,
const char* comment, bool uses_terminal, bool command_expand_lists)
{
std::vector<std::string> no_byproducts;
- return this->AddUtilityCommand(utilityName, excludeFromAll, workingDirectory,
- no_byproducts, depends, commandLines,
- escapeOldStyle, comment, uses_terminal,
- command_expand_lists);
+ return this->AddUtilityCommand(utilityName, origin, excludeFromAll,
+ workingDirectory, no_byproducts, depends,
+ commandLines, escapeOldStyle, comment,
+ uses_terminal, command_expand_lists);
}
cmTarget* cmMakefile::AddUtilityCommand(
- const std::string& utilityName, bool excludeFromAll,
+ const std::string& utilityName, TargetOrigin origin, bool excludeFromAll,
const char* workingDirectory, const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, bool escapeOldStyle,
@@ -1057,6 +1057,7 @@ cmTarget* cmMakefile::AddUtilityCommand(
{
// Create a target instance for this utility.
cmTarget* target = this->AddNewTarget(cmStateEnums::UTILITY, utilityName);
+ target->SetIsGeneratorProvided(origin == TargetOrigin::Generator);
if (excludeFromAll) {
target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 5e87393..737cab9 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -183,12 +183,19 @@ public:
const std::vector<std::string>& srcs,
bool excludeFromAll = false);
+ /** Where the target originated from. */
+ enum class TargetOrigin
+ {
+ Project,
+ Generator
+ };
+
/**
* Add a utility to the build. A utiltity target is a command that
* is run every time the target is built.
*/
cmTarget* AddUtilityCommand(const std::string& utilityName,
- bool excludeFromAll,
+ TargetOrigin origin, bool excludeFromAll,
const std::vector<std::string>& depends,
const char* workingDirectory,
const char* command, const char* arg1 = nullptr,
@@ -196,13 +203,13 @@ public:
const char* arg3 = nullptr,
const char* arg4 = nullptr);
cmTarget* AddUtilityCommand(
- const std::string& utilityName, bool excludeFromAll,
+ const std::string& utilityName, TargetOrigin origin, bool excludeFromAll,
const char* workingDirectory, const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, bool escapeOldStyle = true,
const char* comment = nullptr, bool uses_terminal = false,
bool command_expand_lists = false);
cmTarget* AddUtilityCommand(
- const std::string& utilityName, bool excludeFromAll,
+ const std::string& utilityName, TargetOrigin origin, bool excludeFromAll,
const char* workingDirectory, const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, bool escapeOldStyle = true,
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index d9a5a9a..bd692a2 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -684,8 +684,9 @@ void cmQtAutoGeneratorInitializer::InitCustomTargets()
ccDepends.push_back(qrc.QrcFile);
cmTarget* autoRccTarget = makefile->AddUtilityCommand(
- ccName, true, this->DirWork.c_str(), ccOutput, ccDepends,
- commandLines, false, ccComment.c_str());
+ ccName, cmMakefile::TargetOrigin::Generator, true,
+ this->DirWork.c_str(), ccOutput, ccDepends, commandLines, false,
+ ccComment.c_str());
// Create autogen generator target
localGen->AddGeneratorTarget(
new cmGeneratorTarget(autoRccTarget, localGen));
@@ -852,9 +853,9 @@ void cmQtAutoGeneratorInitializer::InitCustomTargets()
// Create autogen target
cmTarget* autogenTarget = makefile->AddUtilityCommand(
- this->AutogenTargetName, true, this->DirWork.c_str(),
- /*byproducts=*/autogenProvides, autogenDepends, commandLines, false,
- autogenComment.c_str());
+ this->AutogenTargetName, cmMakefile::TargetOrigin::Generator, true,
+ this->DirWork.c_str(), /*byproducts=*/autogenProvides, autogenDepends,
+ commandLines, false, autogenComment.c_str());
// Create autogen generator target
localGen->AddGeneratorTarget(
new cmGeneratorTarget(autogenTarget, localGen));
diff --git a/Source/cmServerDictionary.h b/Source/cmServerDictionary.h
index 9008783..62dee11 100644
--- a/Source/cmServerDictionary.h
+++ b/Source/cmServerDictionary.h
@@ -95,6 +95,7 @@ static const std::string kCTEST_NAME = "ctestName";
static const std::string kCTEST_COMMAND = "ctestCommand";
static const std::string kCTEST_INFO = "ctestInfo";
static const std::string kMINIMUM_CMAKE_VERSION = "minimumCMakeVersion";
+static const std::string kIS_GENERATOR_PROVIDED_KEY = "isGeneratorProvided";
static const std::string kTARGET_CROSS_REFERENCES_KEY = "crossReferences";
static const std::string kLINE_NUMBER_KEY = "line";
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index 7a7080b..cfac513 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -889,6 +889,8 @@ static Json::Value DumpTarget(cmGeneratorTarget* target,
Json::Value result = Json::objectValue;
result[kNAME_KEY] = target->GetName();
+ result[kIS_GENERATOR_PROVIDED_KEY] =
+ target->Target->GetIsGeneratorProvided();
result[kTYPE_KEY] = typeName;
result[kSOURCE_DIRECTORY_KEY] = lg->GetCurrentSourceDirectory();
result[kBUILD_DIRECTORY_KEY] = lg->GetCurrentBinaryDirectory();
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index bf36074..693f35f 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -176,6 +176,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
Visibility vis, cmMakefile* mf)
{
assert(mf);
+ this->IsGeneratorProvided = false;
this->Name = name;
this->TargetTypeValue = type;
this->Makefile = mf;
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 940e26c..56f3e3a 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -180,6 +180,12 @@ public:
bool GetHaveInstallRule() const { return this->HaveInstallRule; }
void SetHaveInstallRule(bool h) { this->HaveInstallRule = h; }
+ /**
+ * Get/Set whether this target was auto-created by a generator.
+ */
+ bool GetIsGeneratorProvided() const { return this->IsGeneratorProvided; }
+ void SetIsGeneratorProvided(bool igp) { this->IsGeneratorProvided = igp; }
+
/** Add a utility on which this project depends. A utility is an executable
* name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE
* commands. It is not a full path nor does it have an extension.
@@ -284,6 +290,7 @@ private:
std::string const& value) const;
private:
+ bool IsGeneratorProvided;
cmPropertyMap Properties;
std::set<std::string> SystemIncludeDirectories;
std::set<std::string> LinkDirectoriesEmmitted;