mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
Use cascading-if for per-config test and install code
When generating per-config blocks in test and install scripts replace
the form
IF()
# config == A
ENDIF()
IF()
# config == B
ENDIF()
with
IF()
# config == A
ELSEIF()
# config == B
ELSE()
# no config matches
ENDIF()
for clarity and to support the else() case cleanly.
This commit is contained in:
@@ -209,6 +209,7 @@ void cmScriptGenerator::GenerateScriptActionsPerConfig(std::ostream& os,
|
||||
// In a multi-configuration generator we produce a separate rule
|
||||
// in a block for each configuration that is built. We restrict
|
||||
// the list of configurations to those to which this rule applies.
|
||||
bool first = true;
|
||||
for(std::vector<std::string>::const_iterator i =
|
||||
this->ConfigurationTypes->begin();
|
||||
i != this->ConfigurationTypes->end(); ++i)
|
||||
@@ -218,10 +219,19 @@ void cmScriptGenerator::GenerateScriptActionsPerConfig(std::ostream& os,
|
||||
{
|
||||
// Generate a per-configuration block.
|
||||
std::string config_test = this->CreateConfigTest(config);
|
||||
os << indent << "IF(" << config_test << ")\n";
|
||||
os << indent << (first? "IF(" : "ELSEIF(") << config_test << ")\n";
|
||||
this->GenerateScriptForConfig(os, config, indent.Next());
|
||||
os << indent << "ENDIF(" << config_test << ")\n";
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
if(!first)
|
||||
{
|
||||
if(this->NeedsScriptNoConfig())
|
||||
{
|
||||
os << indent << "ELSE()\n";
|
||||
this->GenerateScriptNoConfig(os, indent.Next());
|
||||
}
|
||||
os << indent << "ENDIF()\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user