diff options
author | Orkun Tokdemir <ilhanorkuntokdemir@gmail.com> | 2023-10-18 13:00:57 (GMT) |
---|---|---|
committer | Orkun Tokdemir <ilhanorkuntokdemir@gmail.com> | 2024-01-17 15:02:58 (GMT) |
commit | 7c39dabdbc505587f91ae41b4fd7c287d41443e5 (patch) | |
tree | 8dd9d5a2e2d23bcc1fb26259ac8b64352ba44e60 /Source/cmQtAutoGenGlobalInitializer.cxx | |
parent | 31dead97edb03d568c2e66d88422fa3a7806a253 (diff) | |
download | CMake-7c39dabdbc505587f91ae41b4fd7c287d41443e5.zip CMake-7c39dabdbc505587f91ae41b4fd7c287d41443e5.tar.gz CMake-7c39dabdbc505587f91ae41b4fd7c287d41443e5.tar.bz2 |
Autogen: AUTO*_EXECUTABLE: add support for per-config values
* Per-config values were added to `AUTO*_EXECUTABLE`.
* Dependency order was refactored for `cmake_autogen` and `cmake_autorcc` to avoid unnecessary rebuilds.
* A new parameter was added for `cmake_autogen` and `cmake_autorcc` to specify the config name of the `auto*_executable` to be used.
* Add `AUTOGEN_BETTER_GRAPH_MULTI_CONFIG` target property to change the behavior of the dependency graph.
* The timestamp target is split into three targets for per-config to avoid redundant `mocs_compilation` builds when `AUTOGEN_BETTER_GRAPH_MULTI_CONFIG` is ON
* Per-config `DEP_FILE_RULE_NAME` values were added to `AutogenInfo.json` for `Multi-Config` usage.
* Some functions were refactored to avoid code duplication.
This commit reimplements fddd0f0443b4ce81d61f15ee1b2f13105967b25a
Fixes: #20074
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..5e2f99f 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, bool UseBetterGraph) { + cmQtAutoGen::ConfigStrings<cmQtAutoGen::CompilerFeaturesHandle> res; + if (isMultiConfig && UseBetterGraph) { + 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; } |