diff options
Diffstat (limited to 'Source/cmQtAutoGenGlobalInitializer.cxx')
-rw-r--r-- | Source/cmQtAutoGenGlobalInitializer.cxx | 91 |
1 files changed, 73 insertions, 18 deletions
diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx index 1da8847..214df25 100644 --- a/Source/cmQtAutoGenGlobalInitializer.cxx +++ b/Source/cmQtAutoGenGlobalInitializer.cxx @@ -213,24 +213,81 @@ void cmQtAutoGenGlobalInitializer::AddToGlobalAutoRcc( } } -cmQtAutoGen::CompilerFeaturesHandle +cmQtAutoGen::ConfigStrings<cmQtAutoGen::CompilerFeaturesHandle> cmQtAutoGenGlobalInitializer::GetCompilerFeatures( - std::string const& generator, std::string const& executable, - std::string& error) + std::string const& generator, cmQtAutoGen::ConfigString const& executable, + std::string& error, bool const isMultiConfig) { + cmQtAutoGen::ConfigStrings<cmQtAutoGen::CompilerFeaturesHandle> res; + if (isMultiConfig) { + for (auto const& config : executable.Config) { + auto const exe = config.second; + // Check if we have cached features + { + auto it = this->CompilerFeatures_.Config[config.first].find(exe); + if (it != this->CompilerFeatures_.Config[config.first].end()) { + res.Config[config.first] = it->second; + continue; + } + } + + // Check if the executable exists + if (!cmSystemTools::FileExists(exe, true)) { + error = cmStrCat("The \"", generator, "\" executable ", + cmQtAutoGen::Quoted(exe), " does not exist."); + res.Config[config.first] = {}; + continue; + } + + // Test the executable + std::string stdOut; + { + std::string stdErr; + std::vector<std::string> command; + command.emplace_back(exe); + command.emplace_back("-h"); + int retVal = 0; + const bool runResult = cmSystemTools::RunSingleCommand( + command, &stdOut, &stdErr, &retVal, nullptr, + cmSystemTools::OUTPUT_NONE, cmDuration::zero(), + cmProcessOutput::Auto); + if (!runResult) { + error = cmStrCat("Test run of \"", generator, "\" executable ", + cmQtAutoGen::Quoted(exe), " failed.\n", + cmQtAutoGen::QuotedCommand(command), '\n', stdOut, + '\n', stdErr); + res.Config[config.first] = {}; + continue; + } + } + + // Create valid handle + res.Config[config.first] = + std::make_shared<cmQtAutoGen::CompilerFeatures>(); + res.Config[config.first]->HelpOutput = std::move(stdOut); + + // Register compiler features + this->CompilerFeatures_.Config[config.first].emplace( + exe, res.Config[config.first]); + } + return res; + } + // Check if we have cached features { - auto it = this->CompilerFeatures_.find(executable); - if (it != this->CompilerFeatures_.end()) { - return it->second; + auto it = this->CompilerFeatures_.Default.find(executable.Default); + if (it != this->CompilerFeatures_.Default.end()) { + res.Default = it->second; + return res; } } // Check if the executable exists - if (!cmSystemTools::FileExists(executable, true)) { - error = cmStrCat("The \"", generator, "\" executable ", - cmQtAutoGen::Quoted(executable), " does not exist."); - return cmQtAutoGen::CompilerFeaturesHandle(); + if (!cmSystemTools::FileExists(executable.Default, true)) { + error = + cmStrCat("The \"", generator, "\" executable ", + cmQtAutoGen::Quoted(executable.Default), " does not exist."); + return cmQtAutoGen::ConfigStrings<cmQtAutoGen::CompilerFeaturesHandle>(); } // Test the executable @@ -238,7 +295,7 @@ cmQtAutoGenGlobalInitializer::GetCompilerFeatures( { std::string stdErr; std::vector<std::string> command; - command.emplace_back(executable); + command.emplace_back(executable.Default); command.emplace_back("-h"); int retVal = 0; const bool runResult = cmSystemTools::RunSingleCommand( @@ -246,20 +303,18 @@ cmQtAutoGenGlobalInitializer::GetCompilerFeatures( cmDuration::zero(), cmProcessOutput::Auto); if (!runResult) { error = cmStrCat("Test run of \"", generator, "\" executable ", - cmQtAutoGen::Quoted(executable), " failed.\n", + cmQtAutoGen::Quoted(executable.Default), " failed.\n", cmQtAutoGen::QuotedCommand(command), '\n', stdOut, '\n', stdErr); - return cmQtAutoGen::CompilerFeaturesHandle(); + return cmQtAutoGen::ConfigStrings<cmQtAutoGen::CompilerFeaturesHandle>(); } } - // Create valid handle - cmQtAutoGen::CompilerFeaturesHandle res = - std::make_shared<cmQtAutoGen::CompilerFeatures>(); - res->HelpOutput = std::move(stdOut); + res.Default = std::make_shared<cmQtAutoGen::CompilerFeatures>(); + res.Default->HelpOutput = std::move(stdOut); // Register compiler features - this->CompilerFeatures_.emplace(executable, res); + this->CompilerFeatures_.Default.emplace(executable.Default, res.Default); return res; } |