summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-02-16 13:15:49 -0500
committerCMake Topic Stage <kwrobot@kitware.com>2017-02-16 13:15:49 -0500
commit160083b04ddde9904e90cbf8146193e28eb58124 (patch)
treeda598f810fd70ab921c1c9418191f703f6ce8595 /Source
parentfb3fd78d580d0ad0aa138fd8edd7f81f44a3f275 (diff)
parentf773933f2630a17ce6b3b2aa6f8d7d8b65eb336c (diff)
downloadcmake-160083b04ddde9904e90cbf8146193e28eb58124.tar.gz
Merge topic 'vs-refactor-toolset-parsing'
f773933f VS: Refactor generator toolset parsing d9e2b9a9 Tests: Split out RunCMake.GeneratorToolset Xcode checks
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx82
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h6
-rw-r--r--Source/cmGlobalVisualStudio12Generator.cxx16
-rw-r--r--Source/cmGlobalVisualStudio12Generator.h4
4 files changed, 82 insertions, 26 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index b64ae2617f..b1285acc82 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -182,24 +182,80 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
bool cmGlobalVisualStudio10Generator::ParseGeneratorToolset(
std::string const& ts, cmMakefile* mf)
{
- if (ts.find_first_of(",=") != ts.npos) {
- std::ostringstream e;
- /* clang-format off */
- e <<
- "Generator\n"
- " " << this->GetName() << "\n"
- "does not recognize the toolset\n"
- " " << ts << "\n"
- "that was specified.";
- /* clang-format on */
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
- return false;
+ std::vector<std::string> const fields = cmSystemTools::tokenize(ts, ",");
+ std::vector<std::string>::const_iterator fi = fields.begin();
+ if (fi == fields.end()) {
+ return true;
+ }
+
+ // The first field may be the VS platform toolset.
+ if (fi->find('=') == fi->npos) {
+ this->GeneratorToolset = *fi;
+ ++fi;
+ }
+
+ std::set<std::string> handled;
+
+ // The rest of the fields must be key=value pairs.
+ for (; fi != fields.end(); ++fi) {
+ std::string::size_type pos = fi->find('=');
+ if (pos == fi->npos) {
+ std::ostringstream e;
+ /* clang-format off */
+ e <<
+ "Generator\n"
+ " " << this->GetName() << "\n"
+ "given toolset specification\n"
+ " " << ts << "\n"
+ "that contains a field after the first ',' with no '='."
+ ;
+ /* clang-format on */
+ mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return false;
+ }
+ std::string const key = fi->substr(0, pos);
+ std::string const value = fi->substr(pos + 1);
+ if (!handled.insert(key).second) {
+ std::ostringstream e;
+ /* clang-format off */
+ e <<
+ "Generator\n"
+ " " << this->GetName() << "\n"
+ "given toolset specification\n"
+ " " << ts << "\n"
+ "that contains duplicate field key '" << key << "'."
+ ;
+ /* clang-format on */
+ mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return false;
+ }
+ if (!this->ProcessGeneratorToolsetField(key, value)) {
+ std::ostringstream e;
+ /* clang-format off */
+ e <<
+ "Generator\n"
+ " " << this->GetName() << "\n"
+ "given toolset specification\n"
+ " " << ts << "\n"
+ "that contains invalid field '" << *fi << "'."
+ ;
+ /* clang-format on */
+ mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return false;
+ }
}
- this->GeneratorToolset = ts;
return true;
}
+bool cmGlobalVisualStudio10Generator::ProcessGeneratorToolsetField(
+ std::string const& key, std::string const& value)
+{
+ static_cast<void>(key);
+ static_cast<void>(value);
+ return false;
+}
+
bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf)
{
if (this->SystemName == "Windows") {
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 3fc62ec130..c5e4bcdc6a 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -23,7 +23,6 @@ public:
virtual bool SetSystemName(std::string const& s, cmMakefile* mf);
virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf);
virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);
- virtual bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf);
virtual void GenerateBuildCommand(
std::vector<std::string>& makeCommand, const std::string& makeProgram,
@@ -106,6 +105,9 @@ protected:
virtual bool InitializeWindowsPhone(cmMakefile* mf);
virtual bool InitializeWindowsStore(cmMakefile* mf);
+ virtual bool ProcessGeneratorToolsetField(std::string const& key,
+ std::string const& value);
+
virtual std::string SelectWindowsCEToolset() const;
virtual bool SelectWindowsPhoneToolset(std::string& toolset) const;
virtual bool SelectWindowsStoreToolset(std::string& toolset) const;
@@ -156,6 +158,8 @@ private:
virtual std::string FindDevEnvCommand();
virtual std::string GetVSMakeProgram() { return this->GetMSBuildCommand(); }
+ bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf);
+
// We do not use the reload macros for VS >= 10.
virtual std::string GetUserMacrosDirectory() { return ""; }
};
diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx
index 2656dccf8f..de62ff0ac8 100644
--- a/Source/cmGlobalVisualStudio12Generator.cxx
+++ b/Source/cmGlobalVisualStudio12Generator.cxx
@@ -109,19 +109,15 @@ bool cmGlobalVisualStudio12Generator::MatchesGeneratorName(
return false;
}
-bool cmGlobalVisualStudio12Generator::ParseGeneratorToolset(
- std::string const& ts, cmMakefile* mf)
+bool cmGlobalVisualStudio12Generator::ProcessGeneratorToolsetField(
+ std::string const& key, std::string const& value)
{
- std::string::size_type ts_end = ts.size();
- if (cmHasLiteralSuffix(ts, ",host=x64")) {
+ if (key == "host" && value == "x64") {
this->GeneratorToolsetHostArchitecture = "x64";
- ts_end -= 9;
- } else if (ts == "host=x64") {
- this->GeneratorToolsetHostArchitecture = "x64";
- ts_end = 0;
+ return true;
}
- return this->cmGlobalVisualStudio11Generator::ParseGeneratorToolset(
- ts.substr(0, ts_end), mf);
+ return this->cmGlobalVisualStudio11Generator::ProcessGeneratorToolsetField(
+ key, value);
}
bool cmGlobalVisualStudio12Generator::InitializeWindowsPhone(cmMakefile* mf)
diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h
index 79efe521d4..3453628870 100644
--- a/Source/cmGlobalVisualStudio12Generator.h
+++ b/Source/cmGlobalVisualStudio12Generator.h
@@ -31,8 +31,8 @@ public:
// version number
virtual const char* GetToolsVersion() { return "12.0"; }
protected:
- bool ParseGeneratorToolset(std::string const& ts,
- cmMakefile* mf) CM_OVERRIDE;
+ bool ProcessGeneratorToolsetField(std::string const& key,
+ std::string const& value) CM_OVERRIDE;
virtual bool InitializeWindowsPhone(cmMakefile* mf);
virtual bool InitializeWindowsStore(cmMakefile* mf);