summaryrefslogtreecommitdiffstats
path: root/Source/CPack
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-11-12 14:51:47 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-11-12 14:52:32 (GMT)
commitf59ae1a698561657afa32245f9c8f3fc90aa392d (patch)
tree15866420cd8c5f20e8b1f57761290584530b0e3b /Source/CPack
parentcea7f88a54f060b8c4720f0d20432f7cf4bd8d56 (diff)
parente6069613a111ff30e9bb9a0e7294b2ea9da574c1 (diff)
downloadCMake-f59ae1a698561657afa32245f9c8f3fc90aa392d.zip
CMake-f59ae1a698561657afa32245f9c8f3fc90aa392d.tar.gz
CMake-f59ae1a698561657afa32245f9c8f3fc90aa392d.tar.bz2
Merge topic 'cpack-pkg-background'
e6069613a1 CPack: Set background image in macOS installer Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3995
Diffstat (limited to 'Source/CPack')
-rw-r--r--Source/CPack/cmCPackPKGGenerator.cxx66
-rw-r--r--Source/CPack/cmCPackPKGGenerator.h8
-rw-r--r--Source/CPack/cmCPackPackageMakerGenerator.cxx2
-rw-r--r--Source/CPack/cmCPackProductBuildGenerator.cxx2
4 files changed, 74 insertions, 4 deletions
diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx
index 3e1a51b..328aac3 100644
--- a/Source/CPack/cmCPackPKGGenerator.cxx
+++ b/Source/CPack/cmCPackPKGGenerator.cxx
@@ -46,7 +46,66 @@ std::string cmCPackPKGGenerator::GetPackageName(
return component.ArchiveFile + ".pkg";
}
-void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)
+void cmCPackPKGGenerator::CreateBackground(const char* themeName,
+ const char* metapackageFile,
+ cm::string_view genName,
+ cmXMLWriter& xout)
+{
+ std::string paramSuffix =
+ (themeName == nullptr) ? "" : cmSystemTools::UpperCase(themeName);
+ std::string opt = (themeName == nullptr)
+ ? cmStrCat("CPACK_", genName, "_BACKGROUND")
+ : cmStrCat("CPACK_", genName, "_BACKGROUND_", paramSuffix);
+ const char* bgFileName = this->GetOption(opt);
+ if (bgFileName == nullptr) {
+ return;
+ }
+
+ std::string bgFilePath = cmStrCat(metapackageFile, "/Contents/", bgFileName);
+
+ if (!cmSystemTools::FileExists(bgFilePath)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Background image doesn't exist in the resource directory: "
+ << bgFileName << std::endl);
+ return;
+ }
+
+ if (themeName == nullptr) {
+ xout.StartElement("background");
+ } else {
+ xout.StartElement(cmStrCat("background-", themeName));
+ }
+
+ xout.Attribute("file", bgFileName);
+
+ const char* param = this->GetOption(cmStrCat(opt, "_ALIGNMENT"));
+ if (param != nullptr) {
+ xout.Attribute("alignment", param);
+ }
+
+ param = this->GetOption(cmStrCat(opt, "_SCALING"));
+ if (param != nullptr) {
+ xout.Attribute("scaling", param);
+ }
+
+ // Apple docs say that you must provide either mime-type or uti
+ // attribute for the background, but I've seen examples that
+ // doesn't have them, so don't make them mandatory.
+ param = this->GetOption(cmStrCat(opt, "_MIME_TYPE"));
+ if (param != nullptr) {
+ xout.Attribute("mime-type", param);
+ }
+
+ param = this->GetOption(cmStrCat(opt, "_UTI"));
+ if (param != nullptr) {
+ xout.Attribute("uti", param);
+ }
+
+ xout.EndElement();
+}
+
+void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile,
+ const char* genName)
{
std::string distributionTemplate =
this->FindTemplate("Internal/CPack/CPack.distribution.dist.in");
@@ -102,6 +161,11 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)
CreateChoice(PostFlightComponent, xout);
}
+ // default background
+ this->CreateBackground(nullptr, metapackageFile, genName, xout);
+ // Dark Aqua
+ this->CreateBackground("darkAqua", metapackageFile, genName, xout);
+
this->SetOption("CPACK_PACKAGEMAKER_CHOICES", choiceOut.str().c_str());
// Create the distribution.dist file in the metapackage to turn it
diff --git a/Source/CPack/cmCPackPKGGenerator.h b/Source/CPack/cmCPackPKGGenerator.h
index 69286ff..be730ab 100644
--- a/Source/CPack/cmCPackPKGGenerator.h
+++ b/Source/CPack/cmCPackPKGGenerator.h
@@ -9,6 +9,8 @@
#include <sstream>
#include <string>
+#include <cm/string_view>
+
#include "cmCPackComponentGroup.h"
#include "cmCPackGenerator.h"
@@ -57,7 +59,7 @@ protected:
// inter-component dependencies. metapackageFile is the name of the
// metapackage for the distribution. Only valid for a
// component-based install.
- void WriteDistributionFile(const char* metapackageFile);
+ void WriteDistributionFile(const char* metapackageFile, const char* genName);
// Subroutine of WriteDistributionFile that writes out the
// dependency attributes for inter-component dependencies.
@@ -85,6 +87,10 @@ protected:
/// installer GUI.
void CreateChoice(const cmCPackComponent& component, cmXMLWriter& xout);
+ /// Creates a background in the distribution XML.
+ void CreateBackground(const char* themeName, const char* metapackageFile,
+ cm::string_view genName, cmXMLWriter& xout);
+
// The PostFlight component when creating a metapackage
cmCPackComponent PostFlightComponent;
};
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx
index c5ba726..12ea97b 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.cxx
+++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx
@@ -279,7 +279,7 @@ int cmCPackPackageMakerGenerator::PackageFiles()
} else {
// We have built the package in place. Generate the
// distribution.dist file to describe it for the installer.
- WriteDistributionFile(packageDirFileName.c_str());
+ WriteDistributionFile(packageDirFileName.c_str(), "PACKAGEMAKER");
}
std::string tmpFile = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"),
diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx
index dae268c..a3e55de 100644
--- a/Source/CPack/cmCPackProductBuildGenerator.cxx
+++ b/Source/CPack/cmCPackProductBuildGenerator.cxx
@@ -81,7 +81,7 @@ int cmCPackProductBuildGenerator::PackageFiles()
}
// combine package(s) into a distribution
- WriteDistributionFile(packageDirFileName.c_str());
+ WriteDistributionFile(packageDirFileName.c_str(), "PRODUCTBUILD");
std::ostringstream pkgCmd;
std::string version = this->GetOption("CPACK_PACKAGE_VERSION");