mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-19 04:59:48 -06:00
Ninja Multi-Config: Read configuration variables as normal variables
Early versions of the Ninja Multi-Config generator required CMAKE_CONFIGURATION_TYPES and friends to be cache variables in order to support selecting the default config in cmake(1) --build. The behavior of cmake(1) --build has since been updated to no longer require this, and requiring these variables to be cache variables is inconsistent with the other generators. Read the variables as normal CMake variables like the other generators. This does not require a policy, since the only scenario where this would cause a breakage is one where the cache variable and the CMake variable are explicitly set to different values, which doesn't make sense to do anyway.
This commit is contained in:
@@ -2649,31 +2649,18 @@ void cmGlobalNinjaMultiGenerator::GetQtAutoGenConfigs(
|
||||
}
|
||||
|
||||
bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables()
|
||||
{
|
||||
this->GetCMakeInstance()->MarkCliAsUsed("CMAKE_DEFAULT_BUILD_TYPE");
|
||||
this->GetCMakeInstance()->MarkCliAsUsed("CMAKE_CROSS_CONFIGS");
|
||||
this->GetCMakeInstance()->MarkCliAsUsed("CMAKE_DEFAULT_CONFIGS");
|
||||
return this->ReadCacheEntriesForBuild(*this->Makefiles.front()->GetState());
|
||||
}
|
||||
|
||||
std::string cmGlobalNinjaMultiGenerator::GetDefaultBuildConfig() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
|
||||
const cmState& state)
|
||||
{
|
||||
std::vector<std::string> configsVec;
|
||||
cmExpandList(state.GetSafeCacheEntryValue("CMAKE_CONFIGURATION_TYPES"),
|
||||
configsVec);
|
||||
cmExpandList(
|
||||
this->Makefiles.front()->GetSafeDefinition("CMAKE_CONFIGURATION_TYPES"),
|
||||
configsVec);
|
||||
if (configsVec.empty()) {
|
||||
configsVec.emplace_back();
|
||||
}
|
||||
std::set<std::string> configs(configsVec.cbegin(), configsVec.cend());
|
||||
|
||||
this->DefaultFileConfig =
|
||||
state.GetSafeCacheEntryValue("CMAKE_DEFAULT_BUILD_TYPE");
|
||||
this->Makefiles.front()->GetSafeDefinition("CMAKE_DEFAULT_BUILD_TYPE");
|
||||
if (this->DefaultFileConfig.empty()) {
|
||||
this->DefaultFileConfig = configsVec.front();
|
||||
}
|
||||
@@ -2688,8 +2675,9 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
|
||||
}
|
||||
|
||||
std::vector<std::string> crossConfigsVec;
|
||||
cmExpandList(state.GetSafeCacheEntryValue("CMAKE_CROSS_CONFIGS"),
|
||||
crossConfigsVec);
|
||||
cmExpandList(
|
||||
this->Makefiles.front()->GetSafeDefinition("CMAKE_CROSS_CONFIGS"),
|
||||
crossConfigsVec);
|
||||
auto crossConfigs = ListSubsetWithAll(configs, configs, crossConfigsVec);
|
||||
if (!crossConfigs) {
|
||||
std::ostringstream msg;
|
||||
@@ -2702,7 +2690,7 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
|
||||
this->CrossConfigs = *crossConfigs;
|
||||
|
||||
auto defaultConfigsString =
|
||||
state.GetSafeCacheEntryValue("CMAKE_DEFAULT_CONFIGS");
|
||||
this->Makefiles.front()->GetSafeDefinition("CMAKE_DEFAULT_CONFIGS");
|
||||
if (defaultConfigsString.empty()) {
|
||||
defaultConfigsString = this->DefaultFileConfig;
|
||||
}
|
||||
@@ -2736,6 +2724,11 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string cmGlobalNinjaMultiGenerator::GetDefaultBuildConfig() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string cmGlobalNinjaMultiGenerator::OrderDependsTargetForTarget(
|
||||
cmGeneratorTarget const* target, const std::string& config) const
|
||||
{
|
||||
|
||||
@@ -31,7 +31,6 @@ class cmLinkLineComputer;
|
||||
class cmLocalGenerator;
|
||||
class cmMakefile;
|
||||
class cmOutputConverter;
|
||||
class cmState;
|
||||
class cmStateDirectory;
|
||||
class cmake;
|
||||
struct cmDocumentationEntry;
|
||||
@@ -647,8 +646,6 @@ public:
|
||||
|
||||
std::string GetDefaultBuildConfig() const override;
|
||||
|
||||
bool ReadCacheEntriesForBuild(const cmState& state) override;
|
||||
|
||||
bool SupportsDefaultBuildType() const override { return true; }
|
||||
bool SupportsCrossConfigs() const override { return true; }
|
||||
bool SupportsDefaultConfigs() const override { return true; }
|
||||
|
||||
Reference in New Issue
Block a user