summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorNils Gladitz <n.gladitz@abberior-instruments.com>2021-05-19 08:15:16 (GMT)
committerNils Gladitz <n.gladitz@abberior-instruments.com>2021-05-19 17:17:58 (GMT)
commit99ff75455ece5ec4add771a2de93b237ab858d08 (patch)
tree49f27c52bcec9b415c054ac80d3643fa03756a33 /Source
parent82fd8b6ba36658705fc55bc40df0b6b6ec80b773 (diff)
downloadCMake-99ff75455ece5ec4add771a2de93b237ab858d08.zip
CMake-99ff75455ece5ec4add771a2de93b237ab858d08.tar.gz
CMake-99ff75455ece5ec4add771a2de93b237ab858d08.tar.bz2
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.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFileAPICodemodel.cxx5
-rw-r--r--Source/cmInstallCommand.cxx12
-rw-r--r--Source/cmInstallDirectoryGenerator.cxx2
-rw-r--r--Source/cmInstallExportGenerator.cxx2
-rw-r--r--Source/cmInstallFilesGenerator.cxx2
-rw-r--r--Source/cmInstallGenerator.cxx18
-rw-r--r--Source/cmInstallGenerator.h5
-rw-r--r--Source/cmInstallScriptGenerator.cxx5
-rw-r--r--Source/cmInstallScriptGenerator.h2
-rw-r--r--Source/cmInstallSubdirectoryGenerator.cxx2
-rw-r--r--Source/cmInstallTargetGenerator.cxx2
-rw-r--r--Source/cmLocalGenerator.cxx4
12 files changed, 42 insertions, 19 deletions
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx
index 6b35842..945b547 100644
--- a/Source/cmFileAPICodemodel.cxx
+++ b/Source/cmFileAPICodemodel.cxx
@@ -1016,6 +1016,11 @@ Json::Value DirectoryObject::DumpInstaller(cmInstallGenerator* gen)
if (gen->GetExcludeFromAll()) {
installer["isExcludeFromAll"] = true;
}
+
+ if (gen->GetAllComponentsFlag()) {
+ installer["isForAllComponents"] = true;
+ }
+
this->AddBacktrace(installer, gen->GetBacktrace());
return installer;
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index d5d6d93..e973764 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -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()));
}
}
diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx
index 4eb5f69..86362e4 100644
--- a/Source/cmInstallDirectoryGenerator.cxx
+++ b/Source/cmInstallDirectoryGenerator.cxx
@@ -18,7 +18,7 @@ cmInstallDirectoryGenerator::cmInstallDirectoryGenerator(
MessageLevel message, bool exclude_from_all, std::string literal_args,
bool optional, cmListFileBacktrace backtrace)
: cmInstallGenerator(dest, configurations, component, message,
- exclude_from_all, std::move(backtrace))
+ exclude_from_all, false, std::move(backtrace))
, LocalGenerator(nullptr)
, Directories(dirs)
, FilePermissions(std::move(file_permissions))
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index fdc3f8c..ccefd92 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -26,7 +26,7 @@ cmInstallExportGenerator::cmInstallExportGenerator(
std::string filename, std::string name_space, bool exportOld, bool android,
cmListFileBacktrace backtrace)
: cmInstallGenerator(destination, configurations, component, message,
- exclude_from_all, std::move(backtrace))
+ exclude_from_all, false, std::move(backtrace))
, ExportSet(exportSet)
, FilePermissions(std::move(file_permissions))
, FileName(std::move(filename))
diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx
index 556c938..04aaa29 100644
--- a/Source/cmInstallFilesGenerator.cxx
+++ b/Source/cmInstallFilesGenerator.cxx
@@ -17,7 +17,7 @@ cmInstallFilesGenerator::cmInstallFilesGenerator(
MessageLevel message, bool exclude_from_all, std::string rename,
bool optional, cmListFileBacktrace backtrace)
: cmInstallGenerator(dest, configurations, component, message,
- exclude_from_all, std::move(backtrace))
+ exclude_from_all, false, std::move(backtrace))
, LocalGenerator(nullptr)
, Files(files)
, FilePermissions(std::move(file_permissions))
diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx
index 98e3766..cf5f45e 100644
--- a/Source/cmInstallGenerator.cxx
+++ b/Source/cmInstallGenerator.cxx
@@ -11,12 +11,13 @@
cmInstallGenerator::cmInstallGenerator(
std::string destination, std::vector<std::string> const& configurations,
std::string component, MessageLevel message, bool exclude_from_all,
- cmListFileBacktrace backtrace)
+ bool all_components, cmListFileBacktrace backtrace)
: cmScriptGenerator("CMAKE_INSTALL_CONFIG_NAME", configurations)
, Destination(std::move(destination))
, Component(std::move(component))
, Message(message)
, ExcludeFromAll(exclude_from_all)
+ , AllComponents(all_components)
, Backtrace(std::move(backtrace))
{
}
@@ -160,15 +161,20 @@ void cmInstallGenerator::GenerateScript(std::ostream& os)
Indent indent;
// Begin this block of installation.
- std::string component_test =
- this->CreateComponentTest(this->Component, this->ExcludeFromAll);
- os << indent << "if(" << component_test << ")\n";
+ if (!this->AllComponents) {
+ std::string component_test =
+ this->CreateComponentTest(this->Component, this->ExcludeFromAll);
+ os << indent << "if(" << component_test << ")\n";
+ }
// Generate the script possibly with per-configuration code.
- this->GenerateScriptConfigs(os, indent.Next());
+ this->GenerateScriptConfigs(os,
+ this->AllComponents ? indent : indent.Next());
// End this block of installation.
- os << indent << "endif()\n\n";
+ if (!this->AllComponents) {
+ os << indent << "endif()\n\n";
+ }
}
bool cmInstallGenerator::InstallsForConfig(const std::string& config)
diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h
index 6cd9ff9..0117617 100644
--- a/Source/cmInstallGenerator.h
+++ b/Source/cmInstallGenerator.h
@@ -33,7 +33,8 @@ public:
cmInstallGenerator(std::string destination,
std::vector<std::string> const& configurations,
std::string component, MessageLevel message,
- bool exclude_from_all, cmListFileBacktrace backtrace);
+ bool exclude_from_all, bool all_components,
+ cmListFileBacktrace backtrace);
~cmInstallGenerator() override;
cmInstallGenerator(cmInstallGenerator const&) = delete;
@@ -65,6 +66,7 @@ public:
std::string const& GetComponent() const { return this->Component; }
bool GetExcludeFromAll() const { return this->ExcludeFromAll; }
+ bool GetAllComponentsFlag() const { return this->AllComponents; }
cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; }
@@ -79,5 +81,6 @@ protected:
std::string const Component;
MessageLevel const Message;
bool const ExcludeFromAll;
+ bool const AllComponents;
cmListFileBacktrace const Backtrace;
};
diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx
index bb38990..bec98b6 100644
--- a/Source/cmInstallScriptGenerator.cxx
+++ b/Source/cmInstallScriptGenerator.cxx
@@ -14,9 +14,10 @@
cmInstallScriptGenerator::cmInstallScriptGenerator(
std::string script, bool code, std::string const& component,
- bool exclude_from_all, cmListFileBacktrace backtrace)
+ bool exclude_from_all, bool all_components, cmListFileBacktrace backtrace)
: cmInstallGenerator("", std::vector<std::string>(), component,
- MessageDefault, exclude_from_all, std::move(backtrace))
+ MessageDefault, exclude_from_all, all_components,
+ std::move(backtrace))
, Script(std::move(script))
, Code(code)
, AllowGenex(false)
diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h
index 6274f1c..2cf6a4b 100644
--- a/Source/cmInstallScriptGenerator.h
+++ b/Source/cmInstallScriptGenerator.h
@@ -21,7 +21,7 @@ class cmInstallScriptGenerator : public cmInstallGenerator
public:
cmInstallScriptGenerator(
std::string script, bool code, std::string const& component,
- bool exclude_from_all,
+ bool exclude_from_all, bool all_components,
cmListFileBacktrace backtrace = cmListFileBacktrace());
~cmInstallScriptGenerator() override;
diff --git a/Source/cmInstallSubdirectoryGenerator.cxx b/Source/cmInstallSubdirectoryGenerator.cxx
index 76806e5..0fcfa54 100644
--- a/Source/cmInstallSubdirectoryGenerator.cxx
+++ b/Source/cmInstallSubdirectoryGenerator.cxx
@@ -17,7 +17,7 @@ cmInstallSubdirectoryGenerator::cmInstallSubdirectoryGenerator(
cmMakefile* makefile, std::string binaryDirectory, bool excludeFromAll,
cmListFileBacktrace backtrace)
: cmInstallGenerator("", std::vector<std::string>(), "", MessageDefault,
- excludeFromAll, std::move(backtrace))
+ excludeFromAll, false, std::move(backtrace))
, Makefile(makefile)
, BinaryDirectory(std::move(binaryDirectory))
{
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index eb214fa..3e79ad8 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -46,7 +46,7 @@ cmInstallTargetGenerator::cmInstallTargetGenerator(
std::string const& component, MessageLevel message, bool exclude_from_all,
bool optional, cmListFileBacktrace backtrace)
: cmInstallGenerator(dest, configurations, component, message,
- exclude_from_all, std::move(backtrace))
+ exclude_from_all, false, std::move(backtrace))
, TargetName(std::move(targetName))
, Target(nullptr)
, FilePermissions(std::move(file_permissions))
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 4db9216..0c686aa 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -3317,7 +3317,7 @@ void cmLocalGenerator::GenerateTargetInstallRules(
// Include the user-specified pre-install script for this target.
if (cmProp preinstall = l->GetProperty("PRE_INSTALL_SCRIPT")) {
- cmInstallScriptGenerator g(*preinstall, false, "", false);
+ cmInstallScriptGenerator g(*preinstall, false, "", false, false);
g.Generate(os, config, configurationTypes);
}
@@ -3370,7 +3370,7 @@ void cmLocalGenerator::GenerateTargetInstallRules(
// Include the user-specified post-install script for this target.
if (cmProp postinstall = l->GetProperty("POST_INSTALL_SCRIPT")) {
- cmInstallScriptGenerator g(*postinstall, false, "", false);
+ cmInstallScriptGenerator g(*postinstall, false, "", false, false);
g.Generate(os, config, configurationTypes);
}
}