[Cmake-commits] CMake branch, master, updated. v3.13.3-1043-gcb7fbf1

Kitware Robot kwrobot at kitware.com
Tue Jan 22 09:33:06 EST 2019


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  cb7fbf1dbbcc88fc7701250db5c3ccdf0ab7396e (commit)
       via  acaf9801d004dc77d8abbb09b2ce3a88fd182322 (commit)
       via  17e12a9fa99c0a3008da2a611d91e810fad9f102 (commit)
       via  67bced8a26348e1cc05d8c04ed90633c642bf3a3 (commit)
       via  3132ea801c2466773309edda82387025f903fc12 (commit)
       via  2c50a725763eb2201f356852eab98dfdf9c27591 (commit)
       via  48ec0bc1401b99e5a2d07392fb98f96d5fec9e50 (commit)
       via  8bba458ea5d6b792e165560d79efd8d8356f4329 (commit)
       via  818df52c488a94628169811bddffe05f36c68b42 (commit)
       via  8144b00e32cf1e24daf41353cbcd1806311ceac9 (commit)
       via  b70c0aed5c616edce5cbc803c7de92580f835f90 (commit)
      from  05e4fa47738bf44e8ee6501b415df2899b10f6da (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cb7fbf1dbbcc88fc7701250db5c3ccdf0ab7396e
commit cb7fbf1dbbcc88fc7701250db5c3ccdf0ab7396e
Merge: acaf980 3132ea8
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jan 22 14:32:47 2019 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Jan 22 09:32:58 2019 -0500

    Merge topic 'stdout-string'
    
    3132ea801c cmSystemTools: Stdout(),Stderr() accept std::string argument
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2829


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=acaf9801d004dc77d8abbb09b2ce3a88fd182322
commit acaf9801d004dc77d8abbb09b2ce3a88fd182322
Merge: 17e12a9 2c50a72
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jan 22 14:32:00 2019 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Jan 22 09:32:06 2019 -0500

    Merge topic 'depends-string'
    
    2c50a72576 cmDepends: all members accept std::string arguments
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2827


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=17e12a9fa99c0a3008da2a611d91e810fad9f102
commit 17e12a9fa99c0a3008da2a611d91e810fad9f102
Merge: 05e4fa4 67bced8
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Jan 22 14:28:12 2019 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Jan 22 09:28:18 2019 -0500

    Merge topic 'cmake-gui-generator-platform'
    
    67bced8a26 cmake-gui: Improve label for default platform
    48ec0bc140 cmake-gui: Add field for generator platform selection
    8bba458ea5 Add global generator factory method to get default platform name
    818df52c48 Add global generator factory method to get list of known platforms
    8144b00e32 Split global generator factory list with and without platforms
    b70c0aed5c VS: Factor out helper function to compute host platform name
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2832


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=67bced8a26348e1cc05d8c04ed90633c642bf3a3
commit 67bced8a26348e1cc05d8c04ed90633c642bf3a3
Author:     Julien Jomier <julien.jomier at kitware.com>
AuthorDate: Mon Jan 21 13:18:26 2019 +0100
Commit:     Julien Jomier <julien.jomier at kitware.com>
CommitDate: Mon Jan 21 13:18:26 2019 +0100

    cmake-gui: Improve label for default platform
    
    Specify the default platform to be used when the platform field is empty

diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx
index 66707d6..ae5179c 100644
--- a/Source/QtDialog/FirstConfigure.cxx
+++ b/Source/QtDialog/FirstConfigure.cxx
@@ -75,8 +75,7 @@ QFrame* StartCompilerSetup::CreatePlatformWidgets()
   QVBoxLayout* l = new QVBoxLayout(frame);
   l->setContentsMargins(0, 0, 0, 0);
 
-  this->PlatformLabel =
-    new QLabel(tr("Specify the platform for this generator"));
+  this->PlatformLabel = new QLabel(tr("Optional platform for generator"));
   l->addWidget(this->PlatformLabel);
 
   this->PlatformOptions = new QComboBox(frame);
@@ -106,6 +105,10 @@ void StartCompilerSetup::setGenerators(
       this->GeneratorsSupportingPlatform.append(
         QString::fromLocal8Bit(it->name.c_str()));
 
+      this
+        ->GeneratorDefaultPlatform[QString::fromLocal8Bit(it->name.c_str())] =
+        QString::fromLocal8Bit(it->defaultPlatform.c_str());
+
       std::vector<std::string>::const_iterator platformIt =
         it->supportedPlatforms.cbegin();
       while (platformIt != it->supportedPlatforms.cend()) {
@@ -182,6 +185,13 @@ void StartCompilerSetup::onGeneratorChanged(QString const& name)
   // Display the generator platform for the generators supporting it
   if (GeneratorsSupportingPlatform.contains(name)) {
 
+    // Change the label title to include the default platform
+    std::string label = "Optional platform for generator";
+    label += "(if empty, generator uses: ";
+    label += this->GeneratorDefaultPlatform[name].toStdString();
+    label += ")";
+    this->PlatformLabel->setText(tr(label.c_str()));
+
     // Regenerate the list of supported platform
     this->PlatformOptions->clear();
     QStringList platform_list;
diff --git a/Source/QtDialog/FirstConfigure.h b/Source/QtDialog/FirstConfigure.h
index 133f422..d1db5bf 100644
--- a/Source/QtDialog/FirstConfigure.h
+++ b/Source/QtDialog/FirstConfigure.h
@@ -63,6 +63,7 @@ protected:
   QStringList GeneratorsSupportingToolset;
   QStringList GeneratorsSupportingPlatform;
   QMultiMap<QString, QString> GeneratorSupportedPlatforms;
+  QMap<QString, QString> GeneratorDefaultPlatform;
 
 private:
   QFrame* CreateToolsetWidgets();

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3132ea801c2466773309edda82387025f903fc12
commit 3132ea801c2466773309edda82387025f903fc12
Author:     Vitaly Stakhovsky <vvs31415 at gitlab.org>
AuthorDate: Sun Jan 20 00:03:35 2019 -0500
Commit:     Vitaly Stakhovsky <vvs31415 at gitlab.org>
CommitDate: Sun Jan 20 00:03:35 2019 -0500

    cmSystemTools: Stdout(),Stderr() accept std::string argument

diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 1c0d9f6..5ba3370 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -2781,13 +2781,13 @@ bool cmCTest::RunCommand(std::vector<std::string> const& args,
     if ((res == cmsysProcess_Pipe_STDOUT || res == cmsysProcess_Pipe_STDERR) &&
         this->ExtraVerbose) {
       processOutput.DecodeText(data, length, strdata);
-      cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+      cmSystemTools::Stdout(strdata);
     }
   }
   if (this->ExtraVerbose) {
     processOutput.DecodeText(std::string(), strdata);
     if (!strdata.empty()) {
-      cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+      cmSystemTools::Stdout(strdata);
     }
   }
 
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index 2acb015..e4eb5e5 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -87,7 +87,7 @@ void cmDepends::Clear(const char* file)
   if (this->Verbose) {
     std::ostringstream msg;
     msg << "Clearing dependencies in \"" << file << "\"." << std::endl;
-    cmSystemTools::Stdout(msg.str().c_str());
+    cmSystemTools::Stdout(msg.str());
   }
 
   // Write an empty dependency file.
@@ -170,7 +170,7 @@ bool cmDepends::CheckDependencies(
         std::ostringstream msg;
         msg << "Dependee \"" << dependee << "\" does not exist for depender \""
             << depender << "\"." << std::endl;
-        cmSystemTools::Stdout(msg.str().c_str());
+        cmSystemTools::Stdout(msg.str());
       }
     } else {
       if (dependerExists) {
@@ -187,7 +187,7 @@ bool cmDepends::CheckDependencies(
             std::ostringstream msg;
             msg << "Dependee \"" << dependee << "\" is newer than depender \""
                 << depender << "\"." << std::endl;
-            cmSystemTools::Stdout(msg.str().c_str());
+            cmSystemTools::Stdout(msg.str());
           }
         }
       } else {
@@ -206,7 +206,7 @@ bool cmDepends::CheckDependencies(
             msg << "Dependee \"" << dependee
                 << "\" is newer than depends file \""
                 << internalDependsFileName << "\"." << std::endl;
-            cmSystemTools::Stdout(msg.str().c_str());
+            cmSystemTools::Stdout(msg.str());
           }
         }
       }
diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx
index ea4cd40..49d9841 100644
--- a/Source/cmExecProgramCommand.cxx
+++ b/Source/cmExecProgramCommand.cxx
@@ -221,7 +221,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
     if (p == cmsysProcess_Pipe_STDOUT || p == cmsysProcess_Pipe_STDERR) {
       if (verbose) {
         processOutput.DecodeText(data, length, strdata);
-        cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+        cmSystemTools::Stdout(strdata);
       }
       output.append(data, length);
     }
@@ -230,7 +230,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
   if (verbose) {
     processOutput.DecodeText(std::string(), strdata);
     if (!strdata.empty()) {
-      cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+      cmSystemTools::Stdout(strdata);
     }
   }
 
@@ -270,7 +270,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
     }
     msg += "\n";
     if (verbose) {
-      cmSystemTools::Stdout(msg.c_str());
+      cmSystemTools::Stdout(msg);
     }
     output += msg;
 #else
diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx
index 679a648..08a8be7 100644
--- a/Source/cmExecuteProcessCommand.cxx
+++ b/Source/cmExecuteProcessCommand.cxx
@@ -249,14 +249,14 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
     if (p == cmsysProcess_Pipe_STDOUT && !output_quiet) {
       if (output_variable.empty()) {
         processOutput.DecodeText(data, length, strdata, 1);
-        cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+        cmSystemTools::Stdout(strdata);
       } else {
         cmExecuteProcessCommandAppend(tempOutput, data, length);
       }
     } else if (p == cmsysProcess_Pipe_STDERR && !error_quiet) {
       if (error_variable.empty()) {
         processOutput.DecodeText(data, length, strdata, 2);
-        cmSystemTools::Stderr(strdata.c_str(), strdata.size());
+        cmSystemTools::Stderr(strdata);
       } else {
         cmExecuteProcessCommandAppend(tempError, data, length);
       }
@@ -265,13 +265,13 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
   if (!output_quiet && output_variable.empty()) {
     processOutput.DecodeText(std::string(), strdata, 1);
     if (!strdata.empty()) {
-      cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+      cmSystemTools::Stdout(strdata);
     }
   }
   if (!error_quiet && error_variable.empty()) {
     processOutput.DecodeText(std::string(), strdata, 2);
     if (!strdata.empty()) {
-      cmSystemTools::Stderr(strdata.c_str(), strdata.size());
+      cmSystemTools::Stderr(strdata);
     }
   }
 
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 707a1b5..eca6bea 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1286,7 +1286,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
         std::ostringstream msg;
         msg << "Dependee \"" << tgtInfo << "\" is newer than depender \""
             << internalDependFile << "\"." << std::endl;
-        cmSystemTools::Stdout(msg.str().c_str());
+        cmSystemTools::Stdout(msg.str());
       }
       needRescanDependInfo = true;
     }
@@ -1307,7 +1307,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
         std::ostringstream msg;
         msg << "Dependee \"" << dirInfoFile << "\" is newer than depender \""
             << internalDependFile << "\"." << std::endl;
-        cmSystemTools::Stdout(msg.str().c_str());
+        cmSystemTools::Stdout(msg.str());
       }
       needRescanDirInfo = true;
     }
@@ -1489,7 +1489,7 @@ void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose)
         msg << "Deleting primary custom command output \"" << dependee
             << "\" because another output \"" << depender
             << "\" does not exist." << std::endl;
-        cmSystemTools::Stdout(msg.str().c_str());
+        cmSystemTools::Stdout(msg.str());
       }
       cmSystemTools::RemoveFile(dependee);
     }
diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx
index c5d5d7c..e2d7deb 100644
--- a/Source/cmQtAutoGenerator.cxx
+++ b/Source/cmQtAutoGenerator.cxx
@@ -54,7 +54,7 @@ void cmQtAutoGenerator::Logger::Info(GeneratorT genType,
   }
   {
     std::lock_guard<std::mutex> lock(Mutex_);
-    cmSystemTools::Stdout(msg.c_str(), msg.size());
+    cmSystemTools::Stdout(msg);
   }
 }
 
@@ -78,7 +78,7 @@ void cmQtAutoGenerator::Logger::Warning(GeneratorT genType,
   msg.push_back('\n');
   {
     std::lock_guard<std::mutex> lock(Mutex_);
-    cmSystemTools::Stdout(msg.c_str(), msg.size());
+    cmSystemTools::Stdout(msg);
   }
 }
 
@@ -107,7 +107,7 @@ void cmQtAutoGenerator::Logger::Error(GeneratorT genType,
   msg.push_back('\n');
   {
     std::lock_guard<std::mutex> lock(Mutex_);
-    cmSystemTools::Stderr(msg.c_str(), msg.size());
+    cmSystemTools::Stderr(msg);
   }
 }
 
@@ -149,7 +149,7 @@ void cmQtAutoGenerator::Logger::ErrorCommand(
   msg.push_back('\n');
   {
     std::lock_guard<std::mutex> lock(Mutex_);
-    cmSystemTools::Stderr(msg.c_str(), msg.size());
+    cmSystemTools::Stderr(msg);
   }
 }
 
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index be65853..cb97cba 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -302,33 +302,21 @@ void cmSystemTools::SetStderrCallback(OutputCallback f, void* clientData)
   s_StderrCallbackClientData = clientData;
 }
 
-void cmSystemTools::Stdout(const char* s)
-{
-  cmSystemTools::Stdout(s, strlen(s));
-}
-
-void cmSystemTools::Stderr(const char* s)
-{
-  cmSystemTools::Stderr(s, strlen(s));
-}
-
-void cmSystemTools::Stderr(const char* s, size_t length)
+void cmSystemTools::Stderr(const std::string& s)
 {
   if (s_StderrCallback) {
-    (*s_StderrCallback)(s, length, s_StderrCallbackClientData);
+    (*s_StderrCallback)(s.c_str(), s.length(), s_StderrCallbackClientData);
   } else {
-    std::cerr.write(s, length);
-    std::cerr.flush();
+    std::cerr << s << std::flush;
   }
 }
 
-void cmSystemTools::Stdout(const char* s, size_t length)
+void cmSystemTools::Stdout(const std::string& s)
 {
   if (s_StdoutCallback) {
-    (*s_StdoutCallback)(s, length, s_StdoutCallbackClientData);
+    (*s_StdoutCallback)(s.c_str(), s.length(), s_StdoutCallbackClientData);
   } else {
-    std::cout.write(s, length);
-    std::cout.flush();
+    std::cout << s << std::flush;
   }
 }
 
@@ -792,7 +780,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
       if (pipe == cmsysProcess_Pipe_STDOUT) {
         if (outputflag != OUTPUT_NONE) {
           processOutput.DecodeText(data, length, strdata, 1);
-          cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+          cmSystemTools::Stdout(strdata);
         }
         if (captureStdOut) {
           tempStdOut.insert(tempStdOut.end(), data, data + length);
@@ -800,7 +788,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
       } else if (pipe == cmsysProcess_Pipe_STDERR) {
         if (outputflag != OUTPUT_NONE) {
           processOutput.DecodeText(data, length, strdata, 2);
-          cmSystemTools::Stderr(strdata.c_str(), strdata.size());
+          cmSystemTools::Stderr(strdata);
         }
         if (captureStdErr) {
           tempStdErr.insert(tempStdErr.end(), data, data + length);
@@ -811,11 +799,11 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
     if (outputflag != OUTPUT_NONE) {
       processOutput.DecodeText(std::string(), strdata, 1);
       if (!strdata.empty()) {
-        cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+        cmSystemTools::Stdout(strdata);
       }
       processOutput.DecodeText(std::string(), strdata, 2);
       if (!strdata.empty()) {
-        cmSystemTools::Stderr(strdata.c_str(), strdata.size());
+        cmSystemTools::Stderr(strdata);
       }
     }
   }
@@ -1899,13 +1887,13 @@ bool extract_tar(const char* outFileName, bool verbose, bool extract)
     if (verbose) {
       if (extract) {
         cmSystemTools::Stdout("x ");
-        cmSystemTools::Stdout(cm_archive_entry_pathname(entry).c_str());
+        cmSystemTools::Stdout(cm_archive_entry_pathname(entry));
       } else {
         list_item_verbose(stdout, entry);
       }
       cmSystemTools::Stdout("\n");
     } else if (!extract) {
-      cmSystemTools::Stdout(cm_archive_entry_pathname(entry).c_str());
+      cmSystemTools::Stdout(cm_archive_entry_pathname(entry));
       cmSystemTools::Stdout("\n");
     }
     if (extract) {
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index c0999e7..365be36 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -79,13 +79,11 @@ public:
   typedef void (*OutputCallback)(const char*, size_t length, void*);
 
   ///! Send a string to stdout
-  static void Stdout(const char* s);
-  static void Stdout(const char* s, size_t length);
+  static void Stdout(const std::string& s);
   static void SetStdoutCallback(OutputCallback, void* clientData = nullptr);
 
   ///! Send a string to stderr
-  static void Stderr(const char* s);
-  static void Stderr(const char* s, size_t length);
+  static void Stderr(const std::string& s);
   static void SetStderrCallback(OutputCallback, void* clientData = nullptr);
 
   typedef bool (*InterruptCallback)(void*);
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 9fcfbde..c8e54aa 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -2006,7 +2006,7 @@ int cmake::CheckBuildSystem()
     if (verbose) {
       std::ostringstream msg;
       msg << "Re-run cmake no build system arguments\n";
-      cmSystemTools::Stdout(msg.str().c_str());
+      cmSystemTools::Stdout(msg.str());
     }
     return 1;
   }
@@ -2017,7 +2017,7 @@ int cmake::CheckBuildSystem()
       std::ostringstream msg;
       msg << "Re-run cmake missing file: " << this->CheckBuildSystemArgument
           << "\n";
-      cmSystemTools::Stdout(msg.str().c_str());
+      cmSystemTools::Stdout(msg.str());
     }
     return 1;
   }
@@ -2037,7 +2037,7 @@ int cmake::CheckBuildSystem()
       std::ostringstream msg;
       msg << "Re-run cmake error reading : " << this->CheckBuildSystemArgument
           << "\n";
-      cmSystemTools::Stdout(msg.str().c_str());
+      cmSystemTools::Stdout(msg.str());
     }
     // There was an error reading the file.  Just rerun.
     return 1;
@@ -2071,7 +2071,7 @@ int cmake::CheckBuildSystem()
       if (verbose) {
         std::ostringstream msg;
         msg << "Re-run cmake, missing byproduct: " << p << "\n";
-        cmSystemTools::Stdout(msg.str().c_str());
+        cmSystemTools::Stdout(msg.str());
       }
       return 1;
     }
@@ -2092,7 +2092,7 @@ int cmake::CheckBuildSystem()
       std::ostringstream msg;
       msg << "Re-run cmake no CMAKE_MAKEFILE_DEPENDS "
              "or CMAKE_MAKEFILE_OUTPUTS :\n";
-      cmSystemTools::Stdout(msg.str().c_str());
+      cmSystemTools::Stdout(msg.str());
     }
     return 1;
   }
@@ -2111,7 +2111,7 @@ int cmake::CheckBuildSystem()
       if (verbose) {
         std::ostringstream msg;
         msg << "Re-run cmake: build system dependency is missing\n";
-        cmSystemTools::Stdout(msg.str().c_str());
+        cmSystemTools::Stdout(msg.str());
       }
       return 1;
     }
@@ -2131,7 +2131,7 @@ int cmake::CheckBuildSystem()
       if (verbose) {
         std::ostringstream msg;
         msg << "Re-run cmake: build system output is missing\n";
-        cmSystemTools::Stdout(msg.str().c_str());
+        cmSystemTools::Stdout(msg.str());
       }
       return 1;
     }
@@ -2147,7 +2147,7 @@ int cmake::CheckBuildSystem()
         std::ostringstream msg;
         msg << "Re-run cmake file: " << out_oldest
             << " older than: " << dep_newest << "\n";
-        cmSystemTools::Stdout(msg.str().c_str());
+        cmSystemTools::Stdout(msg.str());
       }
       return 1;
     }

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2c50a725763eb2201f356852eab98dfdf9c27591
commit 2c50a725763eb2201f356852eab98dfdf9c27591
Author:     Vitaly Stakhovsky <vvs31415 at gitlab.org>
AuthorDate: Fri Jan 18 20:20:00 2019 -0500
Commit:     Vitaly Stakhovsky <vvs31415 at gitlab.org>
CommitDate: Fri Jan 18 20:30:13 2019 -0500

    cmDepends: all members accept std::string arguments
    
    Most `const char*` arguments converted to `const std::string&`
    in `cmDepends` and derived classes.
    In addition performed minor code cleanup.

diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index 2acb015..fae3d9b 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -13,7 +13,7 @@
 #include <string.h>
 #include <utility>
 
-cmDepends::cmDepends(cmLocalGenerator* lg, const char* targetDir)
+cmDepends::cmDepends(cmLocalGenerator* lg, const std::string& targetDir)
   : LocalGenerator(lg)
   , TargetDirectory(targetDir)
   , Dependee(new char[MaxPath])
@@ -65,12 +65,13 @@ bool cmDepends::Finalize(std::ostream& /*unused*/, std::ostream& /*unused*/)
   return true;
 }
 
-bool cmDepends::Check(const char* makeFile, const char* internalFile,
+bool cmDepends::Check(const std::string& makeFile,
+                      const std::string& internalFile,
                       std::map<std::string, DependencyVector>& validDeps)
 {
   // Check whether dependencies must be regenerated.
   bool okay = true;
-  cmsys::ifstream fin(internalFile);
+  cmsys::ifstream fin(internalFile.c_str());
   if (!(fin && this->CheckDependencies(fin, internalFile, validDeps))) {
     // Clear all dependencies so they will be regenerated.
     this->Clear(makeFile);
@@ -81,7 +82,7 @@ bool cmDepends::Check(const char* makeFile, const char* internalFile,
   return okay;
 }
 
-void cmDepends::Clear(const char* file)
+void cmDepends::Clear(const std::string& file)
 {
   // Print verbose output.
   if (this->Verbose) {
@@ -107,7 +108,7 @@ bool cmDepends::WriteDependencies(const std::set<std::string>& /*unused*/,
 }
 
 bool cmDepends::CheckDependencies(
-  std::istream& internalDepends, const char* internalDependsFileName,
+  std::istream& internalDepends, const std::string& internalDependsFileName,
   std::map<std::string, DependencyVector>& validDeps)
 {
   // Parse dependencies from the stream.  If any dependee is missing
@@ -194,8 +195,8 @@ bool cmDepends::CheckDependencies(
         // The dependee exists, but the depender doesn't. Regenerate if the
         // internalDepends file is older than the dependee.
         int result = 0;
-        if ((!this->FileComparison->FileTimeCompare(internalDependsFileName,
-                                                    dependee, &result) ||
+        if ((!this->FileComparison->FileTimeCompare(
+               internalDependsFileName.c_str(), dependee, &result) ||
              result < 0)) {
           // The depends-file is older than the dependee.
           regenerate = true;
diff --git a/Source/cmDepends.h b/Source/cmDepends.h
index 705d215..b0b5bb5 100644
--- a/Source/cmDepends.h
+++ b/Source/cmDepends.h
@@ -29,7 +29,7 @@ class cmDepends
 public:
   /** Instances need to know the build directory name and the relative
       path from the build directory to the target file.  */
-  cmDepends(cmLocalGenerator* lg = nullptr, const char* targetDir = "");
+  cmDepends(cmLocalGenerator* lg = nullptr, const std::string& targetDir = "");
 
   /** Set the local generator for the directory in which we are
       scanning dependencies.  This is not a full local generator; it
@@ -41,7 +41,10 @@ public:
   void SetLanguage(const std::string& lang) { this->Language = lang; }
 
   /** Set the target build directory.  */
-  void SetTargetDirectory(const char* dir) { this->TargetDirectory = dir; }
+  void SetTargetDirectory(const std::string& dir)
+  {
+    this->TargetDirectory = dir;
+  }
 
   /** should this be verbose in its output */
   void SetVerbose(bool verb) { this->Verbose = verb; }
@@ -61,11 +64,11 @@ public:
       they must be generated Clear has already been called to wipe out
       the old dependencies.
       Dependencies which are still valid will be stored in validDeps. */
-  bool Check(const char* makeFile, const char* internalFile,
+  bool Check(const std::string& makeFile, const std::string& internalFile,
              std::map<std::string, DependencyVector>& validDeps);
 
   /** Clear dependencies for the target file so they will be regenerated.  */
-  void Clear(const char* file);
+  void Clear(const std::string& file);
 
   /** Set the file comparison object */
   void SetFileComparison(cmFileTimeComparison* fc)
@@ -85,7 +88,7 @@ protected:
   // Return false if dependencies must be regenerated and true
   // otherwise.
   virtual bool CheckDependencies(
-    std::istream& internalDepends, const char* internalDependsFileName,
+    std::istream& internalDepends, const std::string& internalDependsFileName,
     std::map<std::string, DependencyVector>& validDeps);
 
   // Finalize the dependency information for the target.
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index 072d116..f6ac4f2 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -24,7 +24,7 @@ cmDependsC::cmDependsC()
 }
 
 cmDependsC::cmDependsC(
-  cmLocalGenerator* lg, const char* targetDir, const std::string& lang,
+  cmLocalGenerator* lg, const std::string& targetDir, const std::string& lang,
   const std::map<std::string, DependencyVector>* validDeps)
   : cmDepends(lg, targetDir)
   , ValidDeps(validDeps)
@@ -53,8 +53,8 @@ cmDependsC::cmDependsC(
   }
 
   this->IncludeRegexLine.compile(INCLUDE_REGEX_LINE);
-  this->IncludeRegexScan.compile(scanRegex.c_str());
-  this->IncludeRegexComplain.compile(complainRegex.c_str());
+  this->IncludeRegexScan.compile(scanRegex);
+  this->IncludeRegexComplain.compile(complainRegex);
   this->IncludeRegexLineString = INCLUDE_REGEX_LINE_MARKER INCLUDE_REGEX_LINE;
   this->IncludeRegexScanString = INCLUDE_REGEX_SCAN_MARKER;
   this->IncludeRegexScanString += scanRegex;
@@ -212,7 +212,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
               // Scan this file for new dependencies.  Pass the directory
               // containing the file to handle double-quote includes.
               std::string dir = cmSystemTools::GetFilenamePath(fullName);
-              this->Scan(fin, dir.c_str(), fullName);
+              this->Scan(fin, dir, fullName);
             } else {
               // Skip file with encoding we do not implement.
             }
@@ -342,7 +342,7 @@ void cmDependsC::WriteCacheFile() const
   }
 }
 
-void cmDependsC::Scan(std::istream& is, const char* directory,
+void cmDependsC::Scan(std::istream& is, const std::string& directory,
                       const std::string& fullName)
 {
   cmIncludeLines* newCacheEntry = new cmIncludeLines;
@@ -418,7 +418,7 @@ void cmDependsC::SetupTransforms()
       sep = "|";
     }
     xform += ")[ \t]*\\(([^),]*)\\)";
-    this->IncludeRegexTransform.compile(xform.c_str());
+    this->IncludeRegexTransform.compile(xform);
 
     // Build a string that encodes all transformation rules and will
     // change when rules are changed.
@@ -460,11 +460,11 @@ void cmDependsC::TransformLine(std::string& line)
   // Construct the transformed line.
   std::string newline = this->IncludeRegexTransform.match(1);
   std::string arg = this->IncludeRegexTransform.match(4);
-  for (const char* c = tri->second.c_str(); *c; ++c) {
-    if (*c == '%') {
+  for (char c : tri->second) {
+    if (c == '%') {
       newline += arg;
     } else {
-      newline += *c;
+      newline += c;
     }
   }
 
diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h
index f833888..af2b06e 100644
--- a/Source/cmDependsC.h
+++ b/Source/cmDependsC.h
@@ -28,7 +28,7 @@ public:
   /** Checking instances need to know the build directory name and the
       relative path from the build directory to the target file.  */
   cmDependsC();
-  cmDependsC(cmLocalGenerator* lg, const char* targetDir,
+  cmDependsC(cmLocalGenerator* lg, const std::string& targetDir,
              const std::string& lang,
              const std::map<std::string, DependencyVector>* validDeps);
 
@@ -42,7 +42,7 @@ protected:
                          std::ostream& internalDepends) override;
 
   // Method to scan a single file.
-  void Scan(std::istream& is, const char* directory,
+  void Scan(std::istream& is, const std::string& directory,
             const std::string& fullName);
 
   // Regular expression to identify C preprocessor include directives.
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index e51f81e..6c5f647 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -7,7 +7,6 @@
 #include <iostream>
 #include <map>
 #include <stdlib.h>
-#include <string.h>
 #include <utility>
 
 #include "cmAlgorithms.h"
@@ -54,7 +53,8 @@ public:
   typedef std::map<std::string, cmFortranSourceInfo> ObjectInfoMap;
   ObjectInfoMap ObjectInfo;
 
-  cmFortranSourceInfo& CreateObjectInfo(const char* obj, const char* src)
+  cmFortranSourceInfo& CreateObjectInfo(const std::string& obj,
+                                        const std::string& src)
   {
     std::map<std::string, cmFortranSourceInfo>::iterator i =
       this->ObjectInfo.find(obj);
@@ -121,8 +121,7 @@ bool cmDependsFortran::WriteDependencies(const std::set<std::string>& sources,
   bool okay = true;
   for (std::string const& src : sources) {
     // Get the information object for this source.
-    cmFortranSourceInfo& info =
-      this->Internal->CreateObjectInfo(obj.c_str(), src.c_str());
+    cmFortranSourceInfo& info = this->Internal->CreateObjectInfo(obj, src);
 
     // Create the parser object. The constructor takes info by reference,
     // so we may look into the resulting objects later.
@@ -153,7 +152,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
   this->LocateModules();
 
   // Get the directory in which stamp files will be stored.
-  const char* stamp_dir = this->TargetDirectory.c_str();
+  const std::string& stamp_dir = this->TargetDirectory;
 
   // Get the directory in which module files will be created.
   cmMakefile* mf = this->LocalGenerator->GetMakefile();
@@ -167,9 +166,8 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
   typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap;
   ObjectInfoMap const& objInfo = this->Internal->ObjectInfo;
   for (auto const& i : objInfo) {
-    if (!this->WriteDependenciesReal(i.first.c_str(), i.second, mod_dir,
-                                     stamp_dir, makeDepends,
-                                     internalDepends)) {
+    if (!this->WriteDependenciesReal(i.first, i.second, mod_dir, stamp_dir,
+                                     makeDepends, internalDepends)) {
       return false;
     }
   }
@@ -256,22 +254,22 @@ void cmDependsFortran::LocateModules()
     std::string fname = targetDir + "/fortran.internal";
     cmsys::ifstream fin(fname.c_str());
     if (fin) {
-      this->MatchRemoteModules(fin, targetDir.c_str());
+      this->MatchRemoteModules(fin, targetDir);
     }
   }
 }
 
 void cmDependsFortran::MatchLocalModules()
 {
-  const char* stampDir = this->TargetDirectory.c_str();
+  std::string const& stampDir = this->TargetDirectory;
   std::set<std::string> const& provides = this->Internal->TargetProvides;
   for (std::string const& i : provides) {
-    this->ConsiderModule(i.c_str(), stampDir);
+    this->ConsiderModule(i, stampDir);
   }
 }
 
 void cmDependsFortran::MatchRemoteModules(std::istream& fin,
-                                          const char* stampDir)
+                                          const std::string& stampDir)
 {
   std::string line;
   bool doing_provides = false;
@@ -300,7 +298,8 @@ void cmDependsFortran::MatchRemoteModules(std::istream& fin,
   }
 }
 
-void cmDependsFortran::ConsiderModule(const char* name, const char* stampDir)
+void cmDependsFortran::ConsiderModule(const std::string& name,
+                                      const std::string& stampDir)
 {
   // Locate each required module.
   typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
@@ -317,17 +316,17 @@ void cmDependsFortran::ConsiderModule(const char* name, const char* stampDir)
   }
 }
 
-bool cmDependsFortran::WriteDependenciesReal(const char* obj,
+bool cmDependsFortran::WriteDependenciesReal(std::string const& obj,
                                              cmFortranSourceInfo const& info,
                                              std::string const& mod_dir,
-                                             const char* stamp_dir,
+                                             std::string const& stamp_dir,
                                              std::ostream& makeDepends,
                                              std::ostream& internalDepends)
 {
   typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
 
   // Get the source file for this object.
-  const char* src = info.Source.c_str();
+  std::string const& src = info.Source;
 
   // Write the include dependencies to the output stream.
   std::string binDir = this->LocalGenerator->GetBinaryDirectory();
@@ -502,8 +501,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
   cmFortranModuleAppendUpperLower(cmSystemTools::GetFilenameName(mod),
                                   mod_upper, mod_lower);
   if (cmSystemTools::FileExists(mod_upper, true)) {
-    if (cmDependsFortran::ModulesDiffer(mod_upper.c_str(), stamp.c_str(),
-                                        compilerId.c_str())) {
+    if (cmDependsFortran::ModulesDiffer(mod_upper, stamp, compilerId)) {
       if (!cmSystemTools::CopyFileAlways(mod_upper, stamp)) {
         std::cerr << "Error copying Fortran module from \"" << mod_upper
                   << "\" to \"" << stamp << "\".\n";
@@ -513,8 +511,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
     return true;
   }
   if (cmSystemTools::FileExists(mod_lower, true)) {
-    if (cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str(),
-                                        compilerId.c_str())) {
+    if (cmDependsFortran::ModulesDiffer(mod_lower, stamp, compilerId)) {
       if (!cmSystemTools::CopyFileAlways(mod_lower, stamp)) {
         std::cerr << "Error copying Fortran module from \"" << mod_lower
                   << "\" to \"" << stamp << "\".\n";
@@ -581,9 +578,9 @@ static bool cmFortranStreamsDiffer(std::istream& ifs1, std::istream& ifs2)
   return true;
 }
 
-bool cmDependsFortran::ModulesDiffer(const char* modFile,
-                                     const char* stampFile,
-                                     const char* compilerId)
+bool cmDependsFortran::ModulesDiffer(const std::string& modFile,
+                                     const std::string& stampFile,
+                                     const std::string& compilerId)
 {
   /*
   gnu >= 4.9:
@@ -617,16 +614,17 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
    * source is compiled twice
    *   -SunPro
    */
-  if (strcmp(compilerId, "SunPro") == 0) {
+  if (compilerId == "SunPro") {
     return cmSystemTools::FilesDiffer(modFile, stampFile);
   }
 
 #if defined(_WIN32) || defined(__CYGWIN__)
-  cmsys::ifstream finModFile(modFile, std::ios::in | std::ios::binary);
-  cmsys::ifstream finStampFile(stampFile, std::ios::in | std::ios::binary);
+  cmsys::ifstream finModFile(modFile.c_str(), std::ios::in | std::ios::binary);
+  cmsys::ifstream finStampFile(stampFile.c_str(),
+                               std::ios::in | std::ios::binary);
 #else
-  cmsys::ifstream finModFile(modFile);
-  cmsys::ifstream finStampFile(stampFile);
+  cmsys::ifstream finModFile(modFile.c_str());
+  cmsys::ifstream finStampFile(stampFile.c_str());
 #endif
   if (!finModFile || !finStampFile) {
     // At least one of the files does not exist.  The modules differ.
@@ -641,7 +639,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
    * Eat the stream content until all recompile only related changes
    * are left behind.
    */
-  if (strcmp(compilerId, "GNU") == 0) {
+  if (compilerId == "GNU") {
     // GNU Fortran 4.9 and later compress .mod files with gzip
     // but also do not include a date so we can fall through to
     // compare them without skipping any prefix.
@@ -664,7 +662,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
         return true;
       }
     }
-  } else if (strcmp(compilerId, "Intel") == 0) {
+  } else if (compilerId == "Intel") {
     const char seq[2] = { '\n', '\0' };
     const int seqlen = 2;
 
diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h
index 5d96dd4..f5f5be2 100644
--- a/Source/cmDependsFortran.h
+++ b/Source/cmDependsFortran.h
@@ -44,8 +44,9 @@ public:
 
   /** Determine if a mod file and the corresponding mod.stamp file
       are representing  different module information. */
-  static bool ModulesDiffer(const char* modFile, const char* stampFile,
-                            const char* compilerId);
+  static bool ModulesDiffer(const std::string& modFile,
+                            const std::string& stampFile,
+                            const std::string& compilerId);
 
 protected:
   // Finalize the dependency information for the target.
@@ -55,8 +56,8 @@ protected:
   // Find all the modules required by the target.
   void LocateModules();
   void MatchLocalModules();
-  void MatchRemoteModules(std::istream& fin, const char* stampDir);
-  void ConsiderModule(const char* name, const char* stampDir);
+  void MatchRemoteModules(std::istream& fin, const std::string& stampDir);
+  void ConsiderModule(const std::string& name, const std::string& stampDir);
   bool FindModule(std::string const& name, std::string& module);
 
   // Implement writing/checking methods required by superclass.
@@ -65,8 +66,10 @@ protected:
                          std::ostream& internalDepends) override;
 
   // Actually write the dependencies to the streams.
-  bool WriteDependenciesReal(const char* obj, cmFortranSourceInfo const& info,
-                             std::string const& mod_dir, const char* stamp_dir,
+  bool WriteDependenciesReal(std::string const& obj,
+                             cmFortranSourceInfo const& info,
+                             std::string const& mod_dir,
+                             std::string const& stamp_dir,
                              std::ostream& makeDepends,
                              std::ostream& internalDepends);
 
diff --git a/Source/cmDependsJava.cxx b/Source/cmDependsJava.cxx
index 29938ba..b44b3a2 100644
--- a/Source/cmDependsJava.cxx
+++ b/Source/cmDependsJava.cxx
@@ -27,7 +27,8 @@ bool cmDependsJava::WriteDependencies(const std::set<std::string>& sources,
 }
 
 bool cmDependsJava::CheckDependencies(
-  std::istream& /*internalDepends*/, const char* /*internalDependsFileName*/,
+  std::istream& /*internalDepends*/,
+  const std::string& /*internalDependsFileName*/,
   std::map<std::string, DependencyVector>& /*validDeps*/)
 {
   return true;
diff --git a/Source/cmDependsJava.h b/Source/cmDependsJava.h
index d070840..1928c51 100644
--- a/Source/cmDependsJava.h
+++ b/Source/cmDependsJava.h
@@ -33,7 +33,7 @@ protected:
                          const std::string& file, std::ostream& makeDepends,
                          std::ostream& internalDepends) override;
   bool CheckDependencies(
-    std::istream& internalDepends, const char* internalDependsFileName,
+    std::istream& internalDepends, const std::string& internalDependsFileName,
     std::map<std::string, DependencyVector>& validDeps) override;
 };
 
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 707a1b5..b31855d 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1333,8 +1333,8 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
     // dependency vector. This means that in the normal case, when only
     // few or one file have been edited, then also only this one file is
     // actually scanned again, instead of all files for this target.
-    needRescanDependencies = !checker.Check(
-      dependFile.c_str(), internalDependFile.c_str(), validDependencies);
+    needRescanDependencies =
+      !checker.Check(dependFile, internalDependFile, validDependencies);
   }
 
   if (needRescanDependInfo || needRescanDirInfo || needRescanDependencies) {
@@ -1347,7 +1347,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
                                        cmsysTerminal_Color_ForegroundBold,
                                      message.c_str(), true, color);
 
-    return this->ScanDependencies(dir.c_str(), validDependencies);
+    return this->ScanDependencies(dir, validDependencies);
   }
 
   // The dependencies are already up-to-date.
@@ -1355,7 +1355,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
 }
 
 bool cmLocalUnixMakefileGenerator3::ScanDependencies(
-  const char* targetDir,
+  const std::string& targetDir,
   std::map<std::string, cmDepends::DependencyVector>& validDeps)
 {
   // Read the directory information file.
@@ -1393,12 +1393,9 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
     cmSystemTools::Error("Directory Information file not found");
   }
 
-  // create the file stream for the depends file
-  std::string dir = targetDir;
-
   // Open the make depends file.  This should be copy-if-different
   // because the make tool may try to reload it needlessly otherwise.
-  std::string ruleFileNameFull = dir;
+  std::string ruleFileNameFull = targetDir;
   ruleFileNameFull += "/depend.make";
   cmGeneratedFileStream ruleFileStream(
     ruleFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
@@ -1410,7 +1407,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
   // Open the cmake dependency tracking file.  This should not be
   // copy-if-different because dependencies are re-scanned when it is
   // older than the DependInfo.cmake.
-  std::string internalRuleFileNameFull = dir;
+  std::string internalRuleFileNameFull = targetDir;
   internalRuleFileNameFull += "/depend.internal";
   cmGeneratedFileStream internalRuleFileStream(
     internalRuleFileNameFull, false,
@@ -1451,7 +1448,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
       scanner->SetFileComparison(
         this->GlobalGenerator->GetCMakeInstance()->GetFileComparison());
       scanner->SetLanguage(lang);
-      scanner->SetTargetDirectory(dir.c_str());
+      scanner->SetTargetDirectory(targetDir);
       scanner->Write(ruleFileStream, internalRuleFileStream);
 
       // free the scanner for this language
@@ -1720,7 +1717,7 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf,
 
     // Clear the implicit dependency makefile.
     std::string dependFile = dir + "/depend.make";
-    clearer.Clear(dependFile.c_str());
+    clearer.Clear(dependFile);
 
     // Remove the internal dependency check file to force
     // regeneration.
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index ee6b37b..c0d0e13 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -245,7 +245,7 @@ protected:
 
   // Helper methods for dependency updates.
   bool ScanDependencies(
-    const char* targetDir,
+    const std::string& targetDir,
     std::map<std::string, cmDepends::DependencyVector>& validDeps);
   void CheckMultipleOutputs(bool verbose);
 

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=48ec0bc1401b99e5a2d07392fb98f96d5fec9e50
commit 48ec0bc1401b99e5a2d07392fb98f96d5fec9e50
Author:     Julien Jomier <julien.jomier at kitware.com>
AuthorDate: Fri Jan 4 12:41:01 2019 +0100
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Jan 18 12:41:35 2019 -0500

    cmake-gui: Add field for generator platform selection
    
    Extend the "first configure" dialog with a field for the user to select
    a value for `CMAKE_GENERATOR_PLATFORM`.
    
    Fixes: #17343

diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 444a980..72cce9f 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -751,6 +751,7 @@ bool CMakeSetupDialog::setupFirstConfigure()
   if (dialog.exec() == QDialog::Accepted) {
     dialog.saveToSettings();
     this->CMakeThread->cmakeInstance()->setGenerator(dialog.getGenerator());
+    this->CMakeThread->cmakeInstance()->setPlatform(dialog.getPlatform());
     this->CMakeThread->cmakeInstance()->setToolset(dialog.getToolset());
 
     QCMakeCacheModel* m = this->CacheValues->cacheModel();
diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx
index 88ce7cb..66707d6 100644
--- a/Source/QtDialog/FirstConfigure.cxx
+++ b/Source/QtDialog/FirstConfigure.cxx
@@ -16,8 +16,12 @@ StartCompilerSetup::StartCompilerSetup(QWidget* p)
   this->GeneratorOptions = new QComboBox(this);
   l->addWidget(this->GeneratorOptions);
 
+  // Add the generator platform
+  this->PlatformFrame = CreatePlatformWidgets();
+  l->addWidget(PlatformFrame);
+
   // Add the ability to specify toolset (-T parameter)
-  ToolsetFrame = CreateToolsetWidgets();
+  this->ToolsetFrame = CreateToolsetWidgets();
   l->addWidget(ToolsetFrame);
 
   l->addSpacing(6);
@@ -45,7 +49,7 @@ StartCompilerSetup::StartCompilerSetup(QWidget* p)
                    SLOT(onSelectionChanged(bool)));
   QObject::connect(this->CompilerSetupOptions[3], SIGNAL(toggled(bool)), this,
                    SLOT(onSelectionChanged(bool)));
-  QObject::connect(GeneratorOptions,
+  QObject::connect(this->GeneratorOptions,
                    SIGNAL(currentIndexChanged(QString const&)), this,
                    SLOT(onGeneratorChanged(QString const&)));
 }
@@ -65,6 +69,24 @@ QFrame* StartCompilerSetup::CreateToolsetWidgets()
   return frame;
 }
 
+QFrame* StartCompilerSetup::CreatePlatformWidgets()
+{
+  QFrame* frame = new QFrame(this);
+  QVBoxLayout* l = new QVBoxLayout(frame);
+  l->setContentsMargins(0, 0, 0, 0);
+
+  this->PlatformLabel =
+    new QLabel(tr("Specify the platform for this generator"));
+  l->addWidget(this->PlatformLabel);
+
+  this->PlatformOptions = new QComboBox(frame);
+  this->PlatformOptions->setEditable(true);
+
+  l->addWidget(this->PlatformOptions);
+
+  return frame;
+}
+
 StartCompilerSetup::~StartCompilerSetup()
 {
 }
@@ -80,6 +102,22 @@ void StartCompilerSetup::setGenerators(
   for (it = gens.begin(); it != gens.end(); ++it) {
     generator_list.append(QString::fromLocal8Bit(it->name.c_str()));
 
+    if (it->supportsPlatform) {
+      this->GeneratorsSupportingPlatform.append(
+        QString::fromLocal8Bit(it->name.c_str()));
+
+      std::vector<std::string>::const_iterator platformIt =
+        it->supportedPlatforms.cbegin();
+      while (platformIt != it->supportedPlatforms.cend()) {
+
+        this->GeneratorSupportedPlatforms.insert(
+          QString::fromLocal8Bit(it->name.c_str()),
+          QString::fromLocal8Bit((*platformIt).c_str()));
+
+        platformIt++;
+      }
+    }
+
     if (it->supportsToolset) {
       this->GeneratorsSupportingToolset.append(
         QString::fromLocal8Bit(it->name.c_str()));
@@ -102,6 +140,11 @@ QString StartCompilerSetup::getGenerator() const
   return this->GeneratorOptions->currentText();
 };
 
+QString StartCompilerSetup::getPlatform() const
+{
+  return this->PlatformOptions->currentText();
+};
+
 QString StartCompilerSetup::getToolset() const
 {
   return this->Toolset->text();
@@ -136,6 +179,24 @@ void StartCompilerSetup::onSelectionChanged(bool on)
 
 void StartCompilerSetup::onGeneratorChanged(QString const& name)
 {
+  // Display the generator platform for the generators supporting it
+  if (GeneratorsSupportingPlatform.contains(name)) {
+
+    // Regenerate the list of supported platform
+    this->PlatformOptions->clear();
+    QStringList platform_list;
+    platform_list.append("");
+
+    QList<QString> platforms = this->GeneratorSupportedPlatforms.values(name);
+    platform_list.append(platforms);
+
+    this->PlatformOptions->addItems(platform_list);
+    PlatformFrame->show();
+  } else {
+    PlatformFrame->hide();
+  }
+
+  // Display the toolset box for the generators supporting it
   if (GeneratorsSupportingToolset.contains(name)) {
     ToolsetFrame->show();
   } else {
@@ -390,6 +451,11 @@ QString FirstConfigure::getGenerator() const
   return this->mStartCompilerSetupPage->getGenerator();
 }
 
+QString FirstConfigure::getPlatform() const
+{
+  return this->mStartCompilerSetupPage->getPlatform();
+}
+
 QString FirstConfigure::getToolset() const
 {
   return this->mStartCompilerSetupPage->getToolset();
diff --git a/Source/QtDialog/FirstConfigure.h b/Source/QtDialog/FirstConfigure.h
index abfa03f..133f422 100644
--- a/Source/QtDialog/FirstConfigure.h
+++ b/Source/QtDialog/FirstConfigure.h
@@ -35,6 +35,7 @@ public:
   void setCurrentGenerator(const QString& gen);
   QString getGenerator() const;
   QString getToolset() const;
+  QString getPlatform() const;
 
   bool defaultSetup() const;
   bool compilerSetup() const;
@@ -56,10 +57,16 @@ protected:
   QFrame* ToolsetFrame;
   QLineEdit* Toolset;
   QLabel* ToolsetLabel;
+  QFrame* PlatformFrame;
+  QComboBox* PlatformOptions;
+  QLabel* PlatformLabel;
   QStringList GeneratorsSupportingToolset;
+  QStringList GeneratorsSupportingPlatform;
+  QMultiMap<QString, QString> GeneratorSupportedPlatforms;
 
 private:
   QFrame* CreateToolsetWidgets();
+  QFrame* CreatePlatformWidgets();
 };
 
 //! the page that gives basic options for native compilers
@@ -159,6 +166,7 @@ public:
 
   void setGenerators(std::vector<cmake::GeneratorInfo> const& gens);
   QString getGenerator() const;
+  QString getPlatform() const;
   QString getToolset() const;
 
   bool defaultSetup() const;
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index 9a6784e..2eecce6 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -35,7 +35,8 @@ QCMake::QCMake(QObject* p)
   cmSystemTools::SetInterruptCallback(QCMake::interruptCallback, this);
 
   std::vector<cmake::GeneratorInfo> generators;
-  this->CMakeInstance->GetRegisteredGenerators(generators);
+  this->CMakeInstance->GetRegisteredGenerators(
+    generators, /*includeNamesWithPlatform=*/false);
 
   std::vector<cmake::GeneratorInfo>::const_iterator it;
   for (it = generators.begin(); it != generators.end(); ++it) {
@@ -74,6 +75,7 @@ void QCMake::setBinaryDirectory(const QString& _dir)
     cmState* state = this->CMakeInstance->GetState();
     this->setGenerator(QString());
     this->setToolset(QString());
+    this->setPlatform(QString());
     if (!this->CMakeInstance->LoadCache(
           this->BinaryDirectory.toLocal8Bit().data())) {
       QDir testDir(this->BinaryDirectory);
@@ -102,6 +104,12 @@ void QCMake::setBinaryDirectory(const QString& _dir)
       this->setGenerator(QString::fromLocal8Bit(curGen.c_str()));
     }
 
+    const char* platform =
+      state->GetCacheEntryValue("CMAKE_GENERATOR_PLATFORM");
+    if (platform) {
+      this->setPlatform(QString::fromLocal8Bit(platform));
+    }
+
     const char* toolset = state->GetCacheEntryValue("CMAKE_GENERATOR_TOOLSET");
     if (toolset) {
       this->setToolset(QString::fromLocal8Bit(toolset));
@@ -119,6 +127,14 @@ void QCMake::setGenerator(const QString& gen)
   }
 }
 
+void QCMake::setPlatform(const QString& platform)
+{
+  if (this->Platform != platform) {
+    this->Platform = platform;
+    emit this->platformChanged(this->Platform);
+  }
+}
+
 void QCMake::setToolset(const QString& toolset)
 {
   if (this->Toolset != toolset) {
@@ -140,7 +156,8 @@ void QCMake::configure()
   this->CMakeInstance->SetGlobalGenerator(
     this->CMakeInstance->CreateGlobalGenerator(
       this->Generator.toLocal8Bit().data()));
-  this->CMakeInstance->SetGeneratorPlatform("");
+  this->CMakeInstance->SetGeneratorPlatform(
+    this->Platform.toLocal8Bit().data());
   this->CMakeInstance->SetGeneratorToolset(this->Toolset.toLocal8Bit().data());
   this->CMakeInstance->LoadCache();
   this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode);
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index 4b3920a..c84da58 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -75,6 +75,8 @@ public slots:
   /// set the desired generator to use
   void setGenerator(const QString& generator);
   /// set the desired generator to use
+  void setPlatform(const QString& platform);
+  /// set the desired generator to use
   void setToolset(const QString& toolset);
   /// do the configure step
   void configure();
@@ -155,6 +157,8 @@ signals:
   void debugOutputChanged(bool);
   /// signal when the toolset changes
   void toolsetChanged(const QString& toolset);
+  /// signal when the platform changes
+  void platformChanged(const QString& platform);
   /// signal when open is done
   void openDone(bool successful);
   /// signal when open is done
@@ -175,6 +179,7 @@ protected:
   QString SourceDirectory;
   QString BinaryDirectory;
   QString Generator;
+  QString Platform;
   QString Toolset;
   std::vector<cmake::GeneratorInfo> AvailableGenerators;
   QString CMakeExecutable;

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8bba458ea5d6b792e165560d79efd8d8356f4329
commit 8bba458ea5d6b792e165560d79efd8d8356f4329
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Jan 18 11:45:33 2019 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Jan 18 12:30:19 2019 -0500

    Add global generator factory method to get default platform name

diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h
index 26c9545..d4f772b 100644
--- a/Source/cmGlobalGeneratorFactory.h
+++ b/Source/cmGlobalGeneratorFactory.h
@@ -41,6 +41,9 @@ public:
 
   /** Get the list of supported platforms name for this generator */
   virtual std::vector<std::string> GetKnownPlatforms() const = 0;
+
+  /** If the generator suports platforms, get its default.  */
+  virtual std::string GetDefaultPlatformName() const = 0;
 };
 
 template <class T>
@@ -87,6 +90,8 @@ public:
     // default is no platform supported
     return std::vector<std::string>();
   }
+
+  std::string GetDefaultPlatformName() const override { return std::string(); }
 };
 
 #endif
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index c439f68..dbe582b 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -100,6 +100,8 @@ public:
     platforms.emplace_back("Itanium");
     return platforms;
   }
+
+  std::string GetDefaultPlatformName() const override { return "Win32"; }
 };
 
 cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory()
diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx
index 0aaf2bb..4eb78ba 100644
--- a/Source/cmGlobalVisualStudio11Generator.cxx
+++ b/Source/cmGlobalVisualStudio11Generator.cxx
@@ -109,6 +109,8 @@ public:
 
     return platforms;
   }
+
+  std::string GetDefaultPlatformName() const override { return "Win32"; }
 };
 
 cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory()
diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx
index 1c202a8..8b50684 100644
--- a/Source/cmGlobalVisualStudio12Generator.cxx
+++ b/Source/cmGlobalVisualStudio12Generator.cxx
@@ -84,6 +84,8 @@ public:
     platforms.emplace_back("ARM");
     return platforms;
   }
+
+  std::string GetDefaultPlatformName() const override { return "Win32"; }
 };
 
 cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory()
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index c87433e..a0a9558 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -84,6 +84,8 @@ public:
     platforms.emplace_back("ARM");
     return platforms;
   }
+
+  std::string GetDefaultPlatformName() const override { return "Win32"; }
 };
 
 cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory()
diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx
index 15a83af..6e61d268 100644
--- a/Source/cmGlobalVisualStudio9Generator.cxx
+++ b/Source/cmGlobalVisualStudio9Generator.cxx
@@ -99,6 +99,8 @@ public:
     }
     return platforms;
   }
+
+  std::string GetDefaultPlatformName() const override { return "Win32"; }
 };
 
 cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
index 4b08b11..31f585c 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
@@ -159,6 +159,8 @@ public:
     platforms.emplace_back("ARM64");
     return platforms;
   }
+
+  std::string GetDefaultPlatformName() const override { return "Win32"; }
 };
 
 cmGlobalGeneratorFactory*
@@ -234,6 +236,11 @@ public:
     platforms.emplace_back("ARM64");
     return platforms;
   }
+
+  std::string GetDefaultPlatformName() const override
+  {
+    return VSHostPlatformName();
+  }
 };
 
 cmGlobalGeneratorFactory*
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index ca5dafe..4dd1a87 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -152,6 +152,8 @@ public:
   {
     return std::vector<std::string>();
   }
+
+  std::string GetDefaultPlatformName() const override { return std::string(); }
 };
 
 cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 927d39b..2ac1b00 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -977,6 +977,7 @@ void cmake::GetRegisteredGenerators(std::vector<GeneratorInfo>& generators,
       info.supportsToolset = gen->SupportsToolset();
       info.supportsPlatform = gen->SupportsPlatform();
       info.supportedPlatforms = gen->GetKnownPlatforms();
+      info.defaultPlatform = gen->GetDefaultPlatformName();
       info.name = name;
       info.baseName = name;
       info.isAlias = false;
diff --git a/Source/cmake.h b/Source/cmake.h
index d67f835..38d0c62 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -105,6 +105,7 @@ public:
     bool supportsToolset;
     bool supportsPlatform;
     std::vector<std::string> supportedPlatforms;
+    std::string defaultPlatform;
     bool isAlias;
   };
 

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=818df52c488a94628169811bddffe05f36c68b42
commit 818df52c488a94628169811bddffe05f36c68b42
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Jan 18 10:13:55 2019 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Jan 18 12:29:53 2019 -0500

    Add global generator factory method to get list of known platforms
    
    Add a `cmGlobalGeneratorFactory::GetKnownPlatforms` method to return
    a list of known possible values for `CMAKE_GENERATOR_PLATFORM`.
    Implement the method for each generator by referencing the list of
    possible values documented in `Help/generator/*.rst` for it.
    
    Co-Author: Julien Jomier <julien.jomier at kitware.com>

diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h
index 906ec9a..26c9545 100644
--- a/Source/cmGlobalGeneratorFactory.h
+++ b/Source/cmGlobalGeneratorFactory.h
@@ -38,6 +38,9 @@ public:
 
   /** Determine whether or not this generator supports platforms */
   virtual bool SupportsPlatform() const = 0;
+
+  /** Get the list of supported platforms name for this generator */
+  virtual std::vector<std::string> GetKnownPlatforms() const = 0;
 };
 
 template <class T>
@@ -77,6 +80,13 @@ public:
 
   /** Determine whether or not this generator supports platforms */
   bool SupportsPlatform() const override { return T::SupportsPlatform(); }
+
+  /** Get the list of supported platforms name for this generator */
+  std::vector<std::string> GetKnownPlatforms() const override
+  {
+    // default is no platform supported
+    return std::vector<std::string>();
+  }
 };
 
 #endif
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index bf856ea..c439f68 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -91,6 +91,15 @@ public:
 
   bool SupportsToolset() const override { return true; }
   bool SupportsPlatform() const override { return true; }
+
+  std::vector<std::string> GetKnownPlatforms() const override
+  {
+    std::vector<std::string> platforms;
+    platforms.emplace_back("x64");
+    platforms.emplace_back("Win32");
+    platforms.emplace_back("Itanium");
+    return platforms;
+  }
 };
 
 cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory()
diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx
index a44058b..0aaf2bb 100644
--- a/Source/cmGlobalVisualStudio11Generator.cxx
+++ b/Source/cmGlobalVisualStudio11Generator.cxx
@@ -93,6 +93,22 @@ public:
 
   bool SupportsToolset() const override { return true; }
   bool SupportsPlatform() const override { return true; }
+
+  std::vector<std::string> GetKnownPlatforms() const override
+  {
+    std::vector<std::string> platforms;
+    platforms.emplace_back("x64");
+    platforms.emplace_back("Win32");
+    platforms.emplace_back("ARM");
+
+    std::set<std::string> installedSDKs =
+      cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs();
+    for (std::string const& i : installedSDKs) {
+      platforms.emplace_back(i);
+    }
+
+    return platforms;
+  }
 };
 
 cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory()
diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx
index cbd5085..1c202a8 100644
--- a/Source/cmGlobalVisualStudio12Generator.cxx
+++ b/Source/cmGlobalVisualStudio12Generator.cxx
@@ -75,6 +75,15 @@ public:
 
   bool SupportsToolset() const override { return true; }
   bool SupportsPlatform() const override { return true; }
+
+  std::vector<std::string> GetKnownPlatforms() const override
+  {
+    std::vector<std::string> platforms;
+    platforms.emplace_back("x64");
+    platforms.emplace_back("Win32");
+    platforms.emplace_back("ARM");
+    return platforms;
+  }
 };
 
 cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory()
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index 47768a8..c87433e 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -75,6 +75,15 @@ public:
 
   bool SupportsToolset() const override { return true; }
   bool SupportsPlatform() const override { return true; }
+
+  std::vector<std::string> GetKnownPlatforms() const override
+  {
+    std::vector<std::string> platforms;
+    platforms.emplace_back("x64");
+    platforms.emplace_back("Win32");
+    platforms.emplace_back("ARM");
+    return platforms;
+  }
 };
 
 cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory()
diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx
index d72b25b..15a83af 100644
--- a/Source/cmGlobalVisualStudio9Generator.cxx
+++ b/Source/cmGlobalVisualStudio9Generator.cxx
@@ -83,6 +83,22 @@ public:
 
   bool SupportsToolset() const override { return false; }
   bool SupportsPlatform() const override { return true; }
+
+  std::vector<std::string> GetKnownPlatforms() const override
+  {
+    std::vector<std::string> platforms;
+    platforms.emplace_back("x64");
+    platforms.emplace_back("Win32");
+    platforms.emplace_back("Itanium");
+    cmVisualStudioWCEPlatformParser parser;
+    parser.ParseVersion("9.0");
+    const std::vector<std::string>& availablePlatforms =
+      parser.GetAvailablePlatforms();
+    for (std::string const& i : availablePlatforms) {
+      platforms.emplace_back(i);
+    }
+    return platforms;
+  }
 };
 
 cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
index 0860294..4b08b11 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
@@ -149,6 +149,16 @@ public:
 
   bool SupportsToolset() const override { return true; }
   bool SupportsPlatform() const override { return true; }
+
+  std::vector<std::string> GetKnownPlatforms() const override
+  {
+    std::vector<std::string> platforms;
+    platforms.emplace_back("x64");
+    platforms.emplace_back("Win32");
+    platforms.emplace_back("ARM");
+    platforms.emplace_back("ARM64");
+    return platforms;
+  }
 };
 
 cmGlobalGeneratorFactory*
@@ -214,6 +224,16 @@ public:
 
   bool SupportsToolset() const override { return true; }
   bool SupportsPlatform() const override { return true; }
+
+  std::vector<std::string> GetKnownPlatforms() const override
+  {
+    std::vector<std::string> platforms;
+    platforms.emplace_back("x64");
+    platforms.emplace_back("Win32");
+    platforms.emplace_back("ARM");
+    platforms.emplace_back("ARM64");
+    return platforms;
+  }
 };
 
 cmGlobalGeneratorFactory*
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index e5ab0e1..ca5dafe 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -147,6 +147,11 @@ public:
 
   bool SupportsToolset() const override { return true; }
   bool SupportsPlatform() const override { return false; }
+
+  std::vector<std::string> GetKnownPlatforms() const override
+  {
+    return std::vector<std::string>();
+  }
 };
 
 cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index f320aff..927d39b 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -976,6 +976,7 @@ void cmake::GetRegisteredGenerators(std::vector<GeneratorInfo>& generators,
       GeneratorInfo info;
       info.supportsToolset = gen->SupportsToolset();
       info.supportsPlatform = gen->SupportsPlatform();
+      info.supportedPlatforms = gen->GetKnownPlatforms();
       info.name = name;
       info.baseName = name;
       info.isAlias = false;
diff --git a/Source/cmake.h b/Source/cmake.h
index b37cccd..d67f835 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -104,6 +104,7 @@ public:
     std::string extraName;
     bool supportsToolset;
     bool supportsPlatform;
+    std::vector<std::string> supportedPlatforms;
     bool isAlias;
   };
 

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8144b00e32cf1e24daf41353cbcd1806311ceac9
commit 8144b00e32cf1e24daf41353cbcd1806311ceac9
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Jan 18 11:08:45 2019 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Jan 18 12:29:53 2019 -0500

    Split global generator factory list with and without platforms
    
    Replace `cmGlobalGeneratorFactory::GetGenerators` with a pair of methods
    to split the list of generator names into those that have platforms in
    the name and those that do not.

diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h
index 4e3e770..906ec9a 100644
--- a/Source/cmGlobalGeneratorFactory.h
+++ b/Source/cmGlobalGeneratorFactory.h
@@ -30,7 +30,8 @@ public:
   virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
 
   /** Get the names of the current registered generators */
-  virtual void GetGenerators(std::vector<std::string>& names) const = 0;
+  virtual std::vector<std::string> GetGeneratorNames() const = 0;
+  virtual std::vector<std::string> GetGeneratorNamesWithPlatform() const = 0;
 
   /** Determine whether or not this generator supports toolsets */
   virtual bool SupportsToolset() const = 0;
@@ -60,9 +61,15 @@ public:
   }
 
   /** Get the names of the current registered generators */
-  void GetGenerators(std::vector<std::string>& names) const override
+  std::vector<std::string> GetGeneratorNames() const override
   {
+    std::vector<std::string> names;
     names.push_back(T::GetActualName());
+    return names;
+  }
+  std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+  {
+    return std::vector<std::string>();
   }
 
   /** Determine whether or not this generator supports toolsets */
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 79757a8..bf856ea 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -74,11 +74,19 @@ public:
                   "Optional [arch] can be \"Win64\" or \"IA64\".";
   }
 
-  void GetGenerators(std::vector<std::string>& names) const override
+  std::vector<std::string> GetGeneratorNames() const override
   {
+    std::vector<std::string> names;
     names.push_back(vs10generatorName);
+    return names;
+  }
+
+  std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+  {
+    std::vector<std::string> names;
     names.push_back(vs10generatorName + std::string(" IA64"));
     names.push_back(vs10generatorName + std::string(" Win64"));
+    return names;
   }
 
   bool SupportsToolset() const override { return true; }
diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx
index 36eb492..a44058b 100644
--- a/Source/cmGlobalVisualStudio11Generator.cxx
+++ b/Source/cmGlobalVisualStudio11Generator.cxx
@@ -69,9 +69,16 @@ public:
                   "Optional [arch] can be \"Win64\" or \"ARM\".";
   }
 
-  void GetGenerators(std::vector<std::string>& names) const override
+  std::vector<std::string> GetGeneratorNames() const override
   {
+    std::vector<std::string> names;
     names.push_back(vs11generatorName);
+    return names;
+  }
+
+  std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+  {
+    std::vector<std::string> names;
     names.push_back(vs11generatorName + std::string(" ARM"));
     names.push_back(vs11generatorName + std::string(" Win64"));
 
@@ -80,6 +87,8 @@ public:
     for (std::string const& i : installedSDKs) {
       names.push_back(std::string(vs11generatorName) + " " + i);
     }
+
+    return names;
   }
 
   bool SupportsToolset() const override { return true; }
diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx
index 61034a7..cbd5085 100644
--- a/Source/cmGlobalVisualStudio12Generator.cxx
+++ b/Source/cmGlobalVisualStudio12Generator.cxx
@@ -58,11 +58,19 @@ public:
                   "Optional [arch] can be \"Win64\" or \"ARM\".";
   }
 
-  void GetGenerators(std::vector<std::string>& names) const override
+  std::vector<std::string> GetGeneratorNames() const override
   {
+    std::vector<std::string> names;
     names.push_back(vs12generatorName);
+    return names;
+  }
+
+  std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+  {
+    std::vector<std::string> names;
     names.push_back(vs12generatorName + std::string(" ARM"));
     names.push_back(vs12generatorName + std::string(" Win64"));
+    return names;
   }
 
   bool SupportsToolset() const override { return true; }
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index 5ea5e67..47768a8 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -58,11 +58,19 @@ public:
                   "Optional [arch] can be \"Win64\" or \"ARM\".";
   }
 
-  void GetGenerators(std::vector<std::string>& names) const override
+  std::vector<std::string> GetGeneratorNames() const override
   {
+    std::vector<std::string> names;
     names.push_back(vs14generatorName);
+    return names;
+  }
+
+  std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+  {
+    std::vector<std::string> names;
     names.push_back(vs14generatorName + std::string(" ARM"));
     names.push_back(vs14generatorName + std::string(" Win64"));
+    return names;
   }
 
   bool SupportsToolset() const override { return true; }
diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx
index 445b40c..d72b25b 100644
--- a/Source/cmGlobalVisualStudio9Generator.cxx
+++ b/Source/cmGlobalVisualStudio9Generator.cxx
@@ -59,9 +59,16 @@ public:
                   "Optional [arch] can be \"Win64\" or \"IA64\".";
   }
 
-  void GetGenerators(std::vector<std::string>& names) const override
+  std::vector<std::string> GetGeneratorNames() const override
   {
+    std::vector<std::string> names;
     names.push_back(vs9generatorName);
+    return names;
+  }
+
+  std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+  {
+    std::vector<std::string> names;
     names.push_back(vs9generatorName + std::string(" Win64"));
     names.push_back(vs9generatorName + std::string(" IA64"));
     cmVisualStudioWCEPlatformParser parser;
@@ -71,6 +78,7 @@ public:
     for (std::string const& i : availablePlatforms) {
       names.push_back("Visual Studio 9 2008 " + i);
     }
+    return names;
   }
 
   bool SupportsToolset() const override { return false; }
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
index 15e52fe..0860294 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
@@ -132,11 +132,19 @@ public:
                   "Optional [arch] can be \"Win64\" or \"ARM\".";
   }
 
-  void GetGenerators(std::vector<std::string>& names) const override
+  std::vector<std::string> GetGeneratorNames() const override
   {
+    std::vector<std::string> names;
     names.push_back(vs15generatorName);
+    return names;
+  }
+
+  std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+  {
+    std::vector<std::string> names;
     names.push_back(vs15generatorName + std::string(" ARM"));
     names.push_back(vs15generatorName + std::string(" Win64"));
+    return names;
   }
 
   bool SupportsToolset() const override { return true; }
@@ -192,9 +200,16 @@ public:
                   "Use -A option to specify architecture.";
   }
 
-  virtual void GetGenerators(std::vector<std::string>& names) const
+  std::vector<std::string> GetGeneratorNames() const override
   {
+    std::vector<std::string> names;
     names.push_back(vs16generatorName);
+    return names;
+  }
+
+  std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+  {
+    return std::vector<std::string>();
   }
 
   bool SupportsToolset() const override { return true; }
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 6618351..e5ab0e1 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -133,9 +133,16 @@ public:
     cmGlobalXCodeGenerator::GetDocumentation(entry);
   }
 
-  void GetGenerators(std::vector<std::string>& names) const override
+  std::vector<std::string> GetGeneratorNames() const override
   {
+    std::vector<std::string> names;
     names.push_back(cmGlobalXCodeGenerator::GetActualName());
+    return names;
+  }
+
+  std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+  {
+    return std::vector<std::string>();
   }
 
   bool SupportsToolset() const override { return true; }
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 9fcfbde..f320aff 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -959,12 +959,18 @@ void cmake::AddDefaultExtraGenerators()
 #endif
 }
 
-void cmake::GetRegisteredGenerators(
-  std::vector<GeneratorInfo>& generators) const
+void cmake::GetRegisteredGenerators(std::vector<GeneratorInfo>& generators,
+                                    bool includeNamesWithPlatform) const
 {
   for (cmGlobalGeneratorFactory* gen : this->Generators) {
-    std::vector<std::string> names;
-    gen->GetGenerators(names);
+    std::vector<std::string> names = gen->GetGeneratorNames();
+
+    if (includeNamesWithPlatform) {
+      std::vector<std::string> namesWithPlatform =
+        gen->GetGeneratorNamesWithPlatform();
+      names.insert(names.end(), namesWithPlatform.begin(),
+                   namesWithPlatform.end());
+    }
 
     for (std::string const& name : names) {
       GeneratorInfo info;
diff --git a/Source/cmake.h b/Source/cmake.h
index cd8c622..b37cccd 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -196,7 +196,8 @@ public:
   void SetGlobalGenerator(cmGlobalGenerator*);
 
   ///! Get the names of the current registered generators
-  void GetRegisteredGenerators(std::vector<GeneratorInfo>& generators) const;
+  void GetRegisteredGenerators(std::vector<GeneratorInfo>& generators,
+                               bool includeNamesWithPlatform = true) const;
 
   ///! Set the name of the selected generator-specific instance.
   void SetGeneratorInstance(std::string const& instance)

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b70c0aed5c616edce5cbc803c7de92580f835f90
commit b70c0aed5c616edce5cbc803c7de92580f835f90
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Jan 18 11:41:31 2019 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Fri Jan 18 12:29:53 2019 -0500

    VS: Factor out helper function to compute host platform name

diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
index 99f9503..15e52fe 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
@@ -19,6 +19,20 @@
 #  include "cmsys/SystemInformation.hxx"
 #endif
 
+static std::string VSHostPlatformName()
+{
+#ifdef HOST_PLATFORM_NAME
+  return HOST_PLATFORM_NAME;
+#else
+  cmsys::SystemInformation info;
+  if (info.Is64Bits()) {
+    return "x64";
+  } else {
+    return "Win32";
+  }
+#endif
+}
+
 static unsigned int VSVersionToMajor(
   cmGlobalVisualStudioGenerator::VSVersion v)
 {
@@ -206,16 +220,7 @@ cmGlobalVisualStudioVersionedGenerator::cmGlobalVisualStudioVersionedGenerator(
   this->DefaultCSharpFlagTableName = VSVersionToToolset(this->Version);
   this->DefaultLinkFlagTableName = VSVersionToToolset(this->Version);
   if (this->Version >= cmGlobalVisualStudioGenerator::VS16) {
-#ifdef HOST_PLATFORM_NAME
-    this->DefaultPlatformName = HOST_PLATFORM_NAME;
-#else
-    cmsys::SystemInformation info;
-    if (info.Is64Bits()) {
-      this->DefaultPlatformName = "x64";
-    } else {
-      this->DefaultPlatformName = "Win32";
-    }
-#endif
+    this->DefaultPlatformName = VSHostPlatformName();
   }
 }
 

-----------------------------------------------------------------------

Summary of changes:
 Source/QtDialog/CMakeSetupDialog.cxx              |  1 +
 Source/QtDialog/FirstConfigure.cxx                | 80 ++++++++++++++++++++++-
 Source/QtDialog/FirstConfigure.h                  |  9 +++
 Source/QtDialog/QCMake.cxx                        | 21 +++++-
 Source/QtDialog/QCMake.h                          |  5 ++
 Source/cmCTest.cxx                                |  4 +-
 Source/cmDepends.cxx                              | 23 +++----
 Source/cmDepends.h                                | 13 ++--
 Source/cmDependsC.cxx                             | 18 ++---
 Source/cmDependsC.h                               |  4 +-
 Source/cmDependsFortran.cxx                       | 58 ++++++++--------
 Source/cmDependsFortran.h                         | 15 +++--
 Source/cmDependsJava.cxx                          |  3 +-
 Source/cmDependsJava.h                            |  2 +-
 Source/cmExecProgramCommand.cxx                   |  6 +-
 Source/cmExecuteProcessCommand.cxx                |  8 +--
 Source/cmGlobalGeneratorFactory.h                 | 26 +++++++-
 Source/cmGlobalVisualStudio10Generator.cxx        | 21 +++++-
 Source/cmGlobalVisualStudio11Generator.cxx        | 29 +++++++-
 Source/cmGlobalVisualStudio12Generator.cxx        | 21 +++++-
 Source/cmGlobalVisualStudio14Generator.cxx        | 21 +++++-
 Source/cmGlobalVisualStudio9Generator.cxx         | 28 +++++++-
 Source/cmGlobalVisualStudioVersionedGenerator.cxx | 71 ++++++++++++++++----
 Source/cmGlobalXCodeGenerator.cxx                 | 16 ++++-
 Source/cmLocalUnixMakefileGenerator3.cxx          | 25 ++++---
 Source/cmLocalUnixMakefileGenerator3.h            |  2 +-
 Source/cmQtAutoGenerator.cxx                      |  8 +--
 Source/cmSystemTools.cxx                          | 36 ++++------
 Source/cmSystemTools.h                            |  6 +-
 Source/cmake.cxx                                  | 32 +++++----
 Source/cmake.h                                    |  5 +-
 31 files changed, 459 insertions(+), 158 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list