[cmake-commits] king committed cmLocalUnixMakefileGenerator3.cxx 1.235 1.236 cmMakefileExecutableTargetGenerator.cxx 1.42 1.43 cmMakefileTargetGenerator.cxx 1.88 1.89 cmMakefileTargetGenerator.h 1.20 1.21 cmSetPropertyCommand.cxx 1.5 1.6 cmSetSourceFilesPropertiesCommand.cxx 1.18 1.19 cmSourceFile.cxx 1.45 1.46

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Feb 15 11:22:25 EST 2008


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv1938/Source

Modified Files:
	cmLocalUnixMakefileGenerator3.cxx 
	cmMakefileExecutableTargetGenerator.cxx 
	cmMakefileTargetGenerator.cxx cmMakefileTargetGenerator.h 
	cmSetPropertyCommand.cxx cmSetSourceFilesPropertiesCommand.cxx 
	cmSourceFile.cxx 
Log Message:
ENH: Cleanup building of OS X bundle content

 - Fixes repeated rebuild of bundles by Makefile generators
 - Add special rules to copy sources to their
   MACOSX_PACKAGE_LOCATION bundle directory
 - Remove MacOSX_Content language hack
   - Remove EXTRA_CONTENT property
   - Remove MACOSX_CONTENT
   - Remove corresponding special cases in object names


Index: cmSetPropertyCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetPropertyCommand.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cmSetPropertyCommand.cxx	28 Jan 2008 13:38:36 -0000	1.5
+++ cmSetPropertyCommand.cxx	15 Feb 2008 16:22:23 -0000	1.6
@@ -295,11 +295,6 @@
     {
     sf->SetProperty(name, this->PropertyValue.c_str());
     }
-
-  // TODO: MACOSX_PACKAGE_LOCATION special case in
-  // cmSetSourceFilesPropertiesCommand
-  // The logic should be moved to cmSourceFile.
-
   return true;
 }
 

Index: cmSourceFile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSourceFile.cxx,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- cmSourceFile.cxx	30 Jan 2008 16:21:54 -0000	1.45
+++ cmSourceFile.cxx	15 Feb 2008 16:22:23 -0000	1.46
@@ -422,13 +422,6 @@
      "It will still be linked into the target though.");
 
   cm->DefineProperty
-    ("EXTRA_CONTENT", cmProperty::SOURCE_FILE, 
-     "Is this file part of a target's extra content.",
-     "If this property is set, the source file will be added to the "
-     "target's list of extra content. This is used by makefile "
-     "generators for some sort of Mac budle framework support.");
-
-  cm->DefineProperty
     ("GENERATED", cmProperty::SOURCE_FILE, 
      "Is this source file generated as part of the build process.",
      "If a source file is generated by the build process CMake will "
@@ -467,17 +460,15 @@
 
   cm->DefineProperty
     ("MACOSX_PACKAGE_LOCATION", cmProperty::SOURCE_FILE, 
-     "Location for MACOSX bundles and frameworks.",
-     "MACOSX_PACKAGE_LOCATION is the property of a file within a mac osx "
-     "bundle or framework that specifies where this file should be "
-     "copied. This makes sense for things like icons and other "
-     "resources.");
-
-  cm->DefineProperty
-    ("MACOSX_CONTENT", cmProperty::SOURCE_FILE, 
-     "If true then this is part of a MACOSX bundle or framework.",
-     "MACOSX_CONTENT is a flag that if true this file will be copied "
-     "to the bundle or framework.");
+     "Place a source file inside a Mac OS X application bundle.",
+     "Executable targets with the MACOSX_BUNDLE property set are built "
+     "as Mac OS X application bundles on Apple platforms.  "
+     "Source files specified for the target with the "
+     "MACOSX_PACKAGE_LOCATION property set will be placed in the "
+     "application bundle Contents folder under the directory specified "
+     "by the value of the property.  "
+     "Typically this is set to \"Resources\" for icon files and other "
+     "bundle resources.");
 
   cm->DefineProperty
     ("OBJECT_DEPENDS", cmProperty::SOURCE_FILE, 

Index: cmMakefileTargetGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- cmMakefileTargetGenerator.h	30 Jan 2008 01:46:25 -0000	1.20
+++ cmMakefileTargetGenerator.h	15 Feb 2008 16:22:23 -0000	1.21
@@ -82,6 +82,9 @@
   // write the depend rules for this target
   void WriteTargetDependRules();
 
+  // write rules for Mac OS X Application Bundle content.
+  void WriteMacOSXContentRules(cmSourceFile& source, const char* pkgloc);
+
   // write the rules for an object
   void WriteObjectRuleFiles(cmSourceFile& source);
 
@@ -178,11 +181,13 @@
   // objects used by this target
   std::vector<std::string> Objects;
   std::vector<std::string> ExternalObjects;
-  std::set<std::string> ExtraContent;
 
   // Set of object file names that will be built in this directory.
   std::set<cmStdString> ObjectFiles;
 
+  // Set of extra output files to be driven by the build.
+  std::set<cmStdString> ExtraFiles;
+
   typedef std::map<cmStdString, cmStdString> MultipleOutputPairsType;
   MultipleOutputPairsType MultipleOutputPairs;
 

Index: cmMakefileExecutableTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileExecutableTargetGenerator.cxx,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- cmMakefileExecutableTargetGenerator.cxx	14 Feb 2008 20:31:08 -0000	1.42
+++ cmMakefileExecutableTargetGenerator.cxx	15 Feb 2008 16:22:23 -0000	1.43
@@ -83,11 +83,6 @@
       obj != this->Objects.end(); ++obj)
     {
     objTarget = relPath;
-    // Handle extra content on Mac bundles
-    if ( this->ExtraContent.find(*obj) != this->ExtraContent.end() )
-      {
-      objTarget = "";
-      }
     objTarget += *obj;
     depends.push_back(objTarget);
     }
@@ -120,8 +115,7 @@
   // Construct the full path version of the names.
   std::string outpath = this->Target->GetDirectory();
   outpath += "/";
-#ifdef __APPLE__
-  if(this->Target->GetPropertyAsBool("MACOSX_BUNDLE"))
+  if(this->Target->IsAppBundleOnApple())
     {
     // Compute bundle directory names.
     std::string macdir = outpath;
@@ -132,27 +126,6 @@
     cmSystemTools::MakeDirectory(outpath.c_str());
     outpath += "/";
 
-    // Make bundle directories
-    std::vector<cmSourceFile*>::const_iterator sourceIt;
-    for ( sourceIt = this->Target->GetSourceFiles().begin();
-      sourceIt != this->Target->GetSourceFiles().end();
-      ++ sourceIt )
-      {
-      const char* subDir = 
-        (*sourceIt)->GetProperty("MACOSX_PACKAGE_LOCATION");
-      if ( subDir )
-        {
-        std::string newDir = macdir;
-        newDir += subDir;
-        if ( !cmSystemTools::MakeDirectory(newDir.c_str()) )
-          {
-          cmSystemTools::Error("Cannot create a subdirectory for \"",
-            newDir.c_str(), "\".");
-          return;
-          }
-        }
-      }
-
     // Configure the Info.plist file.  Note that it needs the executable name
     // to be set.
     std::string plist = macdir + "Info.plist";
@@ -160,7 +133,6 @@
                                                  targetName.c_str(),
                                                  plist.c_str());
     }
-#endif
   std::string outpathImp;
   if(relink)
     {

Index: cmLocalUnixMakefileGenerator3.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.cxx,v
retrieving revision 1.235
retrieving revision 1.236
diff -u -d -r1.235 -r1.236
--- cmLocalUnixMakefileGenerator3.cxx	18 Jan 2008 15:25:25 -0000	1.235
+++ cmLocalUnixMakefileGenerator3.cxx	15 Feb 2008 16:22:23 -0000	1.236
@@ -1887,74 +1887,32 @@
                     std::string* nameWithoutTargetDir,
                     bool* hasSourceExtension)
 {
-  if(const char* fileTargetDirectory =
-     source.GetProperty("MACOSX_PACKAGE_LOCATION"))
+  // Make sure we never hit this old case.
+  if(source.GetProperty("MACOSX_PACKAGE_LOCATION"))
     {
-    // Special handling for OSX package files.
-    std::string objectName =
-      this->GetObjectFileNameWithoutTarget(source, 0,
-                                           hasSourceExtension);
-    if(nameWithoutTargetDir)
-      {
-      *nameWithoutTargetDir = objectName;
-      }
-    objectName = cmSystemTools::GetFilenameName(objectName.c_str());
-    std::string targetName;
-    std::string targetNameReal;
-    std::string targetNameImport;
-    std::string targetNamePDB;
-    target.GetExecutableNames(targetName, targetNameReal, targetNameImport,
-                              targetNamePDB, this->ConfigurationName.c_str());
-    std::string obj;
-
-    // Construct the full path version of the names.
-    //
-    // If target is a MACOSX_BUNDLE target, then the package location is
-    // relative to "${targetDir}/${targetName}.app/Contents"... else it is
-    // relative to "${targetDir}"...
-    //
-    obj = target.GetDirectory();
-    obj += "/";
-    if ( target.GetPropertyAsBool("MACOSX_BUNDLE") )
-      {
-      obj += targetName + ".app/Contents/";
-      }
-    else
-      {
-      // Emit warning here...? MACOSX_PACKAGE_LOCATION is "most useful" in a
-      // MACOSX_BUNDLE...
-      }
-    obj += fileTargetDirectory;
-
-    // Object names are specified relative to the current build dir.
-    obj = this->Convert(obj.c_str(), START_OUTPUT);
-    obj += "/";
-    obj += objectName;
-    return obj;
+    abort();
     }
-  else
-    {
-    // Start with the target directory.
-    std::string obj = this->GetTargetDirectory(target);
-    obj += "/";
 
-    // Get the object file name without the target directory.
-    std::string::size_type dir_len = 0;
-    dir_len += strlen(this->Makefile->GetCurrentOutputDirectory());
-    dir_len += 1;
-    dir_len += obj.size();
-    std::string objectName =
-      this->GetObjectFileNameWithoutTarget(source, dir_len,
-                                           hasSourceExtension);
-    if(nameWithoutTargetDir)
-      {
-      *nameWithoutTargetDir = objectName;
-      }
+  // Start with the target directory.
+  std::string obj = this->GetTargetDirectory(target);
+  obj += "/";
 
-    // Append the object name to the target directory.
-    obj += objectName;
-    return obj;
+  // Get the object file name without the target directory.
+  std::string::size_type dir_len = 0;
+  dir_len += strlen(this->Makefile->GetCurrentOutputDirectory());
+  dir_len += 1;
+  dir_len += obj.size();
+  std::string objectName =
+    this->GetObjectFileNameWithoutTarget(source, dir_len,
+                                         hasSourceExtension);
+  if(nameWithoutTargetDir)
+    {
+    *nameWithoutTargetDir = objectName;
     }
+
+  // Append the object name to the target directory.
+  obj += objectName;
+  return obj;
 }
 
 //----------------------------------------------------------------------------

Index: cmMakefileTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.cxx,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- cmMakefileTargetGenerator.cxx	30 Jan 2008 01:46:25 -0000	1.88
+++ cmMakefileTargetGenerator.cxx	15 Feb 2008 16:22:23 -0000	1.89
@@ -150,6 +150,11 @@
           }
         }
       }
+    else if(const char* pkgloc =
+            (*source)->GetProperty("MACOSX_PACKAGE_LOCATION"))
+      {
+      this->WriteMacOSXContentRules(*(*source), pkgloc);
+      }
     else if(!(*source)->GetPropertyAsBool("HEADER_FILE_ONLY"))
       {
       if(!this->GlobalGenerator->IgnoreFile
@@ -314,6 +319,62 @@
 }
 
 //----------------------------------------------------------------------------
+void cmMakefileTargetGenerator::WriteMacOSXContentRules(cmSourceFile& source,
+                                                        const char* pkgloc)
+{
+  // Skip OS X bundle content when not building a bundle.
+  if(!this->Target->IsAppBundleOnApple()) { return; }
+
+  // Create the directory in which the content is to be placed.
+  std::string targetName;
+  std::string targetNameReal;
+  std::string targetNameImport;
+  std::string targetNamePDB;
+  this->Target->GetExecutableNames
+    (targetName, targetNameReal, targetNameImport, targetNamePDB,
+     this->LocalGenerator->ConfigurationName.c_str());
+  std::string macdir = this->Target->GetDirectory();
+  macdir += "/";
+  macdir += targetName;
+  macdir += ".app/Contents/";
+  macdir += pkgloc;
+  cmSystemTools::MakeDirectory(macdir.c_str());
+
+  // Get the input file location.
+  std::string input = source.GetFullPath();
+
+  // Get the output file location.
+  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);
+
+  // Create a rule to copy the content into the bundle.
+  std::vector<std::string> depends;
+  std::vector<std::string> commands;
+  depends.push_back(input);
+  std::string copyEcho = "Copying Bundle content ";
+  copyEcho += output;
+  this->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 += " ";
+  copyCommand += this->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);
+}
+
+//----------------------------------------------------------------------------
 void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
 {
   // Identify the language of the source file.
@@ -356,10 +417,6 @@
     (this->LocalGenerator->ConvertToFullPath(dir).c_str());
 
   // Save this in the target's list of object files.
-  if ( source.GetPropertyAsBool("EXTRA_CONTENT") )
-    {
-    this->ExtraContent.insert(obj);
-    }
   this->Objects.push_back(obj);
   this->CleanFiles.push_back(obj);
 
@@ -417,10 +474,6 @@
   this->WriteObjectDependRules(source, depends);
 
   std::string relativeObj = this->LocalGenerator->GetHomeRelativeOutputPath();
-  if ( source.GetPropertyAsBool("MACOSX_CONTENT") )
-    {
-    relativeObj = "";
-    }
   relativeObj += obj;
   // Write the build rule.
 
@@ -1143,10 +1196,6 @@
   for(std::vector<std::string>::const_iterator i = this->Objects.begin();
       i != this->Objects.end(); ++i)
     {
-    if ( this->ExtraContent.find(i->c_str()) != this->ExtraContent.end() )
-      {
-      continue;
-      }
     *this->BuildFileStream << " " << lineContinue << "\n";
     if(objName)
       {
@@ -1277,10 +1326,6 @@
   for(std::vector<std::string>::const_iterator i = this->Objects.begin();
       i != this->Objects.end(); ++i)
     {
-    if ( this->ExtraContent.find(i->c_str()) != this->ExtraContent.end() )
-      {
-      continue;
-      }
     helper.Feed(*i);
     }
   for(std::vector<std::string>::const_iterator i =
@@ -1328,6 +1373,13 @@
       {
       this->DriveCustomCommands(depends);
       }
+
+    // Make sure the extra files are built.
+    for(std::set<cmStdString>::const_iterator i = this->ExtraFiles.begin();
+        i != this->ExtraFiles.end(); ++i)
+      {
+      depends.push_back(*i);
+      }
     }
 
   // Write the driver rule.

Index: cmSetSourceFilesPropertiesCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetSourceFilesPropertiesCommand.cxx,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- cmSetSourceFilesPropertiesCommand.cxx	23 Jan 2008 15:27:59 -0000	1.18
+++ cmSetSourceFilesPropertiesCommand.cxx	15 Feb 2008 16:22:23 -0000	1.19
@@ -119,7 +119,6 @@
       {
       // now loop through the rest of the arguments, new style
       ++j;
-      bool dontPush = false;
       while (j != propend)
         {
         propertyPairs.push_back(*j);
@@ -131,26 +130,6 @@
             generated = true;
             }
           }
-        else if(*j == "MACOSX_PACKAGE_LOCATION")
-          {
-          ++j;
-          if(j == propend)
-            {
-            errors = "called with incorrect number of arguments "
-              "MACOSX_PACKAGE_LOCATION with no flags";
-            return false;
-            }
-          propertyPairs.push_back(*j);
-          propertyPairs.push_back("EXTRA_CONTENT");
-          propertyPairs.push_back("1");
-          propertyPairs.push_back("MACOSX_CONTENT");
-          propertyPairs.push_back("1");
-          propertyPairs.push_back("KEEP_EXTENSION");
-          propertyPairs.push_back("1");
-          propertyPairs.push_back("LANGUAGE");
-          propertyPairs.push_back("MacOSX_Content");
-          dontPush = true;
-          }
         else
           {
           ++j;
@@ -160,12 +139,8 @@
           errors = "called with incorrect number of arguments.";
           return false;
           }
-        if ( !dontPush )
-          {
-          propertyPairs.push_back(*j);
-          }
+        propertyPairs.push_back(*j);
         ++j;
-        dontPush = false;
         }
       // break out of the loop because j is already == end
       break;



More information about the Cmake-commits mailing list