mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
install: Implement new install(CODE|SCRIPT) option ALL_COMPONENTS
In a per-component installation the generated installation scripts are invoked once for each component. Per default custom installation script code added by install(CODE|SCRIPT) only runs for one specific component in this context. The new ALL_COMPONENTS option allows custom script code to be run once for each component being installed.
This commit is contained in:
@@ -161,6 +161,7 @@ bool HandleScriptMode(std::vector<std::string> const& args,
|
||||
bool doing_script = false;
|
||||
bool doing_code = false;
|
||||
bool exclude_from_all = false;
|
||||
bool all_components = false;
|
||||
|
||||
// Scan the args once for COMPONENT. Only allow one.
|
||||
//
|
||||
@@ -172,6 +173,8 @@ bool HandleScriptMode(std::vector<std::string> const& args,
|
||||
}
|
||||
if (args[i] == "EXCLUDE_FROM_ALL") {
|
||||
exclude_from_all = true;
|
||||
} else if (args[i] == "ALL_COMPONENTS") {
|
||||
all_components = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,6 +185,11 @@ bool HandleScriptMode(std::vector<std::string> const& args,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (all_components && componentCount == 1) {
|
||||
status.SetError("ALL_COMPONENTS and COMPONENT are mutually exclusive");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Scan the args again, this time adding install generators each time we
|
||||
// encounter a SCRIPT or CODE arg:
|
||||
//
|
||||
@@ -208,14 +216,14 @@ bool HandleScriptMode(std::vector<std::string> const& args,
|
||||
}
|
||||
helper.Makefile->AddInstallGenerator(
|
||||
cm::make_unique<cmInstallScriptGenerator>(
|
||||
script, false, component, exclude_from_all,
|
||||
script, false, component, exclude_from_all, all_components,
|
||||
helper.Makefile->GetBacktrace()));
|
||||
} else if (doing_code) {
|
||||
doing_code = false;
|
||||
std::string const& code = arg;
|
||||
helper.Makefile->AddInstallGenerator(
|
||||
cm::make_unique<cmInstallScriptGenerator>(
|
||||
code, true, component, exclude_from_all,
|
||||
code, true, component, exclude_from_all, all_components,
|
||||
helper.Makefile->GetBacktrace()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user