mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Merge topic 'improve-install-code-script'
2673161b67 install: Improve documentation, argument parsing
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12501
This commit is contained in:
@@ -841,7 +841,7 @@ Signatures
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
install([[SCRIPT <file>] [CODE <code>]]
|
||||
install({ SCRIPT <file> | CODE <code> }...
|
||||
[ALL_COMPONENTS | COMPONENT <component>]
|
||||
[EXCLUDE_FROM_ALL])
|
||||
|
||||
|
||||
@@ -923,14 +923,8 @@ bool HandleScriptMode(std::vector<std::string> const& args,
|
||||
return ArgumentParser::Continue::No;
|
||||
}
|
||||
|
||||
ArgumentParser::Continue AddComponent(cm::string_view value)
|
||||
{
|
||||
this->Components.emplace_back(value);
|
||||
return ArgumentParser::Continue::No;
|
||||
}
|
||||
|
||||
std::vector<Script> Scripts;
|
||||
std::vector<std::string> Components;
|
||||
cm::optional<std::string> Component;
|
||||
bool ExcludeFromAll = false;
|
||||
bool AllComponents = false;
|
||||
};
|
||||
@@ -939,7 +933,7 @@ bool HandleScriptMode(std::vector<std::string> const& args,
|
||||
cmArgumentParser<Arguments>{}
|
||||
.Bind("SCRIPT"_s, &Arguments::AddScript)
|
||||
.Bind("CODE"_s, &Arguments::AddScript)
|
||||
.Bind("COMPONENT"_s, &Arguments::AddComponent)
|
||||
.Bind("COMPONENT"_s, &Arguments::Component)
|
||||
.Bind("EXCLUDE_FROM_ALL"_s, &Arguments::ExcludeFromAll)
|
||||
.Bind("ALL_COMPONENTS"_s, &Arguments::AllComponents);
|
||||
|
||||
@@ -949,22 +943,15 @@ bool HandleScriptMode(std::vector<std::string> const& args,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (arguments.Components.size() > 1) {
|
||||
status.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;
|
||||
}
|
||||
|
||||
if (arguments.AllComponents && !arguments.Components.empty()) {
|
||||
if (arguments.AllComponents && arguments.Component.has_value()) {
|
||||
status.SetError("ALL_COMPONENTS and COMPONENT are mutually exclusive");
|
||||
return false;
|
||||
}
|
||||
|
||||
Helper helper(status);
|
||||
std::string const component = arguments.Components.empty()
|
||||
? helper.DefaultComponentName
|
||||
: arguments.Components.front();
|
||||
std::string const component = arguments.Component.has_value()
|
||||
? *arguments.Component
|
||||
: helper.DefaultComponentName;
|
||||
|
||||
for (Arguments::Script& script : arguments.Scripts) {
|
||||
if (!script.IsCode &&
|
||||
|
||||
@@ -36,14 +36,6 @@ Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
|
||||
|
||||
CMake Error at SCRIPT-CODE-arguments\.cmake:[0-9]+ \(install\):
|
||||
install given more than one COMPONENT for the SCRIPT or CODE signature of
|
||||
the INSTALL command\. Use multiple INSTALL commands with one COMPONENT
|
||||
each\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
|
||||
|
||||
CMake Error at SCRIPT-CODE-arguments\.cmake:[0-9]+ \(install\):
|
||||
install ALL_COMPONENTS and COMPONENT are mutually exclusive
|
||||
Call Stack \(most recent call first\):
|
||||
|
||||
Reference in New Issue
Block a user