CPack/IFW: Add option for ProductImages URLs

Add a `CPACK_IFW_PACKAGE_PRODUCT_IMAGE_URLS` variable for them.
This commit is contained in:
Julien Marrec
2024-09-05 17:03:38 +02:00
committed by Brad King
parent d58f90f628
commit 3331c7032f
4 changed files with 47 additions and 1 deletions

View File

@@ -275,6 +275,16 @@ Package
This feature is available for QtIFW 4.0.0 and later.
.. variable:: CPACK_IFW_PACKAGE_PRODUCT_IMAGE_URLS
.. versionadded:: 3.31
A list of URLs associated with the ProductImages.
Only used if ``CPACK_IFW_PACKAGE_PRODUCT_IMAGES`` is defined
and it has the same size.
This feature is available for QtIFW 4.0.0 and later.
.. variable:: CPACK_IFW_PACKAGE_RUN_PROGRAM
.. versionadded:: 3.23

View File

@@ -0,0 +1,8 @@
cpack-ifw-product-images
------------------------
* The :cpack_gen:`CPack IFW Generator` gained the new
:variable:`CPACK_IFW_PACKAGE_PRODUCT_IMAGE_URLS` variable to
specify images associated with entries of
:variable:`CPACK_IFW_PACKAGE_PRODUCT_IMAGES`.
This feature is available for QtIFW 4.0 and newer.

View File

@@ -323,6 +323,25 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
this->ProductImages.end());
}
if (!this->ProductImages.empty()) {
if (cmValue productUrls =
this->GetOption("CPACK_IFW_PACKAGE_PRODUCT_IMAGE_URLS")) {
this->ProductImageUrls.clear();
cmExpandList(productUrls, this->ProductImageUrls);
if (this->ProductImageUrls.size() != this->ProductImages.size()) {
cmCPackIFWLogger(
WARNING,
"Option \"CPACK_IFW_PACKAGE_PRODUCT_IMAGE_URLS\" will be skipped "
"because it contains "
<< this->ProductImageUrls.size()
<< " elements while \"CPACK_IFW_PACKAGE_PRODUCT_IMAGES\" "
"contains "
<< this->ProductImages.size() << " elements." << std::endl);
this->ProductImageUrls.clear();
}
}
}
// Run program, run program arguments, and run program description
if (cmValue program = this->GetOption("CPACK_IFW_PACKAGE_RUN_PROGRAM")) {
this->RunProgram = *program;
@@ -621,12 +640,17 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
// Product images (copy to config dir)
if (!this->IsVersionLess("4.0") && !this->ProductImages.empty()) {
xout.StartElement("ProductImages");
for (auto const& srcImg : this->ProductImages) {
const bool hasProductImageUrl = !this->ProductImageUrls.empty();
for (size_t i = 0; i < this->ProductImages.size(); ++i) {
xout.StartElement("ProductImage");
auto const& srcImg = this->ProductImages[i];
std::string name = cmSystemTools::GetFilenameName(srcImg);
std::string dstImg = this->Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(srcImg, dstImg);
xout.Element("Image", name);
if (hasProductImageUrl) {
xout.Element("Url", this->ProductImageUrls.at(i));
}
xout.EndElement(); // </ProductImage>
}
xout.EndElement(); // </ProductImages>

View File

@@ -124,6 +124,10 @@ public:
/// A list of images to be shown on PerformInstallationPage.
std::vector<std::string> ProductImages;
/// A list of associated URLs linked to images to be shown on
/// PerformInstallationPage.
std::vector<std::string> ProductImageUrls;
/// Command executed after the installer is done if the user accepts the
/// action
std::string RunProgram;