diff options
author | David Cole <david.cole@kitware.com> | 2007-10-15 11:08:15 (GMT) |
---|---|---|
committer | David Cole <david.cole@kitware.com> | 2007-10-15 11:08:15 (GMT) |
commit | c8e832dcf5d1477192e19bf521f684c953d7751d (patch) | |
tree | d7a828f9c03d484a1689483454674d7f635e13ca /Source | |
parent | fa513be6579b1b5074418aa1fe099e91eb0c8c55 (diff) | |
download | CMake-c8e832dcf5d1477192e19bf521f684c953d7751d.zip CMake-c8e832dcf5d1477192e19bf521f684c953d7751d.tar.gz CMake-c8e832dcf5d1477192e19bf521f684c953d7751d.tar.bz2 |
BUG: Fix #5868 - add COMPONENT handling to the SCRIPT and CODE signatures of the INSTALL command.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmInstallCommand.cxx | 59 | ||||
-rw-r--r-- | Source/cmInstallScriptGenerator.cxx | 16 | ||||
-rw-r--r-- | Source/cmInstallScriptGenerator.h | 3 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 4 |
4 files changed, 64 insertions, 18 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 6696629..6a645da 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -99,8 +99,34 @@ bool cmInstallCommand::InitialPass(std::vector<std::string> const& args) //---------------------------------------------------------------------------- bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) { + std::string component("Unspecified"); + int componentCount = 0; bool doing_script = false; bool doing_code = false; + + // Scan the args once for COMPONENT. Only allow one. + // + for(size_t i=0; i < args.size(); ++i) + { + if(args[i] == "COMPONENT" && i+1 < args.size()) + { + ++componentCount; + ++i; + component = args[i]; + } + } + + if(componentCount>1) + { + this->SetError("given more than one COMPONENT for the SCRIPT or CODE " + "signature of the INSTALL command. " + "Use multiple INSTALL commands with one COMPONENT each."); + return false; + } + + // Scan the args again, this time adding install generators each time we + // encounter a SCRIPT or CODE arg: + // for(size_t i=0; i < args.size(); ++i) { if(args[i] == "SCRIPT") @@ -113,6 +139,11 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) doing_script = false; doing_code = true; } + else if(args[i] == "COMPONENT") + { + doing_script = false; + doing_code = false; + } else if(doing_script) { doing_script = false; @@ -129,16 +160,17 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) return false; } this->Makefile->AddInstallGenerator( - new cmInstallScriptGenerator(script.c_str())); + new cmInstallScriptGenerator(script.c_str(), false, component.c_str())); } else if(doing_code) { doing_code = false; std::string code = args[i]; this->Makefile->AddInstallGenerator( - new cmInstallScriptGenerator(code.c_str(), true)); + new cmInstallScriptGenerator(code.c_str(), true, component.c_str())); } } + if(doing_script) { this->SetError("given no value for SCRIPT argument."); @@ -149,6 +181,11 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) this->SetError("given no value for CODE argument."); return false; } + + //Tell the global generator about any installation component names specified. + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(component.c_str()); + return true; } @@ -169,15 +206,15 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) cmCommandArgumentsHelper argHelper; cmCommandArgumentGroup group; - cmCAStringVector genericArgVector (&argHelper, 0); - cmCAStringVector archiveArgVector (&argHelper, "ARCHIVE", &group); - cmCAStringVector libraryArgVector (&argHelper, "LIBRARY", &group); - cmCAStringVector runtimeArgVector (&argHelper, "RUNTIME", &group); - cmCAStringVector frameworkArgVector (&argHelper, "FRAMEWORK", &group); - cmCAStringVector bundleArgVector (&argHelper, "BUNDLE", &group); - cmCAStringVector privateHeaderArgVector(&argHelper,"PRIVATE_HEADER", &group); - cmCAStringVector publicHeaderArgVector(&argHelper, "PUBLIC_HEADER", &group); - cmCAStringVector resourceArgVector (&argHelper, "RESOURCE", &group); + cmCAStringVector genericArgVector (&argHelper,0); + cmCAStringVector archiveArgVector (&argHelper,"ARCHIVE",&group); + cmCAStringVector libraryArgVector (&argHelper,"LIBRARY",&group); + cmCAStringVector runtimeArgVector (&argHelper,"RUNTIME",&group); + cmCAStringVector frameworkArgVector (&argHelper,"FRAMEWORK",&group); + cmCAStringVector bundleArgVector (&argHelper,"BUNDLE",&group); + cmCAStringVector privateHeaderArgVector(&argHelper,"PRIVATE_HEADER",&group); + cmCAStringVector publicHeaderArgVector (&argHelper,"PUBLIC_HEADER",&group); + cmCAStringVector resourceArgVector (&argHelper,"RESOURCE",&group); genericArgVector.Follows(0); group.Follows(&genericArgVector); diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index ca4cbbb..b7e63de 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -18,8 +18,9 @@ //---------------------------------------------------------------------------- cmInstallScriptGenerator -::cmInstallScriptGenerator(const char* script, bool code): - cmInstallGenerator(0, std::vector<std::string>(), 0), +::cmInstallScriptGenerator(const char* script, bool code, + const char* component) : + cmInstallGenerator(0, std::vector<std::string>(), component), Script(script), Code(code) { } @@ -33,12 +34,19 @@ cmInstallScriptGenerator //---------------------------------------------------------------------------- void cmInstallScriptGenerator::GenerateScript(std::ostream& os) { + Indent indent; + std::string component_test = + this->CreateComponentTest(this->Component.c_str()); + os << indent << "IF(" << component_test << ")\n"; + if(this->Code) { - os << this->Script << "\n"; + os << indent.Next() << this->Script << "\n"; } else { - os << "INCLUDE(\"" << this->Script << "\")\n"; + os << indent.Next() << "INCLUDE(\"" << this->Script << "\")\n"; } + + os << indent << "ENDIF(" << component_test << ")\n\n"; } diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h index 2e9461a..bbe2677 100644 --- a/Source/cmInstallScriptGenerator.h +++ b/Source/cmInstallScriptGenerator.h @@ -25,7 +25,8 @@ class cmInstallScriptGenerator: public cmInstallGenerator { public: - cmInstallScriptGenerator(const char* script, bool code = false); + cmInstallScriptGenerator(const char* script, bool code, + const char* component); virtual ~cmInstallScriptGenerator(); protected: diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3c20cf8..acaaad5 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2419,7 +2419,7 @@ cmLocalGenerator // Include the user-specified pre-install script for this target. if(const char* preinstall = l->second.GetProperty("PRE_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(preinstall); + cmInstallScriptGenerator g(preinstall, false, 0); g.Generate(os, config, configurationTypes); } @@ -2472,7 +2472,7 @@ cmLocalGenerator // Include the user-specified post-install script for this target. if(const char* postinstall = l->second.GetProperty("POST_INSTALL_SCRIPT")) { - cmInstallScriptGenerator g(postinstall); + cmInstallScriptGenerator g(postinstall, false, 0); g.Generate(os, config, configurationTypes); } } |