From f25d87db9e406eda77aa62f583e1ceeb7b145381 Mon Sep 17 00:00:00 2001
From: Alexander Wittig <abgandar@gmail.com>
Date: Fri, 1 Dec 2017 06:14:43 -0500
Subject: CPack: Fix macOS PKG component dependency information

Refactoring in commit v3.7.0-rc1~523^2 (CPack/PackageMaker: port to
cmXMLWriter, 2016-06-08) accidentally broke `distribution.dist`
generation when there are dependencies between components and the pkg
(or the derived productbuild) generator are used.  The resulting
package cannot be installed and instead the Apple Installer app
shows a "Javascript error" message.

The problem is that a `std::ostringstream` is constructed with some
content, but the stream pointer still points to the beginning of the
stream, so subsequent writes overwrite the initial content instead of
appending.
---
 Source/CPack/cmCPackPKGGenerator.cxx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx
index 4f5b2a0..9ea8540 100644
--- a/Source/CPack/cmCPackPKGGenerator.cxx
+++ b/Source/CPack/cmCPackPKGGenerator.cxx
@@ -189,7 +189,7 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component,
     // This way, selecting C will automatically select everything it depends
     // on (B and A), while selecting something that depends on C--either D
     // or E--will automatically cause C to get selected.
-    std::ostringstream selected("my.choice.selected");
+    std::ostringstream selected("my.choice.selected", std::ios_base::ate);
     std::set<const cmCPackComponent*> visited;
     AddDependencyAttributes(component, visited, selected);
     visited.clear();
-- 
cgit v0.12