summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenGlobalInitializer.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-05-22 10:09:31 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-05-22 10:25:17 (GMT)
commit71d6a1455e402755023b509629971afd1ed98922 (patch)
tree7c29c0201927d7a6d5c35b149721fd59c430abf9 /Source/cmQtAutoGenGlobalInitializer.cxx
parent0bf53483295a4b7de358e8b85ad44866d89633c5 (diff)
downloadCMake-71d6a1455e402755023b509629971afd1ed98922.zip
CMake-71d6a1455e402755023b509629971afd1ed98922.tar.gz
CMake-71d6a1455e402755023b509629971afd1ed98922.tar.bz2
Autogen: Evaluate compiler features for the same exectuable only once
To speed up the `AUTOGEN` configuration process, evaluate the compiler features only once. The feature evaluation result is stored in the new class `cmQtAutoGen::CompilerFeatures`, and the instance is shared by using `std::shared_ptr`.
Diffstat (limited to 'Source/cmQtAutoGenGlobalInitializer.cxx')
-rw-r--r--Source/cmQtAutoGenGlobalInitializer.cxx37
1 files changed, 17 insertions, 20 deletions
diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx
index 59e17d7..ef8a56b 100644
--- a/Source/cmQtAutoGenGlobalInitializer.cxx
+++ b/Source/cmQtAutoGenGlobalInitializer.cxx
@@ -203,19 +203,16 @@ void cmQtAutoGenGlobalInitializer::AddToGlobalAutoRcc(
}
}
-bool cmQtAutoGenGlobalInitializer::GetExecutableTestOutput(
+cmQtAutoGen::CompilerFeaturesHandle
+cmQtAutoGenGlobalInitializer::GetCompilerFeatures(
std::string const& generator, std::string const& executable,
- std::string& error, std::string* output)
+ std::string& error)
{
- // Check if we have cached output
+ // Check if we have cached features
{
- auto it = this->ExecutableTestOutputs_.find(executable);
- if (it != this->ExecutableTestOutputs_.end()) {
- // Return output on demand
- if (output != nullptr) {
- *output = it->second;
- }
- return true;
+ auto it = this->CompilerFeatures_.find(executable);
+ if (it != this->CompilerFeatures_.end()) {
+ return it->second;
}
}
@@ -226,7 +223,7 @@ bool cmQtAutoGenGlobalInitializer::GetExecutableTestOutput(
error += "\" executable ";
error += cmQtAutoGen::Quoted(executable);
error += " does not exist.";
- return false;
+ return cmQtAutoGen::CompilerFeaturesHandle();
}
// Test the executable
@@ -234,7 +231,7 @@ bool cmQtAutoGenGlobalInitializer::GetExecutableTestOutput(
{
std::string stdErr;
std::vector<std::string> command;
- command.push_back(executable);
+ command.emplace_back(executable);
command.emplace_back("-h");
int retVal = 0;
const bool runResult = cmSystemTools::RunSingleCommand(
@@ -250,19 +247,19 @@ bool cmQtAutoGenGlobalInitializer::GetExecutableTestOutput(
error += stdOut;
error += "\n";
error += stdErr;
- return false;
+ return cmQtAutoGen::CompilerFeaturesHandle();
}
}
- // Return executable output on demand
- if (output != nullptr) {
- *output = stdOut;
- }
+ // Create valid handle
+ cmQtAutoGen::CompilerFeaturesHandle res =
+ std::make_shared<cmQtAutoGen::CompilerFeatures>();
+ res->HelpOutput = std::move(stdOut);
- // Register executable and output
- this->ExecutableTestOutputs_.emplace(executable, std::move(stdOut));
+ // Register compiler features
+ this->CompilerFeatures_.emplace(executable, res);
- return true;
+ return res;
}
bool cmQtAutoGenGlobalInitializer::generate()