Merge topic 'cpack-productbuild-identifier'

7213ceb869 CPack/productbuild: Add option to customize product identifier

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6738
This commit is contained in:
Brad King
2021-11-22 16:26:28 +00:00
committed by Kitware Robot
4 changed files with 34 additions and 5 deletions

View File

@@ -18,6 +18,14 @@ macOS using ProductBuild:
the automatically detected command (or specify its location if the
auto-detection fails to find it).
.. variable:: CPACK_PRODUCTBUILD_IDENTIFIER
.. versionadded:: 3.23
Set the unique (non-localized) product identifier to be associated with the
product (i.e., ``com.kitware.cmake``). Any component product names will be
appended to this value.
.. variable:: CPACK_PRODUCTBUILD_IDENTITY_NAME
.. versionadded:: 3.8

View File

@@ -0,0 +1,6 @@
cpack-productbuild-identifier
-----------------------------
* The :cpack_gen:`CPack productbuild Generator` gained a new variable,
:variable:`CPACK_PRODUCTBUILD_IDENTIFIER`, used to customize the unique
product identifier associated with the product.

View File

@@ -210,9 +210,14 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponentGroup& group,
void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component,
cmXMLWriter& xout)
{
std::string packageId =
cmStrCat("com.", this->GetOption("CPACK_PACKAGE_VENDOR"), '.',
this->GetOption("CPACK_PACKAGE_NAME"), '.', component.Name);
std::string packageId;
if (cmValue i = this->GetOption("CPACK_PRODUCTBUILD_IDENTIFIER")) {
packageId = cmStrCat(i, '.', component.Name);
} else {
packageId =
cmStrCat("com.", this->GetOption("CPACK_PACKAGE_VENDOR"), '.',
this->GetOption("CPACK_PACKAGE_NAME"), '.', component.Name);
}
xout.StartElement("choice");
xout.Attribute("id", component.Name + "Choice");

View File

@@ -95,6 +95,10 @@ int cmCPackProductBuildGenerator::PackageFiles()
if (cmValue p = this->GetOption("CPACK_PRODUCTBUILD_KEYCHAIN_PATH")) {
keychainPath = p;
}
std::string identifier;
if (cmValue i = this->GetOption("CPACK_PRODUCTBUILD_IDENTIFIER")) {
identifier = i;
}
pkgCmd << productbuild << " --distribution \"" << packageDirFileName
<< "/Contents/distribution.dist\""
@@ -102,6 +106,7 @@ int cmCPackProductBuildGenerator::PackageFiles()
<< "\""
<< " --resources \"" << resDir << "\""
<< " --version \"" << version << "\""
<< (identifier.empty() ? "" : " --identifier \"" + identifier + "\"")
<< (identityName.empty() ? "" : " --sign \"" + identityName + "\"")
<< (keychainPath.empty() ? ""
: " --keychain \"" + keychainPath + "\"")
@@ -204,8 +209,13 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
// The command that will be used to run ProductBuild
std::ostringstream pkgCmd;
std::string pkgId = cmStrCat("com.", this->GetOption("CPACK_PACKAGE_VENDOR"),
'.', this->GetOption("CPACK_PACKAGE_NAME"));
std::string pkgId;
if (cmValue n = this->GetOption("CPACK_PRODUCTBUILD_IDENTIFIER")) {
pkgId = n;
} else {
pkgId = cmStrCat("com.", this->GetOption("CPACK_PACKAGE_VENDOR"), '.',
this->GetOption("CPACK_PACKAGE_NAME"));
}
if (component) {
pkgId += '.';
pkgId += component->Name;