cmake: Allow CMAKE_CONFIGURATION_TYPES to be set by environment variable

When no `CMAKE_CONFIGURATION_TYPES` is explicitly specified while
creating a new build tree, check for an environment variable of the same
name.

Issue: #20983
This commit is contained in:
Brad King
2021-06-29 16:58:16 -04:00
parent e216b9bbd3
commit ef56eefc9b
10 changed files with 40 additions and 2 deletions
+5 -1
View File
@@ -3187,8 +3187,12 @@ void cmMakefile::InitCMAKE_CONFIGURATION_TYPES(std::string const& genDefault)
if (this->GetDefinition("CMAKE_CONFIGURATION_TYPES")) {
return;
}
std::string initConfigs;
if (!cmSystemTools::GetEnv("CMAKE_CONFIGURATION_TYPES", initConfigs)) {
initConfigs = genDefault;
}
this->AddCacheDefinition(
"CMAKE_CONFIGURATION_TYPES", genDefault,
"CMAKE_CONFIGURATION_TYPES", initConfigs,
"Semicolon separated list of supported configuration types, "
"only supports Debug, Release, MinSizeRel, and RelWithDebInfo, "
"anything else will be ignored.",