[cmake-commits] david.cole committed cmMakefileLibraryTargetGenerator.cxx 1.45 1.46 cmMakefileLibraryTargetGenerator.h 1.4 1.5

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Aug 14 14:12:10 EDT 2007


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

Modified Files:
	cmMakefileLibraryTargetGenerator.cxx 
	cmMakefileLibraryTargetGenerator.h 
Log Message:
ENH: Improve framework support in the makefile generator to match the support just added to the Xcode generator. BUG: Remove spurious warning and eliminate empty Libraries subdir inside built framework.


Index: cmMakefileLibraryTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileLibraryTargetGenerator.cxx,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- cmMakefileLibraryTargetGenerator.cxx	2 Aug 2007 13:37:10 -0000	1.45
+++ cmMakefileLibraryTargetGenerator.cxx	14 Aug 2007 18:12:08 -0000	1.46
@@ -89,7 +89,6 @@
   this->CloseFileStreams();
 }
 
-
 //----------------------------------------------------------------------------
 void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
 {
@@ -219,7 +218,6 @@
   this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
 }
 
-
 //----------------------------------------------------------------------------
 void cmMakefileLibraryTargetGenerator::CreateFrameworkLinksAndDirs(
   std::string& targetName,
@@ -255,113 +253,87 @@
   cmSystemTools::CreateSymlink(symlink.c_str(), symlink2.c_str());
   this->Makefile->AddCMakeOutputFile((outpath + "Resources").c_str());
   // Libraries -> Versions/Current/Libraries
-  symlink = "Versions/Current/Libraries";
-  symlink2 = "Libraries";
-  cmSystemTools::CreateSymlink(symlink.c_str(), symlink2.c_str());
-  this->Makefile->AddCMakeOutputFile((outpath + "Libraries").c_str());
+  //symlink = "Versions/Current/Libraries";
+  //symlink2 = "Libraries";
+  //cmSystemTools::CreateSymlink(symlink.c_str(), symlink2.c_str());
+  //this->Makefile->AddCMakeOutputFile((outpath + "Libraries").c_str());
   // Headers -> Versions/Current/Headers
   symlink = "Versions/Current/Headers";
   symlink2 = "Headers";
   cmSystemTools::CreateSymlink(symlink.c_str(), symlink2.c_str());
   this->Makefile->AddCMakeOutputFile((outpath + "Headers").c_str());
+  symlink = "Versions/Current/PrivateHeaders";
+  symlink2 = "PrivateHeaders";
+  cmSystemTools::CreateSymlink(symlink.c_str(), symlink2.c_str());
+  this->Makefile->AddCMakeOutputFile((outpath + "PrivateHeaders").c_str());
   // go back to where we were
   cmSystemTools::ChangeDirectory(cwd.c_str());
 }
 
 //----------------------------------------------------------------------------
-void cmMakefileLibraryTargetGenerator::CopyFrameworkPublicHeaders(
+void cmMakefileLibraryTargetGenerator::CopyFrameworkSources(
   std::string& targetName,
   std::string& outpath,
-  const char* /*version*/)
+  const char* /*version*/ ,
+  const char* propertyName,
+  const char* subdir)
 {
   std::string fullOutput=  outpath + targetName;
-  const char* headers = this->Target->GetProperty("FRAMEWORK_PUBLIC_HEADERS");
-  if(!headers)
-    {
-    return;
-    }
-  std::vector<std::string> headersVec;
-  cmSystemTools::ExpandListArgument(headers,
-                                    headersVec);
   cmCustomCommandLines commandLines;
   std::vector<std::string> depends;
-  for(std::vector<std::string>::iterator i = headersVec.begin();
-      i != headersVec.end(); ++i)
-    {
-    cmCustomCommandLine line;
-    cmSourceFile* sf = this->Makefile->GetOrCreateSource(i->c_str());
-    std::string dest = outpath + "Headers/";
-    dest += cmSystemTools::GetFilenameName(sf->GetFullPath());
-    line.push_back("$(CMAKE_COMMAND)");
-    line.push_back("-E");
-    line.push_back("copy_if_different");
-    line.push_back(sf->GetFullPath());
-    depends.push_back(sf->GetFullPath());
-    line.push_back(dest);
-    commandLines.push_back(line);
-    // make sure the target gets rebuilt if any of the headers is removed
-    this->GenerateExtraOutput(dest.c_str(),
-                              fullOutput.c_str());
-    }
-  // add a set of prebuild commands to run on the target
-  this->Makefile->
-    AddCustomCommandToTarget(this->Target->GetName(),
-                             depends,
-                             commandLines,
-                             cmTarget::PRE_BUILD,
-                             "copy files",
-                             this->Makefile->GetCurrentOutputDirectory());
-}
+  const std::vector<cmSourceFile*>& sources =
+    this->Target->GetSourceFiles();
 
-//----------------------------------------------------------------------------
-void cmMakefileLibraryTargetGenerator::CopyFrameworkResources(
-  std::string& targetName,
-  std::string& outpath,
-  const char* /*version*/)
-{
-  std::string fullOutput=  outpath + targetName;
-  const char* resources = this->Target->GetProperty("FRAMEWORK_RESOURCES");
-  if(!resources)
-    {
-    return;
-    }
-  std::vector<std::string> resourcesVec;
-  cmSystemTools::ExpandListArgument(resources,
-                                    resourcesVec);
-  cmCustomCommandLines commandLines;
-  std::vector<std::string> depends;
-  for(std::vector<std::string>::iterator i = resourcesVec.begin();
-      i != resourcesVec.end(); ++i)
+  for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
+      i != sources.end(); ++i)
     {
-    cmCustomCommandLine line;
-    cmSourceFile* sf = this->Makefile->GetOrCreateSource(i->c_str());
+    cmSourceFile* sf = *i;
+
     if(!sf)
       {
       cmSystemTools::Error(
-        "could not find resource file.", i->c_str());
+        "could not find framework source file", "");
       continue;
       }
-    std::string dest = outpath + "Resources/";
-    dest += cmSystemTools::GetFilenameName(sf->GetFullPath());
-    line.push_back("$(CMAKE_COMMAND)");
-    line.push_back("-E");
-    line.push_back("copy_if_different");
-    line.push_back(sf->GetFullPath());
-    depends.push_back(sf->GetFullPath());
-    line.push_back(dest);
-    commandLines.push_back(line);
-    // make sure the target gets rebuilt if any of the resources is removed
-    this->GenerateExtraOutput(dest.c_str(),
-                              fullOutput.c_str());
+
+    // If processing public headers, skip headers also marked with the private
+    // property. Private wins.
+    //
+    if((std::string(propertyName) == "FRAMEWORK_PUBLIC_HEADER") &&
+      sf->GetPropertyAsBool("FRAMEWORK_PRIVATE_HEADER"))
+      {
+      continue;
+      }
+
+    if(sf->GetPropertyAsBool(propertyName))
+      {
+      cmCustomCommandLine line;
+      std::string dest = outpath + subdir + "/";
+      dest += cmSystemTools::GetFilenameName(sf->GetFullPath());
+      line.push_back("$(CMAKE_COMMAND)");
+      line.push_back("-E");
+      line.push_back("copy_if_different");
+      line.push_back(sf->GetFullPath());
+      depends.push_back(sf->GetFullPath());
+      line.push_back(dest);
+      commandLines.push_back(line);
+      // make sure the target gets rebuilt if any of the headers is removed
+      this->GenerateExtraOutput(dest.c_str(),
+                                fullOutput.c_str());
+      }
     }
+
   // add a set of prebuild commands to run on the target
-  this->Makefile->
-    AddCustomCommandToTarget(this->Target->GetName(),
-                             depends,
-                             commandLines,
-                             cmTarget::PRE_BUILD,
-                             "copy files",
-                             this->Makefile->GetCurrentOutputDirectory());
+  if(!commandLines.empty())
+    {
+    this->Makefile->
+      AddCustomCommandToTarget(this->Target->GetName(),
+                               depends,
+                               commandLines,
+                               cmTarget::PRE_BUILD,
+                               "copy files",
+                               this->Makefile->GetCurrentOutputDirectory());
+    }
 }
 
 //----------------------------------------------------------------------------
@@ -374,11 +346,11 @@
   if(!version)
     {
     version = "A";
-    std::string message = 
-      "Warning: FRAMEWORK_VERSION property not found on ";
-    message += targetName;
-    message += ".  Default to verison A.";
-    cmSystemTools::Message(message.c_str());
+    //std::string message = 
+    //  "Warning: FRAMEWORK_VERSION property not found on ";
+    //message += targetName;
+    //message += ".  Default to version A.";
+    //cmSystemTools::Message(message.c_str());
     }
   // create the symbolic links and directories
   this->CreateFrameworkLinksAndDirs(targetName,
@@ -391,7 +363,7 @@
   outpath += version;
   outpath += "/";
 
-  cmSystemTools::MakeDirectory((macdir + "Libraries").c_str());
+  //cmSystemTools::MakeDirectory((macdir + "Libraries").c_str());
   cmSystemTools::MakeDirectory((macdir + "Headers").c_str());
   // Configure the Info.plist file.  Note that it needs the executable name
   // to be set
@@ -409,12 +381,15 @@
   std::string f2 = rsrcDir + "Info.plist";
   this->Makefile->ConfigureFile(f1.c_str(), f2.c_str(),
                                 false, false, false);
-  this->CopyFrameworkPublicHeaders(targetName,
-                                   outpath,
-                                   version);
-  this->CopyFrameworkResources(targetName,
-                               outpath,
-                               version);
+
+  this->CopyFrameworkSources(targetName, outpath, version,
+    "FRAMEWORK_PRIVATE_HEADER", "PrivateHeaders");
+
+  this->CopyFrameworkSources(targetName, outpath, version,
+    "FRAMEWORK_PUBLIC_HEADER", "Headers");
+
+  this->CopyFrameworkSources(targetName, outpath, version,
+    "FRAMEWORK_RESOURCE", "Resources");
 }
 
 //----------------------------------------------------------------------------

Index: cmMakefileLibraryTargetGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileLibraryTargetGenerator.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- cmMakefileLibraryTargetGenerator.h	8 May 2007 14:32:54 -0000	1.4
+++ cmMakefileLibraryTargetGenerator.h	14 Aug 2007 18:12:08 -0000	1.5
@@ -38,16 +38,15 @@
   // MacOSX Framework support methods
   void WriteFrameworkRules(bool relink);
   void CreateFramework(std::string& targetName,
-                             std::string& outpath);
+                       std::string& outpath);
   void CreateFrameworkLinksAndDirs(std::string& targetName,
-                                         std::string& outpath,
-                                         const char* version);
-  void CopyFrameworkPublicHeaders(std::string& targetName,
-                         std::string& outpath,
-                         const char* version);
-  void CopyFrameworkResources(std::string& targetName,
-                         std::string& outpath,
-                         const char* version);
+                                   std::string& outpath,
+                                   const char* version);
+  void CopyFrameworkSources(std::string& targetName,
+                            std::string& outpath,
+                            const char* version,
+                            const char* propertyName,
+                            const char* subdir);
 };
 
 #endif



More information about the Cmake-commits mailing list