summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenGlobalInitializer.cxx
diff options
context:
space:
mode:
authorOrkun Tokdemir <ilhanorkuntokdemir@gmail.com>2023-06-14 11:10:03 (GMT)
committerOrkun Tokdemir <ilhanorkuntokdemir@gmail.com>2023-09-13 16:23:56 (GMT)
commitfddd0f0443b4ce81d61f15ee1b2f13105967b25a (patch)
tree46e0ed1f11a9ac721672977758c2a628478cba32 /Source/cmQtAutoGenGlobalInitializer.cxx
parent10b09647f2699b32c3d243f595437cb1c63049e2 (diff)
downloadCMake-fddd0f0443b4ce81d61f15ee1b2f13105967b25a.zip
CMake-fddd0f0443b4ce81d61f15ee1b2f13105967b25a.tar.gz
CMake-fddd0f0443b4ce81d61f15ee1b2f13105967b25a.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. * The timestamp target was split into three targets for per-config to avoid redundant `mocs_compilation` builds. * Per-config `DEP_FILE_RULE_NAME` values were added to `AutogenInfo.json` for `CMAKE_CROSS_CONFIG` usage. * Some functions were refactored to avoid code duplication. Fixes: #20074
Diffstat (limited to 'Source/cmQtAutoGenGlobalInitializer.cxx')
-rw-r--r--Source/cmQtAutoGenGlobalInitializer.cxx91
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;
}