diff options
author | Greg Fiumara <greg@gregfiumara.com> | 2021-11-16 16:39:34 -0500 |
---|---|---|
committer | Greg Fiumara <greg@gregfiumara.com> | 2021-11-18 13:01:35 -0500 |
commit | 7213ceb869bfe50acda93eaeab9f3d928f517cd8 (patch) | |
tree | 56cbbbfd63b4863de08ee5b425eea903da7747af /Source/CPack | |
parent | d98b61c68770150e4773ce30eb8145ad487016da (diff) | |
download | cmake-7213ceb869bfe50acda93eaeab9f3d928f517cd8.tar.gz |
CPack/productbuild: Add option to customize product identifier
This adds a new option, CPACK_PRODUCTBUILD_IDENTIFIER, which allows
for customization of the productbuild product identifier within the
CPack productbuild generator.
Fixes: #20830
Diffstat (limited to 'Source/CPack')
-rw-r--r-- | Source/CPack/cmCPackPKGGenerator.cxx | 11 | ||||
-rw-r--r-- | Source/CPack/cmCPackProductBuildGenerator.cxx | 14 |
2 files changed, 20 insertions, 5 deletions
diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index 91adf321e7..b62fab8e6d 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -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"); diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx index f55b8def05..4ad616dc28 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.cxx +++ b/Source/CPack/cmCPackProductBuildGenerator.cxx @@ -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; |