diff options
author | Brad King <brad.king@kitware.com> | 2011-06-10 12:48:20 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2011-06-10 13:25:46 (GMT) |
commit | 77ddb6a0cd35996f1329d727a25de3460f6aa899 (patch) | |
tree | 8d1599e0c93ac466c18650d1fc41c72d1af19d4f /Source | |
parent | 9ccefd55c5db49a0ddb518a7d1a2986def1ec55e (diff) | |
download | CMake-77ddb6a0cd35996f1329d727a25de3460f6aa899.zip CMake-77ddb6a0cd35996f1329d727a25de3460f6aa899.tar.gz CMake-77ddb6a0cd35996f1329d727a25de3460f6aa899.tar.bz2 |
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.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmScriptGenerator.cxx | 14 | ||||
-rw-r--r-- | Source/cmScriptGenerator.h | 2 |
2 files changed, 14 insertions, 2 deletions
diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx index 86ecebe..cabe98a 100644 --- a/Source/cmScriptGenerator.cxx +++ b/Source/cmScriptGenerator.cxx @@ -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"; + } } } diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h index e2a0da5..8b2ca33 100644 --- a/Source/cmScriptGenerator.h +++ b/Source/cmScriptGenerator.h @@ -65,6 +65,8 @@ protected: virtual void GenerateScriptForConfig(std::ostream& os, const char* config, Indent const& indent); + virtual void GenerateScriptNoConfig(std::ostream&, Indent const&) {} + virtual bool NeedsScriptNoConfig() const { return false; } // Test if this generator does something for a given configuration. bool GeneratesForConfig(const char*); |