[Cmake-commits] CMake branch, next, updated. v2.8.8-3505-ga02e4bf

Peter Kuemmel syntheticpp at gmx.net
Tue Jul 17 08:08:04 EDT 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  a02e4bfe697e72306ca59e9e59f399ce0658878c (commit)
       via  c3988ee871c99e31ad4d10e9033d89da902d5694 (commit)
       via  f8e0a5109f104e894f450049a6c97f53bd378dae (commit)
       via  f36c7b0bbe79592c7540740fe9cef747346ae2a4 (commit)
       via  5d885db416a4cec236ba6422868dc3db3d766bc4 (commit)
       via  3b2a01e80ef0faf626afd4c5031395c00e1c9ecd (commit)
       via  7bb56c511eaabf2071cd311b6cf14453651127e4 (commit)
       via  03bdaf545369d4438a8aece8d3cec603d3a99727 (commit)
       via  54d9713adb016423d20c610163726f80da435588 (commit)
       via  10686a17f4457fd6032543992538850be5cc8d88 (commit)
       via  a1b803349b51a9a814cd8e309832991306ef2cf0 (commit)
       via  3ba74ad9d586816f7c60cc6f527148edf982871c (commit)
       via  aff0029ee3d6be52f9fefc00c2ca416459a38b32 (commit)
       via  a7b4e3a57b418aa4569cf3bbd484212e9b9b5c77 (commit)
       via  21f156c03bec7595b58862a58a3446ec453f7d85 (commit)
       via  cdfa14a4f5a1432383c379baf741a713a198809a (commit)
       via  f478b52cd0f3b116c32d6218198ba8c77c555e8b (commit)
      from  57b08342143d28ba54b33427af7067b8e1f2d946 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a02e4bfe697e72306ca59e9e59f399ce0658878c
commit a02e4bfe697e72306ca59e9e59f399ce0658878c
Merge: 57b0834 c3988ee
Author:     Peter Kuemmel <syntheticpp at gmx.net>
AuthorDate: Tue Jul 17 08:07:58 2012 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Jul 17 08:07:58 2012 -0400

    Merge topic 'ninja-fix-macosx' into next
    
    c3988ee Re-factor OS X content generator start up.
    f8e0a51 Re-factor framework directory computation.
    f36c7b0 Re-factor Mac OS X content directory computation.
    5d885db Re-factor bundle content copying rules generation.
    3b2a01e Ninja: Use same echo message as makefiles.
    7bb56c5 Re-factor CFBundle generation.
    03bdaf5 Enable BundleTest with CLang too.
    54d9713 Ninja: Add support for CFBundle.
    10686a1 Ninja: Copy resource files in the bundle.
    a1b8033 Re-factor OS X bundle and framework generation.
    3ba74ad Remove trailing white-spaces.
    aff0029 Ensure 3rd party libraries are writable.
    a7b4e3a Ninja: Add support for OX X library framework.
    21f156c Ninja: Add support for OS X app bundles.
    cdfa14a CMake Nightly Date Stamp
    f478b52 CMake Nightly Date Stamp


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c3988ee871c99e31ad4d10e9033d89da902d5694
commit c3988ee871c99e31ad4d10e9033d89da902d5694
Author:     Nicolas Despres <nicolas.despres at gmail.com>
AuthorDate: Mon Jul 16 23:03:40 2012 +0200
Commit:     Peter Kümmel <syntheticpp at gmx.net>
CommitDate: Tue Jul 17 14:03:12 2012 +0200

    Re-factor OS X content generator start up.

diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 342fa49..bc016dc 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -367,18 +367,8 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()
     return;
     }
 
-  // Construct the full path to the content subdirectory.
-  std::string macdir = this->Generator->MacContentDirectory;
-  macdir += pkgloc;
-  cmSystemTools::MakeDirectory(macdir.c_str());
-
-  // Record use of this content location.  Only the first level
-  // directory is needed.
-  {
-  std::string loc = pkgloc;
-  loc = loc.substr(0, loc.find('/'));
-  this->Generator->MacContentFolders.insert(loc);
-  }
+  std::string macdir =
+    this->Generator->OSXBundleGenerator->InitMacOSXContentDirectory(pkgloc);
 
   // Get the input file location.
   std::string input = source.GetFullPath();
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 2c7bffc..36eb64d 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -664,19 +664,8 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
     return;
     }
 
-  // Construct the full path to the content subdirectory.
   std::string macdir =
-    this->Generator->OSXBundleGenerator->GetMacContentDirectory();
-  macdir += pkgloc;
-  cmSystemTools::MakeDirectory(macdir.c_str());
-
-  // Record use of this content location.  Only the first level
-  // directory is needed.
-  {
-  std::string loc = pkgloc;
-  loc = loc.substr(0, loc.find('/'));
-  this->Generator->MacContentFolders.insert(loc);
-  }
+    this->Generator->OSXBundleGenerator->InitMacOSXContentDirectory(pkgloc);
 
   // Get the input file location.
   std::string input = source.GetFullPath();
diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
index c5a8d5f..7d8df59 100644
--- a/Source/cmOSXBundleGenerator.cxx
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -214,3 +214,23 @@ GenerateMacOSXContentStatements(std::vector<cmSourceFile*> const& sources,
       }
     }
 }
+
+//----------------------------------------------------------------------------
+std::string
+cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc)
+{
+  // Construct the full path to the content subdirectory.
+  std::string macdir = this->MacContentDirectory;
+  macdir += pkgloc;
+  cmSystemTools::MakeDirectory(macdir.c_str());
+
+  // Record use of this content location.  Only the first level
+  // directory is needed.
+  {
+  std::string loc = pkgloc;
+  loc = loc.substr(0, loc.find('/'));
+  this->MacContentFolders->insert(loc);
+  }
+
+  return macdir;
+}
diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h
index c13ca36..2ed9e91 100644
--- a/Source/cmOSXBundleGenerator.h
+++ b/Source/cmOSXBundleGenerator.h
@@ -44,6 +44,7 @@ public:
   void GenerateMacOSXContentStatements(
     std::vector<cmSourceFile*> const& sources,
     MacOSXContentGeneratorType* generator);
+  std::string InitMacOSXContentDirectory(const char* pkgloc);
 
   std::string GetMacContentDirectory() const
   { return this->MacContentDirectory; }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f8e0a5109f104e894f450049a6c97f53bd378dae
commit f8e0a5109f104e894f450049a6c97f53bd378dae
Author:     Nicolas Despres <nicolas.despres at gmail.com>
AuthorDate: Mon Jul 16 19:44:19 2012 +0200
Commit:     Peter Kümmel <syntheticpp at gmx.net>
CommitDate: Tue Jul 17 14:03:11 2012 +0200

    Re-factor framework directory computation.

diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 490acb6..775662c 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -3688,10 +3688,7 @@ std::string cmTarget::GetInstallNameDirForBuildTree(const char* config,
     dir += "/";
     if(this->IsFrameworkOnApple() && !for_xcode)
       {
-      dir += this->GetFullName(config, false);
-      dir += ".framework/Versions/";
-      dir += this->GetFrameworkVersion();
-      dir += "/";
+      dir += this->GetFrameworkDirectory(config);
       }
     return dir;
     }
@@ -3722,10 +3719,7 @@ std::string cmTarget::GetInstallNameDirForInstallTree(const char* config,
 
     if(this->IsFrameworkOnApple() && !for_xcode)
       {
-      dir += this->GetFullName(config, false);
-      dir += ".framework/Versions/";
-      dir += this->GetFrameworkVersion();
-      dir += "/";
+      dir += this->GetFrameworkDirectory(config);
       }
 
     return dir;
@@ -4715,6 +4709,17 @@ std::vector<std::string> cmTarget::GetIncludeDirectories()
 }
 
 //----------------------------------------------------------------------------
+std::string cmTarget::GetFrameworkDirectory(const char* config)
+{
+  std::string fpath;
+  fpath += this->GetFullName(config, false);
+  fpath += ".framework/Versions/";
+  fpath += this->GetFrameworkVersion();
+  fpath += "/";
+  return fpath;
+}
+
+//----------------------------------------------------------------------------
 std::string cmTarget::BuildMacContentDirectory(const std::string& base,
                                                const char* config,
                                                bool includeMacOS)
@@ -4729,10 +4734,7 @@ std::string cmTarget::BuildMacContentDirectory(const std::string& base,
     }
   if(this->IsFrameworkOnApple())
     {
-    fpath += this->GetFullName(config, false);
-    fpath += ".framework/Versions/";
-    fpath += this->GetFrameworkVersion();
-    fpath += "/";
+    fpath += this->GetFrameworkDirectory(config);
     }
   if(this->IsCFBundleOnApple())
     {
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index aa14049..a89c5d9 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -478,6 +478,9 @@ public:
   /** @return whether this target have a well defined output file name. */
   bool HaveWellDefinedOutputFiles();
 
+  /** @return the Mac framework directory without the base. */
+  std::string GetFrameworkDirectory(const char* config = 0);
+
 private:
   /**
    * A list of direct dependencies. Use in conjunction with DependencyMap.

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f36c7b0bbe79592c7540740fe9cef747346ae2a4
commit f36c7b0bbe79592c7540740fe9cef747346ae2a4
Author:     Nicolas Despres <nicolas.despres at gmail.com>
AuthorDate: Mon Jul 16 19:42:56 2012 +0200
Commit:     Peter Kümmel <syntheticpp at gmx.net>
CommitDate: Tue Jul 17 14:03:11 2012 +0200

    Re-factor Mac OS X content directory computation.

diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
index 8788d42..c5a8d5f 100644
--- a/Source/cmOSXBundleGenerator.cxx
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -39,49 +39,36 @@ cmOSXBundleGenerator(cmTarget* target,
  , FrameworkVersion()
  , MacContentFolders(0)
 {
-  if(this->Target->IsAppBundleOnApple())
-    {
-    this->MacContentDirectory = this->Target->GetDirectory(this->ConfigName);
-    this->MacContentDirectory += "/";
-    this->MacContentDirectory += this->TargetNameOut;
-    this->MacContentDirectory += ".app/Contents/";
-    }
-  else if(this->Target->IsFrameworkOnApple())
-    {
+  if (this->MustSkip())
+    return;
+
+  this->MacContentDirectory =
+    this->Target->GetMacContentDirectory(this->ConfigName,
+                                         /*implib*/ false,
+                                         /*includeMacOS*/ false);
+  if(this->Target->IsFrameworkOnApple())
     this->FrameworkVersion = this->Target->GetFrameworkVersion();
-    this->MacContentDirectory = this->Target->GetDirectory(this->ConfigName);
-    this->MacContentDirectory += "/";
-    this->MacContentDirectory += this->TargetNameOut;
-    this->MacContentDirectory += ".framework/Versions/";
-    this->MacContentDirectory += this->FrameworkVersion;
-    this->MacContentDirectory += "/";
-    }
-  else if(this->Target->IsCFBundleOnApple())
-    {
-    this->MacContentDirectory = this->Target->GetDirectory(this->ConfigName);
-    this->MacContentDirectory += "/";
-    this->MacContentDirectory += this->TargetNameOut;
-    this->MacContentDirectory += ".";
-    const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION");
-    if (!ext)
-      {
-      ext = "bundle";
-      }
-    this->MacContentDirectory += ext;
-    this->MacContentDirectory += "/Contents/";
-    }
+}
+
+//----------------------------------------------------------------------------
+bool cmOSXBundleGenerator::MustSkip()
+{
+  return !this->Target->HaveWellDefinedOutputFiles();
 }
 
 //----------------------------------------------------------------------------
 void cmOSXBundleGenerator::CreateAppBundle(std::string& targetName,
                                            std::string& outpath)
 {
+  if (this->MustSkip())
+    return;
+
   // Compute bundle directory names.
   outpath = this->MacContentDirectory;
   outpath += "MacOS";
   cmSystemTools::MakeDirectory(outpath.c_str());
-  this->Makefile->AddCMakeOutputFile(outpath.c_str());
   outpath += "/";
+  this->Makefile->AddCMakeOutputFile(outpath.c_str());
 
   // Configure the Info.plist file.  Note that it needs the executable name
   // to be set.
@@ -95,6 +82,9 @@ void cmOSXBundleGenerator::CreateAppBundle(std::string& targetName,
 //----------------------------------------------------------------------------
 void cmOSXBundleGenerator::CreateFramework(std::string const& targetName)
 {
+  if (this->MustSkip())
+    return;
+
   assert(this->MacContentFolders);
 
   // Configure the Info.plist file into the Resources directory.
@@ -184,12 +174,15 @@ void cmOSXBundleGenerator::CreateFramework(std::string const& targetName)
 void cmOSXBundleGenerator::CreateCFBundle(std::string& targetName,
                                           std::string& outpath)
 {
+  if (this->MustSkip())
+    return;
+
   // Compute bundle directory names.
   outpath = this->MacContentDirectory;
   outpath += "MacOS";
   cmSystemTools::MakeDirectory(outpath.c_str());
-  this->Makefile->AddCMakeOutputFile(outpath.c_str());
   outpath += "/";
+  this->Makefile->AddCMakeOutputFile(outpath.c_str());
 
   // Configure the Info.plist file.  Note that it needs the executable name
   // to be set.
@@ -207,6 +200,9 @@ cmOSXBundleGenerator::
 GenerateMacOSXContentStatements(std::vector<cmSourceFile*> const& sources,
                                 MacOSXContentGeneratorType* generator)
 {
+  if (this->MustSkip())
+    return;
+
   for(std::vector<cmSourceFile*>::const_iterator
         si = sources.begin(); si != sources.end(); ++si)
     {
diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h
index dc6a8ae..c13ca36 100644
--- a/Source/cmOSXBundleGenerator.h
+++ b/Source/cmOSXBundleGenerator.h
@@ -53,6 +53,9 @@ public:
   { this->MacContentFolders = macContentFolders; }
 
 private:
+  bool MustSkip();
+
+private:
   cmTarget* Target;
   cmMakefile* Makefile;
   cmLocalGenerator* LocalGenerator;
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index aaa622f..490acb6 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -2483,6 +2483,16 @@ void cmTarget::MarkAsImported()
 }
 
 //----------------------------------------------------------------------------
+bool cmTarget::HaveWellDefinedOutputFiles()
+{
+  return
+    this->GetType() == cmTarget::STATIC_LIBRARY ||
+    this->GetType() == cmTarget::SHARED_LIBRARY ||
+    this->GetType() == cmTarget::MODULE_LIBRARY ||
+    this->GetType() == cmTarget::EXECUTABLE;
+}
+
+//----------------------------------------------------------------------------
 cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config)
 {
   // There is no output information for imported targets.
@@ -2492,10 +2502,7 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config)
     }
 
   // Only libraries and executables have well-defined output files.
-  if(this->GetType() != cmTarget::STATIC_LIBRARY &&
-     this->GetType() != cmTarget::SHARED_LIBRARY &&
-     this->GetType() != cmTarget::MODULE_LIBRARY &&
-     this->GetType() != cmTarget::EXECUTABLE)
+  if(!this->HaveWellDefinedOutputFiles())
     {
     std::string msg = "cmTarget::GetOutputInfo called for ";
     msg += this->GetName();
@@ -2586,18 +2593,7 @@ const char* cmTarget::NormalGetLocation(const char* config)
     this->Location += cfgid;
     this->Location += "/";
     }
-  if(this->IsAppBundleOnApple())
-    {
-    this->Location += this->GetFullName(config, false);
-    this->Location += ".app/Contents/MacOS/";
-    }
-   if(this->IsFrameworkOnApple())
-    {
-    this->Location += this->GetFullName(config, false);
-    this->Location += ".framework/Versions/";
-    this->Location += this->GetFrameworkVersion();
-    this->Location += "/";
-    }
+  this->Location = this->BuildMacContentDirectory(this->Location, config);
   this->Location += this->GetFullName(config, false);
   return this->Location.c_str();
 }
@@ -3169,35 +3165,7 @@ std::string cmTarget::GetFullPath(const char* config, bool implib,
 std::string cmTarget::NormalGetFullPath(const char* config, bool implib,
                                         bool realname)
 {
-  // TODO: Re-factor with cmOSXBundleGenerator's constructor.
-  // Start with the output directory for the target.
-  std::string fpath = this->GetDirectory(config, implib);
-  fpath += "/";
-
-  if(this->IsAppBundleOnApple())
-    {
-    fpath += this->GetFullName(config, false);
-    fpath += ".app/Contents/MacOS/";
-    }
-  if(this->IsFrameworkOnApple())
-    {
-    fpath += this->GetFullName(config, false);
-    fpath += ".framework/Versions/";
-    fpath += this->GetFrameworkVersion();
-    fpath += "/";
-    }
-  if(this->IsCFBundleOnApple())
-    {
-    fpath += this->GetFullName(config, false);
-    fpath += ".";
-    const char *ext = this->GetProperty("BUNDLE_EXTENSION");
-    if (!ext)
-      {
-      ext = "bundle";
-      }
-    fpath += ext;
-    fpath += "/Contents/MacOS/";
-    }
+  std::string fpath = this->GetMacContentDirectory(config, implib);
 
   // Add the full name of the target.
   if(implib)
@@ -4747,6 +4715,55 @@ std::vector<std::string> cmTarget::GetIncludeDirectories()
 }
 
 //----------------------------------------------------------------------------
+std::string cmTarget::BuildMacContentDirectory(const std::string& base,
+                                               const char* config,
+                                               bool includeMacOS)
+{
+  std::string fpath = base;
+  if(this->IsAppBundleOnApple())
+    {
+    fpath += this->GetFullName(config, false);
+    fpath += ".app/Contents/";
+    if(includeMacOS)
+      fpath += "MacOS/";
+    }
+  if(this->IsFrameworkOnApple())
+    {
+    fpath += this->GetFullName(config, false);
+    fpath += ".framework/Versions/";
+    fpath += this->GetFrameworkVersion();
+    fpath += "/";
+    }
+  if(this->IsCFBundleOnApple())
+    {
+    fpath += this->GetFullName(config, false);
+    fpath += ".";
+    const char *ext = this->GetProperty("BUNDLE_EXTENSION");
+    if (!ext)
+      {
+      ext = "bundle";
+      }
+    fpath += ext;
+    fpath += "/Contents/";
+    if(includeMacOS)
+      fpath += "MacOS/";
+    }
+  return fpath;
+}
+
+//----------------------------------------------------------------------------
+std::string cmTarget::GetMacContentDirectory(const char* config,
+                                             bool implib,
+                                             bool includeMacOS)
+{
+  // Start with the output directory for the target.
+  std::string fpath = this->GetDirectory(config, implib);
+  fpath += "/";
+  fpath = this->BuildMacContentDirectory(fpath, config, includeMacOS);
+  return fpath;
+}
+
+//----------------------------------------------------------------------------
 cmTargetLinkInformationMap
 ::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived()
 {
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index d70cacd..aa14049 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -465,6 +465,19 @@ public:
   /** Get the include directories for this target.  */
   std::vector<std::string> GetIncludeDirectories();
 
+  /** Append to @a base the mac content directory and return it. */
+  std::string BuildMacContentDirectory(const std::string& base,
+                                       const char* config = 0,
+                                       bool includeMacOS = true);
+
+  /** @return the mac content directory for this target. */
+  std::string GetMacContentDirectory(const char* config = 0,
+                                     bool implib = false,
+                                     bool includeMacOS = true);
+
+  /** @return whether this target have a well defined output file name. */
+  bool HaveWellDefinedOutputFiles();
+
 private:
   /**
    * A list of direct dependencies. Use in conjunction with DependencyMap.

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5d885db416a4cec236ba6422868dc3db3d766bc4
commit 5d885db416a4cec236ba6422868dc3db3d766bc4
Author:     Nicolas Despres <nicolas.despres at gmail.com>
AuthorDate: Mon Jul 16 17:34:22 2012 +0200
Commit:     Peter Kümmel <syntheticpp at gmx.net>
CommitDate: Tue Jul 17 14:03:10 2012 +0200

    Re-factor bundle content copying rules generation.

diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index d9ab334..ab5150a 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -18,13 +18,11 @@
 #include "cmSourceFile.h"
 #include "cmTarget.h"
 #include "cmake.h"
-#include "cmOSXBundleGenerator.h"
 
 //----------------------------------------------------------------------------
 cmMakefileExecutableTargetGenerator
 ::cmMakefileExecutableTargetGenerator(cmTarget* target):
-  cmMakefileTargetGenerator(target),
-  OSXBundleGenerator(0)
+  cmMakefileTargetGenerator(target)
 {
   this->CustomCommandDriver = OnDepends;
   this->Target->GetExecutableNames(
@@ -34,6 +32,7 @@ cmMakefileExecutableTargetGenerator
   this->OSXBundleGenerator = new cmOSXBundleGenerator(this->Target,
                                                       this->TargetNameOut,
                                                       this->ConfigName);
+  this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
   this->MacContentDirectory =
     this->OSXBundleGenerator->GetMacContentDirectory();
 }
diff --git a/Source/cmMakefileExecutableTargetGenerator.h b/Source/cmMakefileExecutableTargetGenerator.h
index 26dc72f..3b18166 100644
--- a/Source/cmMakefileExecutableTargetGenerator.h
+++ b/Source/cmMakefileExecutableTargetGenerator.h
@@ -14,8 +14,6 @@
 
 #include "cmMakefileTargetGenerator.h"
 
-class cmOSXBundleGenerator;
-
 class cmMakefileExecutableTargetGenerator: public cmMakefileTargetGenerator
 {
 public:
@@ -28,9 +26,6 @@ public:
 
 protected:
   virtual void WriteExecutableRule(bool relink);
-
-private:
-  cmOSXBundleGenerator* OSXBundleGenerator;
 };
 
 #endif
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index a655504..577e5fd 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -18,15 +18,13 @@
 #include "cmSourceFile.h"
 #include "cmTarget.h"
 #include "cmake.h"
-#include "cmOSXBundleGenerator.h"
 
 #include <memory> // auto_ptr
 
 //----------------------------------------------------------------------------
 cmMakefileLibraryTargetGenerator
 ::cmMakefileLibraryTargetGenerator(cmTarget* target):
-  cmMakefileTargetGenerator(target),
-  OSXBundleGenerator(0)
+  cmMakefileTargetGenerator(target)
 {
   cmOSXBundleGenerator::PrepareTargetProperties(this->Target);
 
diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h
index ee56f6c..07f828b 100644
--- a/Source/cmMakefileLibraryTargetGenerator.h
+++ b/Source/cmMakefileLibraryTargetGenerator.h
@@ -14,8 +14,6 @@
 
 #include "cmMakefileTargetGenerator.h"
 
-class cmOSXBundleGenerator;
-
 class cmMakefileLibraryTargetGenerator:
   public cmMakefileTargetGenerator
 {
@@ -42,9 +40,6 @@ protected:
 
   void AppendOSXVerFlag(std::string& flags, const char* lang,
                         const char* name, bool so);
-
-private:
-  cmOSXBundleGenerator* OSXBundleGenerator;
 };
 
 #endif
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 16e3e02..342fa49 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -28,6 +28,8 @@
 
 
 cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmTarget* target)
+  : OSXBundleGenerator(0)
+  , MacOSXContentGenerator(this)
 {
   this->BuildFileStream = 0;
   this->InfoFileStream = 0;
@@ -153,8 +155,12 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
         }
       }
     }
-  this->WriteMacOSXContentRules(this->GeneratorTarget->HeaderSources);
-  this->WriteMacOSXContentRules(this->GeneratorTarget->ExtraSources);
+  this->OSXBundleGenerator->GenerateMacOSXContentStatements(
+    this->GeneratorTarget->HeaderSources,
+    &this->MacOSXContentGenerator);
+  this->OSXBundleGenerator->GenerateMacOSXContentStatements(
+    this->GeneratorTarget->ExtraSources,
+    &this->MacOSXContentGenerator);
   for(std::vector<cmSourceFile*>::const_iterator
         si = this->GeneratorTarget->ExternalObjects.begin();
       si != this->GeneratorTarget->ExternalObjects.end(); ++si)
@@ -173,7 +179,6 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
   this->GeneratorTarget->UseObjectLibraries(this->ExternalObjects);
 }
 
-
 //----------------------------------------------------------------------------
 void cmMakefileTargetGenerator::WriteCommonCodeRules()
 {
@@ -344,33 +349,26 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
 }
 
 //----------------------------------------------------------------------------
-void cmMakefileTargetGenerator::WriteMacOSXContentRules(
-  std::vector<cmSourceFile*> const& sources)
+cmMakefileTargetGenerator::MacOSXContentGeneratorType::
+MacOSXContentGeneratorType(cmMakefileTargetGenerator* generator)
+  : cmOSXBundleGenerator::MacOSXContentGeneratorType()
+  , Generator(generator)
 {
-  for(std::vector<cmSourceFile*>::const_iterator
-        si = sources.begin(); si != sources.end(); ++si)
-    {
-    cmTarget::SourceFileFlags tsFlags =
-      this->Target->GetTargetSourceFileFlags(*si);
-    if(tsFlags.Type != cmTarget::SourceFileTypeNormal)
-      {
-      this->WriteMacOSXContentRules(**si, tsFlags.MacFolder);
-      }
-    }
 }
 
 //----------------------------------------------------------------------------
-void cmMakefileTargetGenerator::WriteMacOSXContentRules(cmSourceFile& source,
-                                                        const char* pkgloc)
+void
+cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()
+  (cmSourceFile& source, const char* pkgloc)
 {
   // Skip OS X content when not building a Framework or Bundle.
-  if(this->MacContentDirectory.empty())
+  if(this->Generator->MacContentDirectory.empty())
     {
     return;
     }
 
   // Construct the full path to the content subdirectory.
-  std::string macdir = this->MacContentDirectory;
+  std::string macdir = this->Generator->MacContentDirectory;
   macdir += pkgloc;
   cmSystemTools::MakeDirectory(macdir.c_str());
 
@@ -379,7 +377,7 @@ void cmMakefileTargetGenerator::WriteMacOSXContentRules(cmSourceFile& source,
   {
   std::string loc = pkgloc;
   loc = loc.substr(0, loc.find('/'));
-  this->MacContentFolders.insert(loc);
+  this->Generator->MacContentFolders.insert(loc);
   }
 
   // Get the input file location.
@@ -389,9 +387,11 @@ void cmMakefileTargetGenerator::WriteMacOSXContentRules(cmSourceFile& source,
   std::string output = macdir;
   output += "/";
   output += cmSystemTools::GetFilenameName(input);
-  this->CleanFiles.push_back(this->Convert(output.c_str(),
-                                           cmLocalGenerator::START_OUTPUT));
-  output = this->Convert(output.c_str(), cmLocalGenerator::HOME_OUTPUT);
+  this->Generator->CleanFiles.push_back(
+    this->Generator->Convert(output.c_str(),
+                             cmLocalGenerator::START_OUTPUT));
+  output = this->Generator->Convert(output.c_str(),
+                                    cmLocalGenerator::HOME_OUTPUT);
 
   // Create a rule to copy the content into the bundle.
   std::vector<std::string> depends;
@@ -399,21 +399,23 @@ void cmMakefileTargetGenerator::WriteMacOSXContentRules(cmSourceFile& source,
   depends.push_back(input);
   std::string copyEcho = "Copying OS X content ";
   copyEcho += output;
-  this->LocalGenerator->AppendEcho(commands, copyEcho.c_str(),
-                                   cmLocalUnixMakefileGenerator3::EchoBuild);
+  this->Generator->LocalGenerator->AppendEcho(
+    commands, copyEcho.c_str(),
+    cmLocalUnixMakefileGenerator3::EchoBuild);
   std::string copyCommand = "$(CMAKE_COMMAND) -E copy ";
-  copyCommand += this->Convert(input.c_str(),
-                               cmLocalGenerator::NONE,
-                               cmLocalGenerator::SHELL);
+  copyCommand += this->Generator->Convert(input.c_str(),
+                                          cmLocalGenerator::NONE,
+                                          cmLocalGenerator::SHELL);
   copyCommand += " ";
-  copyCommand += this->Convert(output.c_str(),
-                               cmLocalGenerator::NONE,
-                               cmLocalGenerator::SHELL);
+  copyCommand += this->Generator->Convert(output.c_str(),
+                                          cmLocalGenerator::NONE,
+                                          cmLocalGenerator::SHELL);
   commands.push_back(copyCommand);
-  this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      output.c_str(),
-                                      depends, commands, false);
-  this->ExtraFiles.insert(output);
+  this->Generator->LocalGenerator->WriteMakeRule(
+    *this->Generator->BuildFileStream, 0,
+    output.c_str(),
+    depends, commands, false);
+  this->Generator->ExtraFiles.insert(output);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 36a1f68..d5eb634 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -13,6 +13,7 @@
 #define cmMakefileTargetGenerator_h
 
 #include "cmLocalUnixMakefileGenerator3.h"
+#include "cmOSXBundleGenerator.h"
 
 class cmCustomCommand;
 class cmDependInformation;
@@ -73,8 +74,17 @@ protected:
   void WriteTargetDependRules();
 
   // write rules for Mac OS X Application Bundle content.
-  void WriteMacOSXContentRules(std::vector<cmSourceFile*> const& sources);
-  void WriteMacOSXContentRules(cmSourceFile& source, const char* pkgloc);
+  class MacOSXContentGeneratorType
+    : public cmOSXBundleGenerator::MacOSXContentGeneratorType
+  {
+  public:
+    MacOSXContentGeneratorType(cmMakefileTargetGenerator* Generator);
+    virtual void operator()(cmSourceFile& source, const char* pkgloc);
+
+  private:
+    cmMakefileTargetGenerator* Generator;
+  };
+  friend class MacOSXContentGeneratorType;
 
   // write the rules for an object
   void WriteObjectRuleFiles(cmSourceFile& source);
@@ -223,6 +233,8 @@ protected:
   // Mac OS X content info.
   std::string MacContentDirectory;
   std::set<cmStdString> MacContentFolders;
+  cmOSXBundleGenerator* OSXBundleGenerator;
+  MacOSXContentGeneratorType MacOSXContentGenerator;
 
   typedef std::map<cmStdString, cmStdString> ByLanguageMap;
   std::string GetFlags(const std::string &l);
diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx
index a82c503..e8afd45 100644
--- a/Source/cmMakefileUtilityTargetGenerator.cxx
+++ b/Source/cmMakefileUtilityTargetGenerator.cxx
@@ -24,6 +24,12 @@ cmMakefileUtilityTargetGenerator
   cmMakefileTargetGenerator(target)
 {
   this->CustomCommandDriver = OnUtility;
+  this->OSXBundleGenerator = new cmOSXBundleGenerator(this->Target,
+                                                      this->TargetNameOut,
+                                                      this->ConfigName);
+  this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
+  this->MacContentDirectory =
+    this->OSXBundleGenerator->GetMacContentDirectory();
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index f71cc60..2c7bffc 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -22,7 +22,6 @@
 #include "cmComputeLinkInformation.h"
 #include "cmSourceFile.h"
 #include "cmCustomCommandGenerator.h"
-#include "cmOSXBundleGenerator.h"
 
 #include <algorithm>
 
@@ -58,6 +57,7 @@ cmNinjaTargetGenerator::New(cmTarget* target)
 
 cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmTarget* target)
   :
+    MacOSXContentGenerator(this),
     OSXBundleGenerator(0),
     MacContentFolders(),
     Target(target),
@@ -432,9 +432,12 @@ cmNinjaTargetGenerator
      cmCustomCommand const* cc = (*si)->GetCustomCommand();
      this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget());
      }
-  this->WriteMacOSXContentBuildStatements(
-    this->GeneratorTarget->HeaderSources);
-  this->WriteMacOSXContentBuildStatements(this->GeneratorTarget->ExtraSources);
+  this->OSXBundleGenerator->GenerateMacOSXContentStatements(
+    this->GeneratorTarget->HeaderSources,
+    &this->MacOSXContentGenerator);
+  this->OSXBundleGenerator->GenerateMacOSXContentStatements(
+    this->GeneratorTarget->ExtraSources,
+    &this->MacOSXContentGenerator);
   for(std::vector<cmSourceFile*>::const_iterator
         si = this->GeneratorTarget->ExternalObjects.begin();
       si != this->GeneratorTarget->ExternalObjects.end(); ++si)
@@ -643,35 +646,27 @@ cmNinjaTargetGenerator
 }
 
 //----------------------------------------------------------------------------
-// TODO: Re-factor with cmMakefileTargetGenerator::WriteMacOSXContentRules
-void cmNinjaTargetGenerator::WriteMacOSXContentBuildStatements(
-  std::vector<cmSourceFile*> const& sources)
+cmNinjaTargetGenerator::MacOSXContentGeneratorType::
+MacOSXContentGeneratorType(cmNinjaTargetGenerator* generator)
+  : cmOSXBundleGenerator::MacOSXContentGeneratorType()
+  , Generator(generator)
 {
-  for(std::vector<cmSourceFile*>::const_iterator
-        si = sources.begin(); si != sources.end(); ++si)
-    {
-    cmTarget::SourceFileFlags tsFlags =
-      this->Target->GetTargetSourceFileFlags(*si);
-    if(tsFlags.Type != cmTarget::SourceFileTypeNormal)
-      {
-      this->WriteMacOSXContentBuildStatement(**si, tsFlags.MacFolder);
-      }
-    }
 }
 
 //----------------------------------------------------------------------------
-// TODO: Re-factor with cmMakefileTargetGenerator::WriteMacOSXContentRules
-void cmNinjaTargetGenerator::WriteMacOSXContentBuildStatement(
+void
+cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
   cmSourceFile& source, const char* pkgloc)
 {
   // Skip OS X content when not building a Framework or Bundle.
-  if(this->OSXBundleGenerator->GetMacContentDirectory().empty())
+  if(this->Generator->OSXBundleGenerator->GetMacContentDirectory().empty())
     {
     return;
     }
 
   // Construct the full path to the content subdirectory.
-  std::string macdir = this->OSXBundleGenerator->GetMacContentDirectory();
+  std::string macdir =
+    this->Generator->OSXBundleGenerator->GetMacContentDirectory();
   macdir += pkgloc;
   cmSystemTools::MakeDirectory(macdir.c_str());
 
@@ -680,22 +675,25 @@ void cmNinjaTargetGenerator::WriteMacOSXContentBuildStatement(
   {
   std::string loc = pkgloc;
   loc = loc.substr(0, loc.find('/'));
-  this->MacContentFolders.insert(loc);
+  this->Generator->MacContentFolders.insert(loc);
   }
 
   // Get the input file location.
   std::string input = source.GetFullPath();
-  input = this->GetLocalGenerator()->ConvertToNinjaPath(input.c_str());
+  input =
+    this->Generator->GetLocalGenerator()->ConvertToNinjaPath(input.c_str());
 
   // Get the output file location.
   std::string output = macdir;
   output += "/";
   output += cmSystemTools::GetFilenameName(input);
-  output = this->GetLocalGenerator()->ConvertToNinjaPath(output.c_str());
+  output =
+    this->Generator->GetLocalGenerator()->ConvertToNinjaPath(output.c_str());
 
   // Write a build statement to copy the content into the bundle.
-  this->GetGlobalGenerator()->WriteMacOSXContentBuild(input, output);
+  this->Generator->GetGlobalGenerator()->WriteMacOSXContentBuild(input,
+                                                                 output);
 
   // Add as a dependency of all target so that it gets called.
-  this->GetGlobalGenerator()->AddDependencyToAll(output);
+  this->Generator->GetGlobalGenerator()->AddDependencyToAll(output);
 }
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index 49168c4..0a3329f 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -16,6 +16,7 @@
 #include "cmStandardIncludes.h"
 #include "cmNinjaTypes.h"
 #include "cmLocalNinjaGenerator.h"
+#include "cmOSXBundleGenerator.h"
 
 class cmTarget;
 class cmGlobalNinjaGenerator;
@@ -24,7 +25,6 @@ class cmGeneratorTarget;
 class cmMakefile;
 class cmSourceFile;
 class cmCustomCommand;
-class cmOSXBundleGenerator;
 
 class cmNinjaTargetGenerator
 {
@@ -115,12 +115,21 @@ protected:
   void EnsureDirectoryExists(const std::string& dir);
   void EnsureParentDirectoryExists(const std::string& path);
 
-  void WriteMacOSXContentBuildStatements(
-    std::vector<cmSourceFile*> const& sources);
-  void WriteMacOSXContentBuildStatement(cmSourceFile& source,
-                                        const char* pkgloc);
+  // write rules for Mac OS X Application Bundle content.
+  class MacOSXContentGeneratorType
+    : public cmOSXBundleGenerator::MacOSXContentGeneratorType
+  {
+  public:
+    MacOSXContentGeneratorType(cmNinjaTargetGenerator* Generator);
+    virtual void operator()(cmSourceFile& source, const char* pkgloc);
+
+  private:
+    cmNinjaTargetGenerator* Generator;
+  };
+  friend class MacOSXContentGeneratorType;
 
 protected:
+  MacOSXContentGeneratorType MacOSXContentGenerator;
   // Properly initialized by sub-classes.
   cmOSXBundleGenerator* OSXBundleGenerator;
   std::set<cmStdString> MacContentFolders;
diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
index b3210eb..8788d42 100644
--- a/Source/cmOSXBundleGenerator.cxx
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -200,3 +200,21 @@ void cmOSXBundleGenerator::CreateCFBundle(std::string& targetName,
                                                plist.c_str());
   this->Makefile->AddCMakeOutputFile(plist.c_str());
 }
+
+//----------------------------------------------------------------------------
+void
+cmOSXBundleGenerator::
+GenerateMacOSXContentStatements(std::vector<cmSourceFile*> const& sources,
+                                MacOSXContentGeneratorType* generator)
+{
+  for(std::vector<cmSourceFile*>::const_iterator
+        si = sources.begin(); si != sources.end(); ++si)
+    {
+    cmTarget::SourceFileFlags tsFlags =
+      this->Target->GetTargetSourceFileFlags(*si);
+    if(tsFlags.Type != cmTarget::SourceFileTypeNormal)
+      {
+      (*generator)(**si, tsFlags.MacFolder);
+      }
+    }
+}
diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h
index 38092b9..dc6a8ae 100644
--- a/Source/cmOSXBundleGenerator.h
+++ b/Source/cmOSXBundleGenerator.h
@@ -13,6 +13,7 @@
 #define cmOSXBundleGenerator_h
 
 #include "cmStandardIncludes.h"
+#include "cmSourceFile.h"
 
 #include <string>
 #include <set>
@@ -34,6 +35,16 @@ public:
   void CreateFramework(std::string const& targetName);
   void CreateCFBundle(std::string& targetName, std::string& outpath);
 
+  class MacOSXContentGeneratorType
+  {
+  public:
+    virtual void operator()(cmSourceFile& source, const char* pkgloc) = 0;
+  };
+
+  void GenerateMacOSXContentStatements(
+    std::vector<cmSourceFile*> const& sources,
+    MacOSXContentGeneratorType* generator);
+
   std::string GetMacContentDirectory() const
   { return this->MacContentDirectory; }
   std::string GetFrameworkVersion() const

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3b2a01e80ef0faf626afd4c5031395c00e1c9ecd
commit 3b2a01e80ef0faf626afd4c5031395c00e1c9ecd
Author:     Nicolas Despres <nicolas.despres at gmail.com>
AuthorDate: Wed Jul 11 12:58:01 2012 +0200
Commit:     Peter Kümmel <syntheticpp at gmx.net>
CommitDate: Tue Jul 17 14:03:10 2012 +0200

    Ninja: Use same echo message as makefiles.

diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 8d0493f..67a556d 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -125,7 +125,10 @@ const char *cmNinjaNormalTargetGenerator::GetVisibleTypeName() const
     case cmTarget::SHARED_LIBRARY:
       return "shared library";
     case cmTarget::MODULE_LIBRARY:
-      return "shared module";
+      if (this->GetTarget()->IsCFBundleOnApple())
+        return "CFBundle shared module";
+      else
+        return "shared module";
     case cmTarget::EXECUTABLE:
       return "executable";
     default:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7bb56c511eaabf2071cd311b6cf14453651127e4
commit 7bb56c511eaabf2071cd311b6cf14453651127e4
Author:     Nicolas Despres <nicolas.despres at gmail.com>
AuthorDate: Mon Jul 16 16:00:40 2012 +0200
Commit:     Peter Kümmel <syntheticpp at gmx.net>
CommitDate: Tue Jul 17 14:03:09 2012 +0200

    Re-factor CFBundle generation.

diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 4331af6..a655504 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -28,11 +28,7 @@ cmMakefileLibraryTargetGenerator
   cmMakefileTargetGenerator(target),
   OSXBundleGenerator(0)
 {
-  if(this->Target->IsCFBundleOnApple())
-    {
-    target->SetProperty("PREFIX", "");
-    target->SetProperty("SUFFIX", "");
-    }
+  cmOSXBundleGenerator::PrepareTargetProperties(this->Target);
 
   this->CustomCommandDriver = OnDepends;
   this->Target->GetLibraryNames(
@@ -250,27 +246,6 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
 }
 
 //----------------------------------------------------------------------------
-void
-cmMakefileLibraryTargetGenerator::CreateCFBundle(std::string& targetName,
-                                                 std::string& outpath)
-{
-  // Compute bundle directory names.
-  outpath = this->MacContentDirectory;
-  outpath += "MacOS";
-  cmSystemTools::MakeDirectory(outpath.c_str());
-  this->Makefile->AddCMakeOutputFile(outpath.c_str());
-  outpath += "/";
-
-  // Configure the Info.plist file.  Note that it needs the executable name
-  // to be set.
-  std::string plist = this->MacContentDirectory + "Info.plist";
-  this->LocalGenerator->GenerateAppleInfoPList(this->Target,
-                                               targetName.c_str(),
-                                               plist.c_str());
-  this->Makefile->AddCMakeOutputFile(plist.c_str());
-}
-
-//----------------------------------------------------------------------------
 void cmMakefileLibraryTargetGenerator::WriteLibraryRules
 (const char* linkRuleVar, const char* extraFlags, bool relink)
 {
@@ -328,7 +303,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
     {
     outpath = this->Target->GetDirectory(this->ConfigName);
     outpath += "/";
-    this->CreateCFBundle(targetName, outpath);
+    this->OSXBundleGenerator->CreateCFBundle(targetName, outpath);
     }
   else if(relink)
     {
diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h
index 0d4d777..ee56f6c 100644
--- a/Source/cmMakefileLibraryTargetGenerator.h
+++ b/Source/cmMakefileLibraryTargetGenerator.h
@@ -36,7 +36,6 @@ protected:
                          bool relink);
   // MacOSX Framework support methods
   void WriteFrameworkRules(bool relink);
-  void CreateCFBundle(std::string& targetName, std::string& outpath);
 
   // Store the computd framework version for OS X Frameworks.
   std::string FrameworkVersion;
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index d4fc02b..8d0493f 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -36,12 +36,7 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
   , TargetNamePDB()
   , TargetLinkLanguage(0)
 {
-  // TODO: Re-factor with cmMakefileLibraryTargetGenerator's constructor.
-  if(target->IsCFBundleOnApple())
-    {
-    target->SetProperty("PREFIX", "");
-    target->SetProperty("SUFFIX", "");
-    }
+  cmOSXBundleGenerator::PrepareTargetProperties(target);
 
   this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName());
   if (target->GetType() == cmTarget::EXECUTABLE)
@@ -383,13 +378,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
     // Create the library framework.
     this->OSXBundleGenerator->CreateFramework(this->TargetNameOut);
     }
-  // TODO: Re-factor with cmMakefileLibraryTargetGenerator::WriteLibraryRules.
   else if(this->GetTarget()->IsCFBundleOnApple())
     {
+    // Create the core foundation bundle.
     std::string outpath;
-    outpath = this->GetTarget()->GetDirectory(this->GetConfigName());
-    outpath += "/";
-    this->CreateCFBundle(this->TargetNameOut, outpath);
+    this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut, outpath);
     }
 
   // Write comments.
@@ -617,25 +610,3 @@ void cmNinjaNormalTargetGenerator::WriteObjectLibStatement()
   this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
                                              this->GetTarget());
 }
-
-//----------------------------------------------------------------------------
-// TODO: Re-factor with cmMakefileLibraryTargetGenerator::CreateCFBundle.
-void cmNinjaNormalTargetGenerator::CreateCFBundle(std::string& targetName,
-                                                  std::string& outpath)
-{
-  // Compute bundle directory names.
-  outpath = this->OSXBundleGenerator->GetMacContentDirectory();
-  outpath += "MacOS";
-  cmSystemTools::MakeDirectory(outpath.c_str());
-  this->GetMakefile()->AddCMakeOutputFile(outpath.c_str());
-  outpath += "/";
-
-  // Configure the Info.plist file.  Note that it needs the executable name
-  // to be set.
-  std::string plist = this->OSXBundleGenerator->GetMacContentDirectory();
-  plist += "Info.plist";
-  this->GetLocalGenerator()->GenerateAppleInfoPList(this->GetTarget(),
-                                                    targetName.c_str(),
-                                                    plist.c_str());
-  this->GetMakefile()->AddCMakeOutputFile(plist.c_str());
-}
diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h
index 74e10cf..284804b 100644
--- a/Source/cmNinjaNormalTargetGenerator.h
+++ b/Source/cmNinjaNormalTargetGenerator.h
@@ -38,7 +38,6 @@ private:
   void WriteLinkStatement();
   void WriteObjectLibStatement();
   std::vector<std::string> ComputeLinkCmd();
-  void CreateCFBundle(std::string& targetName, std::string& outpath);
 
 private:
   // Target name info.
diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
index d7afcd6..b3210eb 100644
--- a/Source/cmOSXBundleGenerator.cxx
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -16,6 +16,16 @@
 
 #include <cassert>
 
+void cmOSXBundleGenerator::PrepareTargetProperties(cmTarget* target)
+{
+  if(target->IsCFBundleOnApple())
+    {
+    target->SetProperty("PREFIX", "");
+    target->SetProperty("SUFFIX", "");
+    }
+}
+
+//----------------------------------------------------------------------------
 cmOSXBundleGenerator::
 cmOSXBundleGenerator(cmTarget* target,
                      std::string targetNameOut,
@@ -169,3 +179,24 @@ void cmOSXBundleGenerator::CreateFramework(std::string const& targetName)
     this->Makefile->AddCMakeOutputFile(newName.c_str());
     }
 }
+
+//----------------------------------------------------------------------------
+void cmOSXBundleGenerator::CreateCFBundle(std::string& targetName,
+                                          std::string& outpath)
+{
+  // Compute bundle directory names.
+  outpath = this->MacContentDirectory;
+  outpath += "MacOS";
+  cmSystemTools::MakeDirectory(outpath.c_str());
+  this->Makefile->AddCMakeOutputFile(outpath.c_str());
+  outpath += "/";
+
+  // Configure the Info.plist file.  Note that it needs the executable name
+  // to be set.
+  std::string plist = this->MacContentDirectory;
+  plist += "Info.plist";
+  this->LocalGenerator->GenerateAppleInfoPList(this->Target,
+                                               targetName.c_str(),
+                                               plist.c_str());
+  this->Makefile->AddCMakeOutputFile(plist.c_str());
+}
diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h
index 29ce7c4..38092b9 100644
--- a/Source/cmOSXBundleGenerator.h
+++ b/Source/cmOSXBundleGenerator.h
@@ -24,12 +24,15 @@ class cmLocalGenerator;
 class cmOSXBundleGenerator
 {
 public:
+  static void PrepareTargetProperties(cmTarget* target);
+
   cmOSXBundleGenerator(cmTarget* target,
                        std::string targetNameOut,
                        const char* configName);
 
   void CreateAppBundle(std::string& targetName, std::string& outpath);
   void CreateFramework(std::string const& targetName);
+  void CreateCFBundle(std::string& targetName, std::string& outpath);
 
   std::string GetMacContentDirectory() const
   { return this->MacContentDirectory; }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=03bdaf545369d4438a8aece8d3cec603d3a99727
commit 03bdaf545369d4438a8aece8d3cec603d3a99727
Author:     Nicolas Despres <nicolas.despres at gmail.com>
AuthorDate: Mon Jul 16 11:26:56 2012 +0200
Commit:     Peter Kümmel <syntheticpp at gmx.net>
CommitDate: Tue Jul 17 14:03:09 2012 +0200

    Enable BundleTest with CLang too.

diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 300ab09..c702adf 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1418,42 +1418,44 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
     LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSMidl")
   ENDIF(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio")
 
-  IF (APPLE AND CMAKE_COMPILER_IS_GNUCXX)
-    SET(BundleTestInstallDir
-      "${CMake_BINARY_DIR}/Tests/BundleTest/InstallDirectory")
-    ADD_TEST(BundleTest ${CMAKE_CTEST_COMMAND}
-      --build-and-test
-      "${CMake_SOURCE_DIR}/Tests/BundleTest"
-      "${CMake_BINARY_DIR}/Tests/BundleTest"
-      --build-two-config
-      --build-generator ${CMAKE_TEST_GENERATOR}
-      --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
-      --build-project BundleTest
-      --build-target install
-#     --build-target package
-      --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${BundleTestInstallDir}"
-       "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}"
-      --test-command
-      ${BundleTestInstallDir}/Applications/SecondBundleExe.app/Contents/MacOS/SecondBundleExe)
-    LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleTest")
-
-    ADD_TEST(CFBundleTest ${CMAKE_CTEST_COMMAND}
-      --build-and-test
-      "${CMake_SOURCE_DIR}/Tests/CFBundleTest"
-      "${CMake_BINARY_DIR}/Tests/CFBundleTest"
-      --build-two-config
-      --build-generator ${CMAKE_TEST_GENERATOR}
-      --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
-      --build-project CFBundleTest
-      --test-command
-      ${CMAKE_CMAKE_COMMAND} -DCTEST_CONFIGURATION_TYPE=\${CTEST_CONFIGURATION_TYPE}
+  IF (APPLE)
+    if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+      SET(BundleTestInstallDir
+        "${CMake_BINARY_DIR}/Tests/BundleTest/InstallDirectory")
+      ADD_TEST(BundleTest ${CMAKE_CTEST_COMMAND}
+        --build-and-test
+        "${CMake_SOURCE_DIR}/Tests/BundleTest"
+        "${CMake_BINARY_DIR}/Tests/BundleTest"
+        --build-two-config
+        --build-generator ${CMAKE_TEST_GENERATOR}
+        --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
+        --build-project BundleTest
+        --build-target install
+#       --build-target package
+        --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${BundleTestInstallDir}"
+        "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}"
+        --test-command
+        ${BundleTestInstallDir}/Applications/SecondBundleExe.app/Contents/MacOS/SecondBundleExe)
+      LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleTest")
+
+      ADD_TEST(CFBundleTest ${CMAKE_CTEST_COMMAND}
+        --build-and-test
+        "${CMake_SOURCE_DIR}/Tests/CFBundleTest"
+        "${CMake_BINARY_DIR}/Tests/CFBundleTest"
+        --build-two-config
+        --build-generator ${CMAKE_TEST_GENERATOR}
+        --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
+        --build-project CFBundleTest
+        --test-command
+        ${CMAKE_CMAKE_COMMAND} -DCTEST_CONFIGURATION_TYPE=\${CTEST_CONFIGURATION_TYPE}
         -Ddir=${CMake_BINARY_DIR}/Tests/CFBundleTest
         -Dgen=${CMAKE_TEST_GENERATOR}
         -P ${CMake_SOURCE_DIR}/Tests/CFBundleTest/VerifyResult.cmake)
-    LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest")
+      LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest")
 
-    ADD_TEST_MACRO(ObjC++ ObjC++)
-  ENDIF (APPLE AND CMAKE_COMPILER_IS_GNUCXX)
+      ADD_TEST_MACRO(ObjC++ ObjC++)
+    ENDIF (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+  ENDIF (APPLE)
 
   IF(APPLE AND CTEST_TEST_CPACK)
     ADD_TEST(BundleGeneratorTest ${CMAKE_CTEST_COMMAND}

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=54d9713adb016423d20c610163726f80da435588
commit 54d9713adb016423d20c610163726f80da435588
Author:     Nicolas Despres <nicolas.despres at gmail.com>
AuthorDate: Wed Jul 11 11:19:25 2012 +0200
Commit:     Peter Kümmel <syntheticpp at gmx.net>
CommitDate: Tue Jul 17 14:03:08 2012 +0200

    Ninja: Add support for CFBundle.
    
    This patch fixes test CFBundleTest on Darwin.

diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 45a4f68..d4fc02b 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -36,6 +36,13 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
   , TargetNamePDB()
   , TargetLinkLanguage(0)
 {
+  // TODO: Re-factor with cmMakefileLibraryTargetGenerator's constructor.
+  if(target->IsCFBundleOnApple())
+    {
+    target->SetProperty("PREFIX", "");
+    target->SetProperty("SUFFIX", "");
+    }
+
   this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName());
   if (target->GetType() == cmTarget::EXECUTABLE)
     target->GetExecutableNames(this->TargetNameOut,
@@ -376,6 +383,14 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
     // Create the library framework.
     this->OSXBundleGenerator->CreateFramework(this->TargetNameOut);
     }
+  // TODO: Re-factor with cmMakefileLibraryTargetGenerator::WriteLibraryRules.
+  else if(this->GetTarget()->IsCFBundleOnApple())
+    {
+    std::string outpath;
+    outpath = this->GetTarget()->GetDirectory(this->GetConfigName());
+    outpath += "/";
+    this->CreateCFBundle(this->TargetNameOut, outpath);
+    }
 
   // Write comments.
   cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream());
@@ -602,3 +617,25 @@ void cmNinjaNormalTargetGenerator::WriteObjectLibStatement()
   this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
                                              this->GetTarget());
 }
+
+//----------------------------------------------------------------------------
+// TODO: Re-factor with cmMakefileLibraryTargetGenerator::CreateCFBundle.
+void cmNinjaNormalTargetGenerator::CreateCFBundle(std::string& targetName,
+                                                  std::string& outpath)
+{
+  // Compute bundle directory names.
+  outpath = this->OSXBundleGenerator->GetMacContentDirectory();
+  outpath += "MacOS";
+  cmSystemTools::MakeDirectory(outpath.c_str());
+  this->GetMakefile()->AddCMakeOutputFile(outpath.c_str());
+  outpath += "/";
+
+  // Configure the Info.plist file.  Note that it needs the executable name
+  // to be set.
+  std::string plist = this->OSXBundleGenerator->GetMacContentDirectory();
+  plist += "Info.plist";
+  this->GetLocalGenerator()->GenerateAppleInfoPList(this->GetTarget(),
+                                                    targetName.c_str(),
+                                                    plist.c_str());
+  this->GetMakefile()->AddCMakeOutputFile(plist.c_str());
+}
diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h
index 284804b..74e10cf 100644
--- a/Source/cmNinjaNormalTargetGenerator.h
+++ b/Source/cmNinjaNormalTargetGenerator.h
@@ -38,6 +38,7 @@ private:
   void WriteLinkStatement();
   void WriteObjectLibStatement();
   std::vector<std::string> ComputeLinkCmd();
+  void CreateCFBundle(std::string& targetName, std::string& outpath);
 
 private:
   // Target name info.
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 4f3f2c5..aaa622f 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -3169,6 +3169,7 @@ std::string cmTarget::GetFullPath(const char* config, bool implib,
 std::string cmTarget::NormalGetFullPath(const char* config, bool implib,
                                         bool realname)
 {
+  // TODO: Re-factor with cmOSXBundleGenerator's constructor.
   // Start with the output directory for the target.
   std::string fpath = this->GetDirectory(config, implib);
   fpath += "/";
@@ -3185,6 +3186,18 @@ std::string cmTarget::NormalGetFullPath(const char* config, bool implib,
     fpath += this->GetFrameworkVersion();
     fpath += "/";
     }
+  if(this->IsCFBundleOnApple())
+    {
+    fpath += this->GetFullName(config, false);
+    fpath += ".";
+    const char *ext = this->GetProperty("BUNDLE_EXTENSION");
+    if (!ext)
+      {
+      ext = "bundle";
+      }
+    fpath += ext;
+    fpath += "/Contents/MacOS/";
+    }
 
   // Add the full name of the target.
   if(implib)

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=10686a17f4457fd6032543992538850be5cc8d88
commit 10686a17f4457fd6032543992538850be5cc8d88
Author:     Nicolas Despres <nicolas.despres at gmail.com>
AuthorDate: Tue Jul 10 20:13:01 2012 +0200
Commit:     Peter Kümmel <syntheticpp at gmx.net>
CommitDate: Tue Jul 17 14:03:08 2012 +0200

    Ninja: Copy resource files in the bundle.
    
    This patch fixes test BundleTest on Darwin.

diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 07cc75f..1bf466e 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -252,6 +252,48 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command,
                                      vars);
 }
 
+void
+cmGlobalNinjaGenerator::AddMacOSXContentRule()
+{
+  cmLocalGenerator *lg = this->LocalGenerators[0];
+  cmMakefile* mfRoot = lg->GetMakefile();
+
+  cmOStringStream cmd;
+  cmd << lg->ConvertToOutputFormat(
+           mfRoot->GetRequiredDefinition("CMAKE_COMMAND"),
+           cmLocalGenerator::SHELL)
+      << " -E copy $in $out";
+
+  this->AddRule("COPY_OSX_CONTENT",
+                cmd.str(),
+                "Copying OS X Content $out",
+                "Rule for copying OS X bundle content file."
+                /*depfile*/ "",
+                /*rspfile*/ "");
+}
+
+void
+cmGlobalNinjaGenerator::WriteMacOSXContentBuild(const std::string& input,
+                                                const std::string& output)
+{
+  this->AddMacOSXContentRule();
+
+  cmNinjaDeps outputs;
+  outputs.push_back(output);
+  cmNinjaDeps deps;
+  deps.push_back(input);
+  cmNinjaVars vars;
+
+  cmGlobalNinjaGenerator::WriteBuild(*this->BuildFileStream,
+                                     "",
+                                     "COPY_OSX_CONTENT",
+                                     outputs,
+                                     deps,
+                                     cmNinjaDeps(),
+                                     cmNinjaDeps(),
+                                     cmNinjaVars());
+}
+
 void cmGlobalNinjaGenerator::WriteRule(std::ostream& os,
                                        const std::string& name,
                                        const std::string& command,
@@ -758,6 +800,11 @@ void cmGlobalNinjaGenerator::AddDependencyToAll(cmTarget* target)
   this->AppendTargetOutputs(target, this->AllDependencies);
 }
 
+void cmGlobalNinjaGenerator::AddDependencyToAll(const std::string& input)
+{
+  this->AllDependencies.push_back(input);
+}
+
 void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies()
 {
   for (std::map<std::string, std::set<std::string> >::iterator
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index ff4f85d..61353c5 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -103,6 +103,8 @@ public:
                                const cmNinjaDeps& outputs,
                                const cmNinjaDeps& deps = cmNinjaDeps(),
                              const cmNinjaDeps& orderOnlyDeps = cmNinjaDeps());
+  void WriteMacOSXContentBuild(const std::string& input,
+                               const std::string& output);
 
   /**
    * Write a rule statement named @a name to @a os with the @a comment,
@@ -242,6 +244,7 @@ public:
   bool HasRule(const std::string& name);
 
   void AddCustomCommandRule();
+  void AddMacOSXContentRule();
 
 protected:
 
@@ -276,6 +279,7 @@ private:
   void WriteDisclaimer(std::ostream& os);
 
   void AddDependencyToAll(cmTarget* target);
+  void AddDependencyToAll(const std::string& input);
 
   void WriteAssumedSourceDependencies();
 
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index fecce14..45a4f68 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -35,8 +35,6 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
   , TargetNameImport()
   , TargetNamePDB()
   , TargetLinkLanguage(0)
-  , OSXBundleGenerator(0)
-  , MacContentFolders()
 {
   this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName());
   if (target->GetType() == cmTarget::EXECUTABLE)
diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h
index fb597c5..284804b 100644
--- a/Source/cmNinjaNormalTargetGenerator.h
+++ b/Source/cmNinjaNormalTargetGenerator.h
@@ -47,8 +47,6 @@ private:
   std::string TargetNameImport;
   std::string TargetNamePDB;
   const char *TargetLinkLanguage;
-  cmOSXBundleGenerator* OSXBundleGenerator;
-  std::set<cmStdString> MacContentFolders;
 };
 
 #endif // ! cmNinjaNormalTargetGenerator_h
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 4758989..f71cc60 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -22,6 +22,7 @@
 #include "cmComputeLinkInformation.h"
 #include "cmSourceFile.h"
 #include "cmCustomCommandGenerator.h"
+#include "cmOSXBundleGenerator.h"
 
 #include <algorithm>
 
@@ -56,7 +57,10 @@ cmNinjaTargetGenerator::New(cmTarget* target)
 }
 
 cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmTarget* target)
-  : Target(target),
+  :
+    OSXBundleGenerator(0),
+    MacContentFolders(),
+    Target(target),
     Makefile(target->GetMakefile()),
     LocalGenerator(
       static_cast<cmLocalNinjaGenerator*>(Makefile->GetLocalGenerator())),
@@ -428,6 +432,9 @@ cmNinjaTargetGenerator
      cmCustomCommand const* cc = (*si)->GetCustomCommand();
      this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget());
      }
+  this->WriteMacOSXContentBuildStatements(
+    this->GeneratorTarget->HeaderSources);
+  this->WriteMacOSXContentBuildStatements(this->GeneratorTarget->ExtraSources);
   for(std::vector<cmSourceFile*>::const_iterator
         si = this->GeneratorTarget->ExternalObjects.begin();
       si != this->GeneratorTarget->ExternalObjects.end(); ++si)
@@ -634,3 +641,61 @@ cmNinjaTargetGenerator
 {
   EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path.c_str()));
 }
+
+//----------------------------------------------------------------------------
+// TODO: Re-factor with cmMakefileTargetGenerator::WriteMacOSXContentRules
+void cmNinjaTargetGenerator::WriteMacOSXContentBuildStatements(
+  std::vector<cmSourceFile*> const& sources)
+{
+  for(std::vector<cmSourceFile*>::const_iterator
+        si = sources.begin(); si != sources.end(); ++si)
+    {
+    cmTarget::SourceFileFlags tsFlags =
+      this->Target->GetTargetSourceFileFlags(*si);
+    if(tsFlags.Type != cmTarget::SourceFileTypeNormal)
+      {
+      this->WriteMacOSXContentBuildStatement(**si, tsFlags.MacFolder);
+      }
+    }
+}
+
+//----------------------------------------------------------------------------
+// TODO: Re-factor with cmMakefileTargetGenerator::WriteMacOSXContentRules
+void cmNinjaTargetGenerator::WriteMacOSXContentBuildStatement(
+  cmSourceFile& source, const char* pkgloc)
+{
+  // Skip OS X content when not building a Framework or Bundle.
+  if(this->OSXBundleGenerator->GetMacContentDirectory().empty())
+    {
+    return;
+    }
+
+  // Construct the full path to the content subdirectory.
+  std::string macdir = this->OSXBundleGenerator->GetMacContentDirectory();
+  macdir += pkgloc;
+  cmSystemTools::MakeDirectory(macdir.c_str());
+
+  // Record use of this content location.  Only the first level
+  // directory is needed.
+  {
+  std::string loc = pkgloc;
+  loc = loc.substr(0, loc.find('/'));
+  this->MacContentFolders.insert(loc);
+  }
+
+  // Get the input file location.
+  std::string input = source.GetFullPath();
+  input = this->GetLocalGenerator()->ConvertToNinjaPath(input.c_str());
+
+  // Get the output file location.
+  std::string output = macdir;
+  output += "/";
+  output += cmSystemTools::GetFilenameName(input);
+  output = this->GetLocalGenerator()->ConvertToNinjaPath(output.c_str());
+
+  // Write a build statement to copy the content into the bundle.
+  this->GetGlobalGenerator()->WriteMacOSXContentBuild(input, output);
+
+  // Add as a dependency of all target so that it gets called.
+  this->GetGlobalGenerator()->AddDependencyToAll(output);
+}
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index af43a8b..49168c4 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -24,6 +24,7 @@ class cmGeneratorTarget;
 class cmMakefile;
 class cmSourceFile;
 class cmCustomCommand;
+class cmOSXBundleGenerator;
 
 class cmNinjaTargetGenerator
 {
@@ -114,6 +115,16 @@ protected:
   void EnsureDirectoryExists(const std::string& dir);
   void EnsureParentDirectoryExists(const std::string& path);
 
+  void WriteMacOSXContentBuildStatements(
+    std::vector<cmSourceFile*> const& sources);
+  void WriteMacOSXContentBuildStatement(cmSourceFile& source,
+                                        const char* pkgloc);
+
+protected:
+  // Properly initialized by sub-classes.
+  cmOSXBundleGenerator* OSXBundleGenerator;
+  std::set<cmStdString> MacContentFolders;
+
 private:
   cmTarget* Target;
   cmGeneratorTarget* GeneratorTarget;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a1b803349b51a9a814cd8e309832991306ef2cf0
commit a1b803349b51a9a814cd8e309832991306ef2cf0
Author:     Nicolas Despres <nicolas.despres at gmail.com>
AuthorDate: Sat Jul 7 19:54:16 2012 +0200
Commit:     Peter Kümmel <syntheticpp at gmx.net>
CommitDate: Tue Jul 17 14:03:07 2012 +0200

    Re-factor OS X bundle and framework generation.

diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 14af796..543a64e 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -219,6 +219,8 @@ SET(SRCS
   cmMakefileExecutableTargetGenerator.cxx
   cmMakefileLibraryTargetGenerator.cxx
   cmMakefileUtilityTargetGenerator.cxx
+  cmOSXBundleGenerator.cxx
+  cmOSXBundleGenerator.h
   cmNewLineStyle.h
   cmNewLineStyle.cxx
   cmOrderDirectories.cxx
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 36e366e..d9ab334 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -18,24 +18,31 @@
 #include "cmSourceFile.h"
 #include "cmTarget.h"
 #include "cmake.h"
+#include "cmOSXBundleGenerator.h"
 
 //----------------------------------------------------------------------------
 cmMakefileExecutableTargetGenerator
 ::cmMakefileExecutableTargetGenerator(cmTarget* target):
-  cmMakefileTargetGenerator(target)
+  cmMakefileTargetGenerator(target),
+  OSXBundleGenerator(0)
 {
   this->CustomCommandDriver = OnDepends;
   this->Target->GetExecutableNames(
     this->TargetNameOut, this->TargetNameReal, this->TargetNameImport,
     this->TargetNamePDB, this->ConfigName);
 
-  if(this->Target->IsAppBundleOnApple())
-    {
-    this->MacContentDirectory = this->Target->GetDirectory(this->ConfigName);
-    this->MacContentDirectory += "/";
-    this->MacContentDirectory += this->TargetNameOut;
-    this->MacContentDirectory += ".app/Contents/";
-    }
+  this->OSXBundleGenerator = new cmOSXBundleGenerator(this->Target,
+                                                      this->TargetNameOut,
+                                                      this->ConfigName);
+  this->MacContentDirectory =
+    this->OSXBundleGenerator->GetMacContentDirectory();
+}
+
+//----------------------------------------------------------------------------
+cmMakefileExecutableTargetGenerator
+::~cmMakefileExecutableTargetGenerator()
+{
+  delete this->OSXBundleGenerator;
 }
 
 //----------------------------------------------------------------------------
@@ -100,7 +107,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   outpath += "/";
   if(this->Target->IsAppBundleOnApple())
     {
-    this->CreateAppBundle(targetName, outpath);
+    this->OSXBundleGenerator->CreateAppBundle(targetName, outpath);
     }
   std::string outpathImp;
   if(relink)
@@ -440,24 +447,3 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
                           exeCleanFiles.begin(),
                           exeCleanFiles.end());
 }
-
-//----------------------------------------------------------------------------
-void
-cmMakefileExecutableTargetGenerator::CreateAppBundle(std::string& targetName,
-                                                     std::string& outpath)
-{
-  // Compute bundle directory names.
-  outpath = this->MacContentDirectory;
-  outpath += "MacOS";
-  cmSystemTools::MakeDirectory(outpath.c_str());
-  this->Makefile->AddCMakeOutputFile(outpath.c_str());
-  outpath += "/";
-
-  // Configure the Info.plist file.  Note that it needs the executable name
-  // to be set.
-  std::string plist = this->MacContentDirectory + "Info.plist";
-  this->LocalGenerator->GenerateAppleInfoPList(this->Target,
-                                               targetName.c_str(),
-                                               plist.c_str());
-  this->Makefile->AddCMakeOutputFile(plist.c_str());
-}
diff --git a/Source/cmMakefileExecutableTargetGenerator.h b/Source/cmMakefileExecutableTargetGenerator.h
index a9712ca..26dc72f 100644
--- a/Source/cmMakefileExecutableTargetGenerator.h
+++ b/Source/cmMakefileExecutableTargetGenerator.h
@@ -14,10 +14,13 @@
 
 #include "cmMakefileTargetGenerator.h"
 
+class cmOSXBundleGenerator;
+
 class cmMakefileExecutableTargetGenerator: public cmMakefileTargetGenerator
 {
 public:
   cmMakefileExecutableTargetGenerator(cmTarget* target);
+  virtual ~cmMakefileExecutableTargetGenerator();
 
   /* the main entry point for this class. Writes the Makefiles associated
      with this target */
@@ -25,7 +28,9 @@ public:
 
 protected:
   virtual void WriteExecutableRule(bool relink);
-  void CreateAppBundle(std::string& targetName, std::string& outpath);
+
+private:
+  cmOSXBundleGenerator* OSXBundleGenerator;
 };
 
 #endif
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 0901e6f..4331af6 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -18,13 +18,15 @@
 #include "cmSourceFile.h"
 #include "cmTarget.h"
 #include "cmake.h"
+#include "cmOSXBundleGenerator.h"
 
 #include <memory> // auto_ptr
 
 //----------------------------------------------------------------------------
 cmMakefileLibraryTargetGenerator
 ::cmMakefileLibraryTargetGenerator(cmTarget* target):
-  cmMakefileTargetGenerator(target)
+  cmMakefileTargetGenerator(target),
+  OSXBundleGenerator(0)
 {
   if(this->Target->IsCFBundleOnApple())
     {
@@ -37,30 +39,19 @@ cmMakefileLibraryTargetGenerator
     this->TargetNameOut, this->TargetNameSO, this->TargetNameReal,
     this->TargetNameImport, this->TargetNamePDB, this->ConfigName);
 
-  if(this->Target->IsFrameworkOnApple())
-    {
-    this->FrameworkVersion = this->Target->GetFrameworkVersion();
-    this->MacContentDirectory = this->Target->GetDirectory(this->ConfigName);
-    this->MacContentDirectory += "/";
-    this->MacContentDirectory += this->TargetNameOut;
-    this->MacContentDirectory += ".framework/Versions/";
-    this->MacContentDirectory += this->FrameworkVersion;
-    this->MacContentDirectory += "/";
-    }
-  else if(this->Target->IsCFBundleOnApple())
-    {
-    this->MacContentDirectory = this->Target->GetDirectory(this->ConfigName);
-    this->MacContentDirectory += "/";
-    this->MacContentDirectory += this->TargetNameOut;
-    this->MacContentDirectory += ".";
-    const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION");
-    if (!ext)
-      {
-      ext = "bundle";
-      }
-    this->MacContentDirectory += ext;
-    this->MacContentDirectory += "/Contents/";
-    }
+  this->OSXBundleGenerator = new cmOSXBundleGenerator(this->Target,
+                                                      this->TargetNameOut,
+                                                      this->ConfigName);
+  this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
+  this->MacContentDirectory =
+    this->OSXBundleGenerator->GetMacContentDirectory();
+}
+
+//----------------------------------------------------------------------------
+cmMakefileLibraryTargetGenerator
+::~cmMakefileLibraryTargetGenerator()
+{
+  delete this->OSXBundleGenerator;
 }
 
 //----------------------------------------------------------------------------
@@ -260,94 +251,6 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
 
 //----------------------------------------------------------------------------
 void
-cmMakefileLibraryTargetGenerator
-::CreateFramework(std::string const& targetName)
-{
-  // Configure the Info.plist file into the Resources directory.
-  this->MacContentFolders.insert("Resources");
-  std::string plist = this->MacContentDirectory + "Resources/Info.plist";
-  this->LocalGenerator->GenerateFrameworkInfoPList(this->Target,
-                                                   targetName.c_str(),
-                                                   plist.c_str());
-
-  // TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to
-  // drive rules to create these files at build time.
-  std::string oldName;
-  std::string newName;
-
-  // Compute the location of the top-level foo.framework directory.
-  std::string top = this->Target->GetDirectory(this->ConfigName);
-  top += "/";
-  top += this->TargetNameOut;
-  top += ".framework/";
-
-  // Make foo.framework/Versions
-  std::string versions = top;
-  versions += "Versions";
-  cmSystemTools::MakeDirectory(versions.c_str());
-
-  // Make foo.framework/Versions/version
-  std::string version = versions;
-  version += "/";
-  version += this->FrameworkVersion;
-  cmSystemTools::MakeDirectory(version.c_str());
-
-  // Current -> version
-  oldName = this->FrameworkVersion;
-  newName = versions;
-  newName += "/Current";
-  cmSystemTools::RemoveFile(newName.c_str());
-  cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
-  this->Makefile->AddCMakeOutputFile(newName.c_str());
-
-  // foo -> Versions/Current/foo
-  oldName = "Versions/Current/";
-  oldName += this->TargetNameOut;
-  newName = top;
-  newName += this->TargetNameOut;
-  cmSystemTools::RemoveFile(newName.c_str());
-  cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
-  this->Makefile->AddCMakeOutputFile(newName.c_str());
-
-  // Resources -> Versions/Current/Resources
-  if(this->MacContentFolders.find("Resources") !=
-     this->MacContentFolders.end())
-    {
-    oldName = "Versions/Current/Resources";
-    newName = top;
-    newName += "Resources";
-    cmSystemTools::RemoveFile(newName.c_str());
-    cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
-    this->Makefile->AddCMakeOutputFile(newName.c_str());
-    }
-
-  // Headers -> Versions/Current/Headers
-  if(this->MacContentFolders.find("Headers") !=
-     this->MacContentFolders.end())
-    {
-    oldName = "Versions/Current/Headers";
-    newName = top;
-    newName += "Headers";
-    cmSystemTools::RemoveFile(newName.c_str());
-    cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
-    this->Makefile->AddCMakeOutputFile(newName.c_str());
-    }
-
-  // PrivateHeaders -> Versions/Current/PrivateHeaders
-  if(this->MacContentFolders.find("PrivateHeaders") !=
-     this->MacContentFolders.end())
-    {
-    oldName = "Versions/Current/PrivateHeaders";
-    newName = top;
-    newName += "PrivateHeaders";
-    cmSystemTools::RemoveFile(newName.c_str());
-    cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
-    this->Makefile->AddCMakeOutputFile(newName.c_str());
-    }
-}
-
-//----------------------------------------------------------------------------
-void
 cmMakefileLibraryTargetGenerator::CreateCFBundle(std::string& targetName,
                                                  std::string& outpath)
 {
@@ -419,7 +322,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   if(this->Target->IsFrameworkOnApple())
     {
     outpath = this->MacContentDirectory;
-    this->CreateFramework(targetName);
+    this->OSXBundleGenerator->CreateFramework(targetName);
     }
   else if(this->Target->IsCFBundleOnApple())
     {
diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h
index ed79bd8..0d4d777 100644
--- a/Source/cmMakefileLibraryTargetGenerator.h
+++ b/Source/cmMakefileLibraryTargetGenerator.h
@@ -14,11 +14,14 @@
 
 #include "cmMakefileTargetGenerator.h"
 
+class cmOSXBundleGenerator;
+
 class cmMakefileLibraryTargetGenerator:
   public cmMakefileTargetGenerator
 {
 public:
   cmMakefileLibraryTargetGenerator(cmTarget* target);
+  virtual ~cmMakefileLibraryTargetGenerator();
 
   /* the main entry point for this class. Writes the Makefiles associated
      with this target */
@@ -33,7 +36,6 @@ protected:
                          bool relink);
   // MacOSX Framework support methods
   void WriteFrameworkRules(bool relink);
-  void CreateFramework(std::string const& targetName);
   void CreateCFBundle(std::string& targetName, std::string& outpath);
 
   // Store the computd framework version for OS X Frameworks.
@@ -41,6 +43,9 @@ protected:
 
   void AppendOSXVerFlag(std::string& flags, const char* lang,
                         const char* name, bool so);
+
+private:
+  cmOSXBundleGenerator* OSXBundleGenerator;
 };
 
 #endif
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 6a5fd6b..fecce14 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -16,6 +16,7 @@
 #include "cmSourceFile.h"
 #include "cmGeneratedFileStream.h"
 #include "cmMakefile.h"
+#include "cmOSXBundleGenerator.h"
 
 #include <assert.h>
 #include <algorithm>
@@ -34,8 +35,8 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
   , TargetNameImport()
   , TargetNamePDB()
   , TargetLinkLanguage(0)
-  , MacContentDirectory()
-  , FrameworkVersion()
+  , OSXBundleGenerator(0)
+  , MacContentFolders()
 {
   this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName());
   if (target->GetType() == cmTarget::EXECUTABLE)
@@ -59,43 +60,15 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
     EnsureDirectoryExists(target->GetDirectory(this->GetConfigName()));
     }
 
-  // TODO: Factor with the cmMakefileExecutableTargetGenerator constructor.
-  if(target->IsAppBundleOnApple())
-    {
-    this->MacContentDirectory = target->GetDirectory(this->GetConfigName());
-    this->MacContentDirectory += "/";
-    this->MacContentDirectory += this->TargetNameOut;
-    this->MacContentDirectory += ".app/Contents/";
-    }
-  // TODO: Factor with the cmMakefileLibraryTargetGenerator constructor.
-  else if(target->IsFrameworkOnApple())
-    {
-    this->FrameworkVersion = target->GetFrameworkVersion();
-    this->MacContentDirectory = target->GetDirectory(this->GetConfigName());
-    this->MacContentDirectory += "/";
-    this->MacContentDirectory += this->TargetNameOut;
-    this->MacContentDirectory += ".framework/Versions/";
-    this->MacContentDirectory += this->FrameworkVersion;
-    this->MacContentDirectory += "/";
-    }
-  else if(target->IsCFBundleOnApple())
-    {
-    this->MacContentDirectory = target->GetDirectory(this->GetConfigName());
-    this->MacContentDirectory += "/";
-    this->MacContentDirectory += this->TargetNameOut;
-    this->MacContentDirectory += ".";
-    const char *ext = target->GetProperty("BUNDLE_EXTENSION");
-    if (!ext)
-      {
-      ext = "bundle";
-      }
-    this->MacContentDirectory += ext;
-    this->MacContentDirectory += "/Contents/";
-    }
+  this->OSXBundleGenerator = new cmOSXBundleGenerator(target,
+                                                      this->TargetNameOut,
+                                                      this->GetConfigName());
+  this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
 }
 
 cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator()
 {
+  delete this->OSXBundleGenerator;
 }
 
 void cmNinjaNormalTargetGenerator::Generate()
@@ -392,7 +365,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
     {
     // Create the app bundle
     std::string outpath;
-    this->CreateAppBundle(this->TargetNameOut, outpath);
+    this->OSXBundleGenerator->CreateAppBundle(this->TargetNameOut, outpath);
 
     // Calculate the output path
     targetOutput = outpath + this->TargetNameOut;
@@ -403,7 +376,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
   else if (this->GetTarget()->IsFrameworkOnApple())
     {
     // Create the library framework.
-    this->CreateFramework(this->TargetNameOut);
+    this->OSXBundleGenerator->CreateFramework(this->TargetNameOut);
     }
 
   // Write comments.
@@ -631,113 +604,3 @@ void cmNinjaNormalTargetGenerator::WriteObjectLibStatement()
   this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
                                              this->GetTarget());
 }
-
-// TODO: Factor with cmMakefileExecutableTargetGenerator::CreateAppBundle().
-void
-cmNinjaNormalTargetGenerator::CreateAppBundle(const std::string& targetName,
-                                              std::string& outpath)
-{
-  // Compute bundle directory names.
-  outpath = this->MacContentDirectory;
-  outpath += "MacOS";
-  cmSystemTools::MakeDirectory(outpath.c_str());
-  this->GetMakefile()->AddCMakeOutputFile(outpath.c_str());
-  outpath += "/";
-
-  // Configure the Info.plist file.  Note that it needs the executable name
-  // to be set.
-  std::string plist = this->MacContentDirectory + "Info.plist";
-  this->GetLocalGenerator()->GenerateAppleInfoPList(this->GetTarget(),
-                                                    targetName.c_str(),
-                                                    plist.c_str());
-  this->GetMakefile()->AddCMakeOutputFile(plist.c_str());
-}
-
-// TODO: Factor with cmMakefileLibraryTargetGenerator::CreateFramework().
-void
-cmNinjaNormalTargetGenerator::CreateFramework(std::string const& targetName)
-{
-  // Create the Resources directory.
-  std::string resources = this->MacContentDirectory + "Resources/";
-  cmSystemTools::MakeDirectory(resources.c_str());
-
-  // Configure the Info.plist file into the Resources directory.
-  std::set<cmStdString> macContentFolders;
-  macContentFolders.insert("Resources");
-  std::string plist = resources + "Info.plist";
-  this->GetLocalGenerator()->GenerateFrameworkInfoPList(this->GetTarget(),
-                                                        targetName.c_str(),
-                                                        plist.c_str());
-
-  // TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to
-  // drive rules to create these files at build time.
-  std::string oldName;
-  std::string newName;
-
-  // Compute the location of the top-level foo.framework directory.
-  std::string top = this->GetTarget()->GetDirectory(this->GetConfigName());
-  top += "/";
-  top += this->TargetNameOut;
-  top += ".framework/";
-
-  // Make foo.framework/Versions
-  std::string versions = top;
-  versions += "Versions";
-  cmSystemTools::MakeDirectory(versions.c_str());
-
-  // Make foo.framework/Versions/version
-  std::string version = versions;
-  version += "/";
-  version += this->FrameworkVersion;
-  cmSystemTools::MakeDirectory(version.c_str());
-
-  // Current -> version
-  oldName = this->FrameworkVersion;
-  newName = versions;
-  newName += "/Current";
-  cmSystemTools::RemoveFile(newName.c_str());
-  cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
-  this->GetMakefile()->AddCMakeOutputFile(newName.c_str());
-
-  // foo -> Versions/Current/foo
-  oldName = "Versions/Current/";
-  oldName += this->TargetNameOut;
-  newName = top;
-  newName += this->TargetNameOut;
-  cmSystemTools::RemoveFile(newName.c_str());
-  cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
-  this->GetMakefile()->AddCMakeOutputFile(newName.c_str());
-
-  // Resources -> Versions/Current/Resources
-  if(macContentFolders.find("Resources") != macContentFolders.end())
-    {
-    oldName = "Versions/Current/Resources";
-    newName = top;
-    newName += "Resources";
-    cmSystemTools::RemoveFile(newName.c_str());
-    cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
-    this->GetMakefile()->AddCMakeOutputFile(newName.c_str());
-    }
-
-  // Headers -> Versions/Current/Headers
-  if(macContentFolders.find("Headers") != macContentFolders.end())
-    {
-    oldName = "Versions/Current/Headers";
-    newName = top;
-    newName += "Headers";
-    cmSystemTools::RemoveFile(newName.c_str());
-    cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
-    this->GetMakefile()->AddCMakeOutputFile(newName.c_str());
-    }
-
-  // PrivateHeaders -> Versions/Current/PrivateHeaders
-  if(macContentFolders.find("PrivateHeaders") != macContentFolders.end())
-    {
-    oldName = "Versions/Current/PrivateHeaders";
-    newName = top;
-    newName += "PrivateHeaders";
-    cmSystemTools::RemoveFile(newName.c_str());
-    cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
-    this->GetMakefile()->AddCMakeOutputFile(newName.c_str());
-    }
-}
diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h
index c48a8ec..fb597c5 100644
--- a/Source/cmNinjaNormalTargetGenerator.h
+++ b/Source/cmNinjaNormalTargetGenerator.h
@@ -15,8 +15,12 @@
 
 #  include "cmNinjaTargetGenerator.h"
 #  include "cmNinjaTypes.h"
+#  include "cmStandardIncludes.h"
+
+#  include <set>
 
 class cmSourceFile;
+class cmOSXBundleGenerator;
 
 class cmNinjaNormalTargetGenerator : public cmNinjaTargetGenerator
 {
@@ -34,8 +38,6 @@ private:
   void WriteLinkStatement();
   void WriteObjectLibStatement();
   std::vector<std::string> ComputeLinkCmd();
-  void CreateAppBundle(const std::string& targetName, std::string& outpath);
-  void CreateFramework(std::string const& targetName);
 
 private:
   // Target name info.
@@ -45,8 +47,8 @@ private:
   std::string TargetNameImport;
   std::string TargetNamePDB;
   const char *TargetLinkLanguage;
-  std::string MacContentDirectory;
-  std::string FrameworkVersion;
+  cmOSXBundleGenerator* OSXBundleGenerator;
+  std::set<cmStdString> MacContentFolders;
 };
 
 #endif // ! cmNinjaNormalTargetGenerator_h
diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
new file mode 100644
index 0000000..d7afcd6
--- /dev/null
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -0,0 +1,171 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2012 Nicolas Despres <nicolas.despres at gmail.com>
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+#include "cmOSXBundleGenerator.h"
+#include "cmMakefile.h"
+#include "cmTarget.h"
+#include "cmLocalGenerator.h"
+
+#include <cassert>
+
+cmOSXBundleGenerator::
+cmOSXBundleGenerator(cmTarget* target,
+                     std::string targetNameOut,
+                     const char* configName)
+ : Target(target)
+ , Makefile(target->GetMakefile())
+ , LocalGenerator(this->Makefile->GetLocalGenerator())
+ , TargetNameOut(targetNameOut)
+ , ConfigName(configName)
+ , MacContentDirectory()
+ , FrameworkVersion()
+ , MacContentFolders(0)
+{
+  if(this->Target->IsAppBundleOnApple())
+    {
+    this->MacContentDirectory = this->Target->GetDirectory(this->ConfigName);
+    this->MacContentDirectory += "/";
+    this->MacContentDirectory += this->TargetNameOut;
+    this->MacContentDirectory += ".app/Contents/";
+    }
+  else if(this->Target->IsFrameworkOnApple())
+    {
+    this->FrameworkVersion = this->Target->GetFrameworkVersion();
+    this->MacContentDirectory = this->Target->GetDirectory(this->ConfigName);
+    this->MacContentDirectory += "/";
+    this->MacContentDirectory += this->TargetNameOut;
+    this->MacContentDirectory += ".framework/Versions/";
+    this->MacContentDirectory += this->FrameworkVersion;
+    this->MacContentDirectory += "/";
+    }
+  else if(this->Target->IsCFBundleOnApple())
+    {
+    this->MacContentDirectory = this->Target->GetDirectory(this->ConfigName);
+    this->MacContentDirectory += "/";
+    this->MacContentDirectory += this->TargetNameOut;
+    this->MacContentDirectory += ".";
+    const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION");
+    if (!ext)
+      {
+      ext = "bundle";
+      }
+    this->MacContentDirectory += ext;
+    this->MacContentDirectory += "/Contents/";
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmOSXBundleGenerator::CreateAppBundle(std::string& targetName,
+                                           std::string& outpath)
+{
+  // Compute bundle directory names.
+  outpath = this->MacContentDirectory;
+  outpath += "MacOS";
+  cmSystemTools::MakeDirectory(outpath.c_str());
+  this->Makefile->AddCMakeOutputFile(outpath.c_str());
+  outpath += "/";
+
+  // Configure the Info.plist file.  Note that it needs the executable name
+  // to be set.
+  std::string plist = this->MacContentDirectory + "Info.plist";
+  this->LocalGenerator->GenerateAppleInfoPList(this->Target,
+                                               targetName.c_str(),
+                                               plist.c_str());
+  this->Makefile->AddCMakeOutputFile(plist.c_str());
+}
+
+//----------------------------------------------------------------------------
+void cmOSXBundleGenerator::CreateFramework(std::string const& targetName)
+{
+  assert(this->MacContentFolders);
+
+  // Configure the Info.plist file into the Resources directory.
+  this->MacContentFolders->insert("Resources");
+  std::string plist = this->MacContentDirectory + "Resources/Info.plist";
+  this->LocalGenerator->GenerateFrameworkInfoPList(this->Target,
+                                                   targetName.c_str(),
+                                                   plist.c_str());
+
+  // TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to
+  // drive rules to create these files at build time.
+  std::string oldName;
+  std::string newName;
+
+  // Compute the location of the top-level foo.framework directory.
+  std::string top = this->Target->GetDirectory(this->ConfigName);
+  top += "/";
+  top += this->TargetNameOut;
+  top += ".framework/";
+
+  // Make foo.framework/Versions
+  std::string versions = top;
+  versions += "Versions";
+  cmSystemTools::MakeDirectory(versions.c_str());
+
+  // Make foo.framework/Versions/version
+  std::string version = versions;
+  version += "/";
+  version += this->FrameworkVersion;
+  cmSystemTools::MakeDirectory(version.c_str());
+
+  // Current -> version
+  oldName = this->FrameworkVersion;
+  newName = versions;
+  newName += "/Current";
+  cmSystemTools::RemoveFile(newName.c_str());
+  cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+  this->Makefile->AddCMakeOutputFile(newName.c_str());
+
+  // foo -> Versions/Current/foo
+  oldName = "Versions/Current/";
+  oldName += this->TargetNameOut;
+  newName = top;
+  newName += this->TargetNameOut;
+  cmSystemTools::RemoveFile(newName.c_str());
+  cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+  this->Makefile->AddCMakeOutputFile(newName.c_str());
+
+  // Resources -> Versions/Current/Resources
+  if(this->MacContentFolders->find("Resources") !=
+     this->MacContentFolders->end())
+    {
+    oldName = "Versions/Current/Resources";
+    newName = top;
+    newName += "Resources";
+    cmSystemTools::RemoveFile(newName.c_str());
+    cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+    this->Makefile->AddCMakeOutputFile(newName.c_str());
+    }
+
+  // Headers -> Versions/Current/Headers
+  if(this->MacContentFolders->find("Headers") !=
+     this->MacContentFolders->end())
+    {
+    oldName = "Versions/Current/Headers";
+    newName = top;
+    newName += "Headers";
+    cmSystemTools::RemoveFile(newName.c_str());
+    cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+    this->Makefile->AddCMakeOutputFile(newName.c_str());
+    }
+
+  // PrivateHeaders -> Versions/Current/PrivateHeaders
+  if(this->MacContentFolders->find("PrivateHeaders") !=
+     this->MacContentFolders->end())
+    {
+    oldName = "Versions/Current/PrivateHeaders";
+    newName = top;
+    newName += "PrivateHeaders";
+    cmSystemTools::RemoveFile(newName.c_str());
+    cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+    this->Makefile->AddCMakeOutputFile(newName.c_str());
+    }
+}
diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h
new file mode 100644
index 0000000..29ce7c4
--- /dev/null
+++ b/Source/cmOSXBundleGenerator.h
@@ -0,0 +1,52 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2012 Nicolas Despres <nicolas.despres at gmail.com>
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+#ifndef cmOSXBundleGenerator_h
+#define cmOSXBundleGenerator_h
+
+#include "cmStandardIncludes.h"
+
+#include <string>
+#include <set>
+
+class cmTarget;
+class cmMakefile;
+class cmLocalGenerator;
+
+class cmOSXBundleGenerator
+{
+public:
+  cmOSXBundleGenerator(cmTarget* target,
+                       std::string targetNameOut,
+                       const char* configName);
+
+  void CreateAppBundle(std::string& targetName, std::string& outpath);
+  void CreateFramework(std::string const& targetName);
+
+  std::string GetMacContentDirectory() const
+  { return this->MacContentDirectory; }
+  std::string GetFrameworkVersion() const
+  { return this->FrameworkVersion; }
+  void SetMacContentFolders(std::set<cmStdString>* macContentFolders)
+  { this->MacContentFolders = macContentFolders; }
+
+private:
+  cmTarget* Target;
+  cmMakefile* Makefile;
+  cmLocalGenerator* LocalGenerator;
+  std::string TargetNameOut;
+  const char* ConfigName;
+  std::string MacContentDirectory;
+  std::string FrameworkVersion;
+  std::set<cmStdString>* MacContentFolders;
+};
+
+#endif
diff --git a/bootstrap b/bootstrap
index 3cd41a2..13a95c8 100755
--- a/bootstrap
+++ b/bootstrap
@@ -220,6 +220,7 @@ CMAKE_CXX_SOURCES="\
   cmMakefileLibraryTargetGenerator \
   cmMakefileTargetGenerator \
   cmMakefileUtilityTargetGenerator \
+  cmOSXBundleGenerator \
   cmNewLineStyle \
   cmBootstrapCommands \
   cmCommands \

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3ba74ad9d586816f7c60cc6f527148edf982871c
commit 3ba74ad9d586816f7c60cc6f527148edf982871c
Author:     Nicolas Despres <nicolas.despres at gmail.com>
AuthorDate: Sat Jul 7 19:57:40 2012 +0200
Commit:     Peter Kümmel <syntheticpp at gmx.net>
CommitDate: Tue Jul 17 14:03:06 2012 +0200

    Remove trailing white-spaces.

diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 78278cb..36e366e 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -129,7 +129,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   std::string targetFullPathReal = outpath + targetNameReal;
   std::string targetFullPathPDB = outpath + targetNamePDB;
   std::string targetFullPathImport = outpathImp + targetNameImport;
-  std::string targetOutPathPDB = 
+  std::string targetOutPathPDB =
     this->Convert(targetFullPathPDB.c_str(),
                   cmLocalGenerator::NONE,
                   cmLocalGenerator::SHELL);
diff --git a/Source/cmMakefileExecutableTargetGenerator.h b/Source/cmMakefileExecutableTargetGenerator.h
index 985f207..a9712ca 100644
--- a/Source/cmMakefileExecutableTargetGenerator.h
+++ b/Source/cmMakefileExecutableTargetGenerator.h
@@ -22,7 +22,7 @@ public:
   /* the main entry point for this class. Writes the Makefiles associated
      with this target */
   virtual void WriteRuleFiles();
-  
+
 protected:
   virtual void WriteExecutableRule(bool relink);
   void CreateAppBundle(std::string& targetName, std::string& outpath);
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index db59ffd..0901e6f 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -199,7 +199,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
   linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
   this->LocalGenerator->AppendFlags
     (extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str()));
-                                    
+
   this->LocalGenerator->AddConfigVariableFlags
     (extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName);
   this->AddModuleDefinitionFlag(extraFlags);
@@ -220,7 +220,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
   linkRuleVar += "_CREATE_SHARED_MODULE";
 
   std::string extraFlags;
-  this->LocalGenerator->AppendFlags(extraFlags, 
+  this->LocalGenerator->AppendFlags(extraFlags,
                                     this->Target->GetProperty("LINK_FLAGS"));
   std::string linkFlagsConfig = "LINK_FLAGS_";
   linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
@@ -246,7 +246,7 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
   linkRuleVar += "_CREATE_MACOSX_FRAMEWORK";
 
   std::string extraFlags;
-  this->LocalGenerator->AppendFlags(extraFlags, 
+  this->LocalGenerator->AppendFlags(extraFlags,
                                     this->Target->GetProperty("LINK_FLAGS"));
   std::string linkFlagsConfig = "LINK_FLAGS_";
   linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
@@ -460,16 +460,16 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
 
   // Construct the output path version of the names for use in command
   // arguments.
-  std::string targetOutPathPDB = 
+  std::string targetOutPathPDB =
     this->Convert(targetFullPathPDB.c_str(),cmLocalGenerator::NONE,
                   cmLocalGenerator::SHELL);
-  std::string targetOutPath = 
+  std::string targetOutPath =
     this->Convert(targetFullPath.c_str(),cmLocalGenerator::START_OUTPUT,
                   cmLocalGenerator::SHELL);
-  std::string targetOutPathSO = 
+  std::string targetOutPathSO =
     this->Convert(targetFullPathSO.c_str(),cmLocalGenerator::START_OUTPUT,
                   cmLocalGenerator::SHELL);
-  std::string targetOutPathReal = 
+  std::string targetOutPathReal =
     this->Convert(targetFullPathReal.c_str(),cmLocalGenerator::START_OUTPUT,
                   cmLocalGenerator::SHELL);
   std::string targetOutPathImport =
@@ -569,7 +569,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
 
   std::vector<std::string> commands1;
   // Add a command to remove any existing files for this library.
-  // for static libs only 
+  // for static libs only
   if(this->Target->GetType() == cmTarget::STATIC_LIBRARY)
     {
     this->LocalGenerator->AppendCleanCommand(commands1, libCleanFiles,
diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h
index e6a5867..ed79bd8 100644
--- a/Source/cmMakefileLibraryTargetGenerator.h
+++ b/Source/cmMakefileLibraryTargetGenerator.h
@@ -14,7 +14,7 @@
 
 #include "cmMakefileTargetGenerator.h"
 
-class cmMakefileLibraryTargetGenerator: 
+class cmMakefileLibraryTargetGenerator:
   public cmMakefileTargetGenerator
 {
 public:
@@ -22,8 +22,8 @@ public:
 
   /* the main entry point for this class. Writes the Makefiles associated
      with this target */
-  virtual void WriteRuleFiles();  
-  
+  virtual void WriteRuleFiles();
+
 protected:
   void WriteObjectLibraryRules();
   void WriteStaticLibraryRules();
diff --git a/bootstrap b/bootstrap
index 9d98f47..3cd41a2 100755
--- a/bootstrap
+++ b/bootstrap
@@ -72,14 +72,14 @@ else
   cmake_system_darwin=false
 fi
 
-# Determine whether this is BeOS 
+# Determine whether this is BeOS
 if echo "${cmake_system}" | grep BeOS >/dev/null 2>&1; then
   cmake_system_beos=true
 else
   cmake_system_beos=false
 fi
 
-# Determine whether this is Haiku 
+# Determine whether this is Haiku
 if echo "${cmake_system}" | grep Haiku >/dev/null 2>&1; then
   cmake_system_haiku=true
 else
@@ -351,7 +351,7 @@ cmake_error()
   res=$1
   shift 1
   echo "---------------------------------------------"
-  echo "Error when bootstrapping CMake:" 
+  echo "Error when bootstrapping CMake:"
   echo "$*"
   echo "---------------------------------------------"
   if [ -f cmake_bootstrap.log ]; then
@@ -370,7 +370,7 @@ cmake_replace_string ()
   SEARCHFOR="$3"
   REPLACEWITH="$4"
   if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
-    cat "${INFILE}" | 
+    cat "${INFILE}" |
       sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}${_tmp}"
     if [ -f "${OUTFILE}${_tmp}" ]; then
       if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
@@ -393,7 +393,7 @@ cmake_kwsys_config_replace_string ()
   APPEND="$*"
   if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
     echo "${APPEND}" > "${OUTFILE}${_tmp}"
-    cat "${INFILE}" | 
+    cat "${INFILE}" |
       sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
                 s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
                 s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
@@ -797,7 +797,7 @@ echo '
 # include <iostream.h>
 #endif
 
-class NeedCXX 
+class NeedCXX
 {
 public:
   NeedCXX() { this->Foo = 1; }
@@ -1387,12 +1387,12 @@ cmake_kwsys_config_replace_string \
   "${cmake_bootstrap_dir}/cmsys/Configure.h" \
   "${cmake_compiler_settings_comment}"
 
-for a in ${KWSYS_FILES}; do 
+for a in ${KWSYS_FILES}; do
   cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
      "${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
 done
 
-for a in ${KWSYS_IOS_FILES}; do 
+for a in ${KWSYS_IOS_FILES}; do
   cmake_replace_string "${cmake_source_dir}/Source/kwsys/kwsys_ios_${a}.h.in" \
      "${cmake_bootstrap_dir}/cmsys/ios/${a}" KWSYS_NAMESPACE cmsys
 done

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=aff0029ee3d6be52f9fefc00c2ca416459a38b32
commit aff0029ee3d6be52f9fefc00c2ca416459a38b32
Author:     Nicolas Despres <nicolas.despres at gmail.com>
AuthorDate: Fri Jul 6 12:49:04 2012 +0200
Commit:     Peter Kümmel <syntheticpp at gmx.net>
CommitDate: Tue Jul 17 14:03:05 2012 +0200

    Ensure 3rd party libraries are writable.
    
    This patch fixes CMake.Install when Qt4 is installed read-only by packaging
    system like Homebrew.

diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt
index 056e48e..07ec106 100644
--- a/Source/QtDialog/CMakeLists.txt
+++ b/Source/QtDialog/CMakeLists.txt
@@ -36,14 +36,14 @@ ELSE(NOT QT4_FOUND)
     QMacInstallDialog.cxx
     QMacInstallDialog.h
     )
-  QT4_WRAP_UI(UI_SRCS 
+  QT4_WRAP_UI(UI_SRCS
     CMakeSetupDialog.ui
     Compilers.ui
     CrossCompiler.ui
     AddCacheEntry.ui
     MacInstallDialog.ui
     )
-  QT4_WRAP_CPP(MOC_SRCS 
+  QT4_WRAP_CPP(MOC_SRCS
     AddCacheEntry.h
     Compilers.h
     CMakeSetupDialog.h
@@ -76,7 +76,7 @@ ELSE(NOT QT4_FOUND)
       SET_TARGET_PROPERTIES(cmake-gui PROPERTIES
        OUTPUT_NAME ${CMAKE_BUNDLE_NAME})
     ENDIF(APPLE)
-    SET(CMAKE_INSTALL_DESTINATION_ARGS 
+    SET(CMAKE_INSTALL_DESTINATION_ARGS
       BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}")
   ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.4)
 
@@ -112,11 +112,12 @@ ELSE(NOT QT4_FOUND)
     endif(APPLE)
     install(CODE "
       include(\"${CMake_SOURCE_DIR}/Modules/BundleUtilities.cmake\")
+      set(BU_CHMOD_BUNDLE_ITEMS ON)
       fixup_bundle(\"${fixup_exe}\" \"\" \"${QT_LIBRARY_DIR};${QT_BINARY_DIR}\")
     ")
   endif(APPLE OR WIN32)
 
   CONFIGURE_FILE("${QtDialog_SOURCE_DIR}/QtDialogCPack.cmake.in"
-    "${QtDialog_BINARY_DIR}/QtDialogCPack.cmake" @ONLY)    
+    "${QtDialog_BINARY_DIR}/QtDialogCPack.cmake" @ONLY)
 ENDIF(NOT QT4_FOUND)
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a7b4e3a57b418aa4569cf3bbd484212e9b9b5c77
commit a7b4e3a57b418aa4569cf3bbd484212e9b9b5c77
Author:     Nicolas Despres <nicolas.despres at gmail.com>
AuthorDate: Thu Jul 5 18:31:17 2012 +0200
Commit:     Peter Kümmel <syntheticpp at gmx.net>
CommitDate: Tue Jul 17 14:03:05 2012 +0200

    Ninja: Add support for OX X library framework.
    
    This patch fixes test ExportImport on Darwin.

diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 7247ddc..6a5fd6b 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -35,6 +35,7 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
   , TargetNamePDB()
   , TargetLinkLanguage(0)
   , MacContentDirectory()
+  , FrameworkVersion()
 {
   this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName());
   if (target->GetType() == cmTarget::EXECUTABLE)
@@ -66,6 +67,31 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
     this->MacContentDirectory += this->TargetNameOut;
     this->MacContentDirectory += ".app/Contents/";
     }
+  // TODO: Factor with the cmMakefileLibraryTargetGenerator constructor.
+  else if(target->IsFrameworkOnApple())
+    {
+    this->FrameworkVersion = target->GetFrameworkVersion();
+    this->MacContentDirectory = target->GetDirectory(this->GetConfigName());
+    this->MacContentDirectory += "/";
+    this->MacContentDirectory += this->TargetNameOut;
+    this->MacContentDirectory += ".framework/Versions/";
+    this->MacContentDirectory += this->FrameworkVersion;
+    this->MacContentDirectory += "/";
+    }
+  else if(target->IsCFBundleOnApple())
+    {
+    this->MacContentDirectory = target->GetDirectory(this->GetConfigName());
+    this->MacContentDirectory += "/";
+    this->MacContentDirectory += this->TargetNameOut;
+    this->MacContentDirectory += ".";
+    const char *ext = target->GetProperty("BUNDLE_EXTENSION");
+    if (!ext)
+      {
+      ext = "bundle";
+      }
+    this->MacContentDirectory += ext;
+    this->MacContentDirectory += "/Contents/";
+    }
 }
 
 cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator()
@@ -374,6 +400,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
     targetOutputReal = outpath + this->TargetNameReal;
     targetOutputReal = this->ConvertToNinjaPath(targetOutputReal.c_str());
     }
+  else if (this->GetTarget()->IsFrameworkOnApple())
+    {
+    // Create the library framework.
+    this->CreateFramework(this->TargetNameOut);
+    }
 
   // Write comments.
   cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream());
@@ -621,3 +652,92 @@ cmNinjaNormalTargetGenerator::CreateAppBundle(const std::string& targetName,
                                                     plist.c_str());
   this->GetMakefile()->AddCMakeOutputFile(plist.c_str());
 }
+
+// TODO: Factor with cmMakefileLibraryTargetGenerator::CreateFramework().
+void
+cmNinjaNormalTargetGenerator::CreateFramework(std::string const& targetName)
+{
+  // Create the Resources directory.
+  std::string resources = this->MacContentDirectory + "Resources/";
+  cmSystemTools::MakeDirectory(resources.c_str());
+
+  // Configure the Info.plist file into the Resources directory.
+  std::set<cmStdString> macContentFolders;
+  macContentFolders.insert("Resources");
+  std::string plist = resources + "Info.plist";
+  this->GetLocalGenerator()->GenerateFrameworkInfoPList(this->GetTarget(),
+                                                        targetName.c_str(),
+                                                        plist.c_str());
+
+  // TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to
+  // drive rules to create these files at build time.
+  std::string oldName;
+  std::string newName;
+
+  // Compute the location of the top-level foo.framework directory.
+  std::string top = this->GetTarget()->GetDirectory(this->GetConfigName());
+  top += "/";
+  top += this->TargetNameOut;
+  top += ".framework/";
+
+  // Make foo.framework/Versions
+  std::string versions = top;
+  versions += "Versions";
+  cmSystemTools::MakeDirectory(versions.c_str());
+
+  // Make foo.framework/Versions/version
+  std::string version = versions;
+  version += "/";
+  version += this->FrameworkVersion;
+  cmSystemTools::MakeDirectory(version.c_str());
+
+  // Current -> version
+  oldName = this->FrameworkVersion;
+  newName = versions;
+  newName += "/Current";
+  cmSystemTools::RemoveFile(newName.c_str());
+  cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+  this->GetMakefile()->AddCMakeOutputFile(newName.c_str());
+
+  // foo -> Versions/Current/foo
+  oldName = "Versions/Current/";
+  oldName += this->TargetNameOut;
+  newName = top;
+  newName += this->TargetNameOut;
+  cmSystemTools::RemoveFile(newName.c_str());
+  cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+  this->GetMakefile()->AddCMakeOutputFile(newName.c_str());
+
+  // Resources -> Versions/Current/Resources
+  if(macContentFolders.find("Resources") != macContentFolders.end())
+    {
+    oldName = "Versions/Current/Resources";
+    newName = top;
+    newName += "Resources";
+    cmSystemTools::RemoveFile(newName.c_str());
+    cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+    this->GetMakefile()->AddCMakeOutputFile(newName.c_str());
+    }
+
+  // Headers -> Versions/Current/Headers
+  if(macContentFolders.find("Headers") != macContentFolders.end())
+    {
+    oldName = "Versions/Current/Headers";
+    newName = top;
+    newName += "Headers";
+    cmSystemTools::RemoveFile(newName.c_str());
+    cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+    this->GetMakefile()->AddCMakeOutputFile(newName.c_str());
+    }
+
+  // PrivateHeaders -> Versions/Current/PrivateHeaders
+  if(macContentFolders.find("PrivateHeaders") != macContentFolders.end())
+    {
+    oldName = "Versions/Current/PrivateHeaders";
+    newName = top;
+    newName += "PrivateHeaders";
+    cmSystemTools::RemoveFile(newName.c_str());
+    cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+    this->GetMakefile()->AddCMakeOutputFile(newName.c_str());
+    }
+}
diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h
index cee685d..c48a8ec 100644
--- a/Source/cmNinjaNormalTargetGenerator.h
+++ b/Source/cmNinjaNormalTargetGenerator.h
@@ -35,6 +35,7 @@ private:
   void WriteObjectLibStatement();
   std::vector<std::string> ComputeLinkCmd();
   void CreateAppBundle(const std::string& targetName, std::string& outpath);
+  void CreateFramework(std::string const& targetName);
 
 private:
   // Target name info.
@@ -45,6 +46,7 @@ private:
   std::string TargetNamePDB;
   const char *TargetLinkLanguage;
   std::string MacContentDirectory;
+  std::string FrameworkVersion;
 };
 
 #endif // ! cmNinjaNormalTargetGenerator_h

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=21f156c03bec7595b58862a58a3446ec453f7d85
commit 21f156c03bec7595b58862a58a3446ec453f7d85
Author:     Nicolas Despres <nicolas.despres at gmail.com>
AuthorDate: Tue Jul 3 22:22:17 2012 +0200
Commit:     Peter Kümmel <syntheticpp at gmx.net>
CommitDate: Tue Jul 17 14:03:04 2012 +0200

    Ninja: Add support for OS X app bundles.
    
    This patch fixes test Qt4Deploy on Darwin.
    
    Thanks to Jamie Kirkpatrick <jkp at kirkconsulting.co.uk>

diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index be7739e..7247ddc 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -33,6 +33,8 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
   , TargetNameReal()
   , TargetNameImport()
   , TargetNamePDB()
+  , TargetLinkLanguage(0)
+  , MacContentDirectory()
 {
   this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName());
   if (target->GetType() == cmTarget::EXECUTABLE)
@@ -55,6 +57,15 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
     // ensure the directory exists (OutDir test)
     EnsureDirectoryExists(target->GetDirectory(this->GetConfigName()));
     }
+
+  // TODO: Factor with the cmMakefileExecutableTargetGenerator constructor.
+  if(target->IsAppBundleOnApple())
+    {
+    this->MacContentDirectory = target->GetDirectory(this->GetConfigName());
+    this->MacContentDirectory += "/";
+    this->MacContentDirectory += this->TargetNameOut;
+    this->MacContentDirectory += ".app/Contents/";
+    }
 }
 
 cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator()
@@ -341,6 +352,29 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
 {
   cmTarget::TargetType targetType = this->GetTarget()->GetType();
 
+  std::string targetOutput = ConvertToNinjaPath(
+    this->GetTarget()->GetFullPath(this->GetConfigName()).c_str());
+  std::string targetOutputReal = ConvertToNinjaPath(
+    this->GetTarget()->GetFullPath(this->GetConfigName(),
+                                   /*implib=*/false,
+                                   /*realpath=*/true).c_str());
+  std::string targetOutputImplib = ConvertToNinjaPath(
+    this->GetTarget()->GetFullPath(this->GetConfigName(),
+                                   /*implib=*/true).c_str());
+
+  if (this->GetTarget()->IsAppBundleOnApple())
+    {
+    // Create the app bundle
+    std::string outpath;
+    this->CreateAppBundle(this->TargetNameOut, outpath);
+
+    // Calculate the output path
+    targetOutput = outpath + this->TargetNameOut;
+    targetOutput = this->ConvertToNinjaPath(targetOutput.c_str());
+    targetOutputReal = outpath + this->TargetNameReal;
+    targetOutputReal = this->ConvertToNinjaPath(targetOutputReal.c_str());
+    }
+
   // Write comments.
   cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream());
   this->GetBuildFileStream()
@@ -353,16 +387,6 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
   cmNinjaDeps emptyDeps;
   cmNinjaVars vars;
 
-  std::string targetOutput = ConvertToNinjaPath(
-    this->GetTarget()->GetFullPath(this->GetConfigName()).c_str());
-  std::string targetOutputReal = ConvertToNinjaPath(
-    this->GetTarget()->GetFullPath(this->GetConfigName(),
-                                   /*implib=*/false,
-                                   /*realpath=*/true).c_str());
-  std::string targetOutputImplib = ConvertToNinjaPath(
-    this->GetTarget()->GetFullPath(this->GetConfigName(),
-                                   /*implib=*/true).c_str());
-
   // Compute the comment.
   cmOStringStream comment;
   comment << "Link the " << this->GetVisibleTypeName() << " "
@@ -576,3 +600,24 @@ void cmNinjaNormalTargetGenerator::WriteObjectLibStatement()
   this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
                                              this->GetTarget());
 }
+
+// TODO: Factor with cmMakefileExecutableTargetGenerator::CreateAppBundle().
+void
+cmNinjaNormalTargetGenerator::CreateAppBundle(const std::string& targetName,
+                                              std::string& outpath)
+{
+  // Compute bundle directory names.
+  outpath = this->MacContentDirectory;
+  outpath += "MacOS";
+  cmSystemTools::MakeDirectory(outpath.c_str());
+  this->GetMakefile()->AddCMakeOutputFile(outpath.c_str());
+  outpath += "/";
+
+  // Configure the Info.plist file.  Note that it needs the executable name
+  // to be set.
+  std::string plist = this->MacContentDirectory + "Info.plist";
+  this->GetLocalGenerator()->GenerateAppleInfoPList(this->GetTarget(),
+                                                    targetName.c_str(),
+                                                    plist.c_str());
+  this->GetMakefile()->AddCMakeOutputFile(plist.c_str());
+}
diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h
index 1ef9567..cee685d 100644
--- a/Source/cmNinjaNormalTargetGenerator.h
+++ b/Source/cmNinjaNormalTargetGenerator.h
@@ -34,6 +34,7 @@ private:
   void WriteLinkStatement();
   void WriteObjectLibStatement();
   std::vector<std::string> ComputeLinkCmd();
+  void CreateAppBundle(const std::string& targetName, std::string& outpath);
 
 private:
   // Target name info.
@@ -43,6 +44,7 @@ private:
   std::string TargetNameImport;
   std::string TargetNamePDB;
   const char *TargetLinkLanguage;
+  std::string MacContentDirectory;
 };
 
 #endif // ! cmNinjaNormalTargetGenerator_h

-----------------------------------------------------------------------

Summary of changes:
 Source/CMakeLists.txt                          |    2 +
 Source/CMakeVersion.cmake                      |    2 +-
 Source/QtDialog/CMakeLists.txt                 |    9 +-
 Source/cmGlobalNinjaGenerator.cxx              |   47 +++++
 Source/cmGlobalNinjaGenerator.h                |    4 +
 Source/cmMakefileExecutableTargetGenerator.cxx |   45 ++---
 Source/cmMakefileExecutableTargetGenerator.h   |    4 +-
 Source/cmMakefileLibraryTargetGenerator.cxx    |  172 +++---------------
 Source/cmMakefileLibraryTargetGenerator.h      |    9 +-
 Source/cmMakefileTargetGenerator.cxx           |   82 ++++-----
 Source/cmMakefileTargetGenerator.h             |   16 ++-
 Source/cmMakefileUtilityTargetGenerator.cxx    |    6 +
 Source/cmNinjaNormalTargetGenerator.cxx        |   59 +++++-
 Source/cmNinjaNormalTargetGenerator.h          |    4 +
 Source/cmNinjaTargetGenerator.cxx              |   54 ++++++-
 Source/cmNinjaTargetGenerator.h                |   20 ++
 Source/cmOSXBundleGenerator.cxx                |  236 ++++++++++++++++++++++++
 Source/cmOSXBundleGenerator.h                  |   70 +++++++
 Source/cmTarget.cxx                            |  112 +++++++----
 Source/cmTarget.h                              |   16 ++
 Tests/CMakeLists.txt                           |   66 ++++----
 bootstrap                                      |   17 +-
 22 files changed, 723 insertions(+), 329 deletions(-)
 create mode 100644 Source/cmOSXBundleGenerator.cxx
 create mode 100644 Source/cmOSXBundleGenerator.h


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list