[cmake-commits] david.cole committed cmGlobalGenerator.cxx 1.207 1.208 cmGlobalGenerator.h 1.95 1.96 cmGlobalXCodeGenerator.cxx 1.167 1.168 cmInstallCommand.cxx 1.33 1.34 cmInstallTargetGenerator.cxx 1.46 1.47 cmMakefileLibraryTargetGenerator.cxx 1.46 1.47 cmMakefileTargetGenerator.cxx 1.70 1.71 cmOrderLinkDirectories.cxx 1.37 1.38 cmTarget.cxx 1.163 1.164 cmTarget.h 1.91 1.92

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Oct 10 11:06:16 EDT 2007


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

Modified Files:
	cmGlobalGenerator.cxx cmGlobalGenerator.h 
	cmGlobalXCodeGenerator.cxx cmInstallCommand.cxx 
	cmInstallTargetGenerator.cxx 
	cmMakefileLibraryTargetGenerator.cxx 
	cmMakefileTargetGenerator.cxx cmOrderLinkDirectories.cxx 
	cmTarget.cxx cmTarget.h 
Log Message:
ENH: Finish up the Framework creation code restructuring. Frameworks build and install now. More work needed on the packaging step. See Tests/Framework for example use.


Index: cmGlobalXCodeGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.cxx,v
retrieving revision 1.167
retrieving revision 1.168
diff -u -d -r1.167 -r1.168
--- cmGlobalXCodeGenerator.cxx	17 Sep 2007 14:40:57 -0000	1.167
+++ cmGlobalXCodeGenerator.cxx	10 Oct 2007 15:06:14 -0000	1.168
@@ -23,7 +23,6 @@
 #include "cmake.h"
 #include "cmGeneratedFileStream.h"
 #include "cmSourceFile.h"
-#include "cmOrderLinkDirectories.h"
 
 //----------------------------------------------------------------------------
 #if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -428,18 +427,6 @@
 }
 
 //----------------------------------------------------------------------------
-bool IsResource(cmSourceFile* sf)
-{
-  const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION");
-
-  bool isResource =
-    (sf->GetPropertyAsBool("FRAMEWORK_RESOURCE") ||
-     (location && cmStdString(location) == "Resources"));
-
-  return isResource;
-}
-
-//----------------------------------------------------------------------------
 cmStdString GetGroupMapKey(cmTarget& cmtarget, cmSourceFile* sf)
 {
   cmStdString key(cmtarget.GetName());
@@ -449,8 +436,8 @@
 }
 
 //----------------------------------------------------------------------------
-cmXCodeObject* 
-cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, 
+cmXCodeObject*
+cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
                                               cmSourceFile* sf,
                                               cmTarget& cmtarget)
 {
@@ -498,7 +485,8 @@
 
   // Is this a resource file in this target? Add it to the resources group...
   //
-  bool isResource = IsResource(sf);
+  cmTarget::SourceFileFlags tsFlags = cmtarget.GetTargetSourceFileFlags(sf);
+  bool isResource = tsFlags.Resource;
 
   // Is this a "private" or "public" framework header file?
   // Set the ATTRIBUTES attribute appropriately...
@@ -506,14 +494,14 @@
   if(cmtarget.GetType() == cmTarget::SHARED_LIBRARY &&
      cmtarget.GetPropertyAsBool("FRAMEWORK"))
     {
-    if(sf->GetPropertyAsBool("FRAMEWORK_PRIVATE_HEADER"))
+    if(tsFlags.PrivateHeader)
       {
       cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
       attrs->AddObject(this->CreateString("Private"));
       settings->AddAttribute("ATTRIBUTES", attrs);
       isResource = true;
       }
-    else if(sf->GetPropertyAsBool("FRAMEWORK_PUBLIC_HEADER"))
+    else if(tsFlags.PublicHeader)
       {
       cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
       attrs->AddObject(this->CreateString("Public"));
@@ -693,6 +681,9 @@
       cmXCodeObject* filetype = 
         fr->GetObject()->GetObject("lastKnownFileType");
 
+      cmTarget::SourceFileFlags tsFlags =
+        cmtarget.GetTargetSourceFileFlags(*i);
+
       if(strcmp(filetype->GetString(), "\"compiled.mach-o.objfile\"") == 0)
         {
         externalObjFiles.push_back(xsf);
@@ -701,7 +692,7 @@
         {
         headerFiles.push_back(xsf);
         }
-      else if(IsResource(*i))
+      else if(tsFlags.Resource)
         {
         resourceFiles.push_back(xsf);
         }
@@ -813,8 +804,8 @@
           }
         copyFilesBuildPhase->AddAttribute("dstPath",
           this->CreateString(ostr.str().c_str()));
-        copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
-          this->CreateString("0"));
+        copyFilesBuildPhase->AddAttribute(
+          "runOnlyForDeploymentPostprocessing", this->CreateString("0"));
         buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
         copyFilesBuildPhase->AddAttribute("files", buildFiles);
         std::vector<cmSourceFile*>::iterator sfIt;
@@ -1418,6 +1409,14 @@
       productType = "com.apple.product-type.framework";
 
       const char* version = target.GetProperty("FRAMEWORK_VERSION");
+      if(!version)
+        {
+        version = target.GetProperty("VERSION");
+        }
+      if(!version)
+        {
+        version = "A";
+        }
       buildSettings->AddAttribute("FRAMEWORK_VERSION",
                                   this->CreateString(version));
       }
@@ -1501,7 +1500,7 @@
   for(std::vector<std::string>::iterator i = includes.begin();
       i != includes.end(); ++i)
     {
-    if(cmSystemTools::IsPathToFramework(i->c_str()))
+    if(this->NameResolvesToFramework(i->c_str()))
       {
       std::string frameworkDir = *i;
       frameworkDir += "/../";
@@ -1927,9 +1926,22 @@
     else
       {
       std::string oldValue = attr->GetString();
-      cmSystemTools::ReplaceString(oldValue, "\"", "");
+
+      // unescape escaped quotes internal to the string:
+      cmSystemTools::ReplaceString(oldValue, "\\\"", "\"");
+
+      // remove surrounding quotes, if any:
+      std::string::size_type len = oldValue.length();
+      if(oldValue[0] == '\"' && oldValue[len-1] == '\"')
+        {
+        oldValue = oldValue.substr(1, len-2);
+        }
+
       oldValue += " ";
       oldValue += value;
+
+      // SetString automatically escapes internal quotes and then surrounds
+      // the result with quotes if necessary...
       attr->SetString(oldValue.c_str());
       }
     }
@@ -2098,8 +2110,8 @@
           {
           // now add the same one but append $(CONFIGURATION) to it:
           linkDirs += " ";
-          linkDirs += this->XCodeEscapePath(libDir->c_str());
-          linkDirs += "/$(CONFIGURATION)";
+          linkDirs += this->XCodeEscapePath(
+            (*libDir + "/$(CONFIGURATION)").c_str());
           }
         linkDirs += " ";
         linkDirs += this->XCodeEscapePath(libDir->c_str());
@@ -2506,8 +2518,8 @@
   // one more pass for external depend information not handled
   // correctly by xcode
   makefileStream << "# DO NOT EDIT\n";
-  makefileStream << "# This makefile makes sure all linkable targets are \n";
-  makefileStream << "# up-to-date with anything they link to,avoiding a "
+  makefileStream << "# This makefile makes sure all linkable targets are\n";
+  makefileStream << "# up-to-date with anything they link to, avoiding a "
     "bug in XCode 1.5\n";
   for(std::vector<std::string>::const_iterator
         ct = this->CurrentConfigurationTypes.begin();
@@ -2826,10 +2838,13 @@
       {
       if(dir.find(".framework") != dir.npos)
         {
+        // Remove trailing slashes (so that the rfind does not find the one at
+        // the very end...!)
+        //
+        cmSystemTools::ConvertToUnixSlashes(dir);
         std::string::size_type pos = dir.rfind("/");
         std::string framework = dir.substr(pos);
-        std::string newDir;
-        newDir = dir.substr(0, pos);
+        std::string newDir = dir.substr(0, pos);
         newDir += "/";
         newDir += config;
         dir = newDir;

Index: cmGlobalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.h,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -d -r1.95 -r1.96
--- cmGlobalGenerator.h	31 Aug 2007 17:42:21 -0000	1.95
+++ cmGlobalGenerator.h	10 Oct 2007 15:06:14 -0000	1.96
@@ -187,6 +187,10 @@
                        const char* name, 
                        bool useImportedTargets);
 
+  /** Determine if a name resolves to a framework on disk or a built target
+      that is a framework. */
+  bool NameResolvesToFramework(const std::string& libname);
+
   /** If check to see if the target is linked to by any other
       target in the project */
   bool IsDependedOn(const char* project, cmTarget* target);

Index: cmGlobalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.cxx,v
retrieving revision 1.207
retrieving revision 1.208
diff -u -d -r1.207 -r1.208
--- cmGlobalGenerator.cxx	31 Aug 2007 17:45:02 -0000	1.207
+++ cmGlobalGenerator.cxx	10 Oct 2007 15:06:14 -0000	1.208
@@ -1277,6 +1277,7 @@
 }
 
 
+//----------------------------------------------------------------------------
 cmTarget* cmGlobalGenerator::FindTarget(const char* project,
                                         const char* name,
                                         bool useImportedTargets)
@@ -1318,6 +1319,27 @@
   return 0;
 }
 
+//----------------------------------------------------------------------------
+bool cmGlobalGenerator::NameResolvesToFramework(const std::string& libname)
+{
+  if(cmSystemTools::IsPathToFramework(libname.c_str()))
+    {
+    return true;
+    }
+
+  if(cmTarget* tgt = this->FindTarget(0, libname.c_str(), true))
+    {
+    if(tgt->GetType() == cmTarget::SHARED_LIBRARY &&
+       tgt->GetPropertyAsBool("FRAMEWORK"))
+       {
+       return true;
+       }
+    }
+
+  return false;
+}
+
+//----------------------------------------------------------------------------
 inline std::string removeQuotes(const std::string& s)
 {
   if(s[0] == '\"' && s[s.size()-1] == '\"')

Index: cmMakefileLibraryTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileLibraryTargetGenerator.cxx,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- cmMakefileLibraryTargetGenerator.cxx	14 Aug 2007 18:12:08 -0000	1.46
+++ cmMakefileLibraryTargetGenerator.cxx	10 Oct 2007 15:06:14 -0000	1.47
@@ -252,16 +252,12 @@
   symlink2 = "Resources";
   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());
   // 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());
+  // PrivateHeaders -> Versions/Current/PrivateHeaders
   symlink = "Versions/Current/PrivateHeaders";
   symlink2 = "PrivateHeaders";
   cmSystemTools::CreateSymlink(symlink.c_str(), symlink2.c_str());
@@ -278,12 +274,14 @@
   const char* propertyName,
   const char* subdir)
 {
-  std::string fullOutput=  outpath + targetName;
+  std::string fullOutput = outpath + targetName;
   cmCustomCommandLines commandLines;
   std::vector<std::string> depends;
   const std::vector<cmSourceFile*>& sources =
     this->Target->GetSourceFiles();
 
+  std::string propName(propertyName);
+
   for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
       i != sources.end(); ++i)
     {
@@ -296,16 +294,20 @@
       continue;
       }
 
+    cmTarget::SourceFileFlags tsFlags =
+      this->Target->GetTargetSourceFileFlags(sf);
+
     // 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"))
+    if(tsFlags.PrivateHeader && (propName == "PUBLIC_HEADER"))
       {
       continue;
       }
 
-    if(sf->GetPropertyAsBool(propertyName))
+    if(tsFlags.PrivateHeader && (propName == "PRIVATE_HEADER") ||
+      tsFlags.PublicHeader && (propName == "PUBLIC_HEADER") ||
+      tsFlags.Resource && (propName == "RESOURCE"))
       {
       cmCustomCommandLine line;
       std::string dest = outpath + subdir + "/";
@@ -318,8 +320,7 @@
       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());
+      this->GenerateExtraOutput(dest.c_str(), fullOutput.c_str());
       }
     }
 
@@ -345,12 +346,11 @@
   const char* version = this->Target->GetProperty("FRAMEWORK_VERSION");
   if(!version)
     {
+    version = this->Target->GetProperty("VERSION");
+    }
+  if(!version)
+    {
     version = "A";
-    //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,
@@ -383,13 +383,13 @@
                                 false, false, false);
 
   this->CopyFrameworkSources(targetName, outpath, version,
-    "FRAMEWORK_PRIVATE_HEADER", "PrivateHeaders");
+    "PRIVATE_HEADER", "PrivateHeaders");
 
   this->CopyFrameworkSources(targetName, outpath, version,
-    "FRAMEWORK_PUBLIC_HEADER", "Headers");
+    "PUBLIC_HEADER", "Headers");
 
   this->CopyFrameworkSources(targetName, outpath, version,
-    "FRAMEWORK_RESOURCE", "Resources");
+    "RESOURCE", "Resources");
 }
 
 //----------------------------------------------------------------------------

Index: cmInstallCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallCommand.cxx,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- cmInstallCommand.cxx	31 Aug 2007 20:52:32 -0000	1.33
+++ cmInstallCommand.cxx	10 Oct 2007 15:06:14 -0000	1.34
@@ -175,9 +175,9 @@
   cmCAStringVector runtimeArgVector     (&argHelper, "RUNTIME", &group);
   cmCAStringVector frameworkArgVector   (&argHelper, "FRAMEWORK", &group);
   cmCAStringVector bundleArgVector      (&argHelper, "BUNDLE", &group);
-  cmCAStringVector resourcesArgVector   (&argHelper, "RESOURCE", &group);
-  cmCAStringVector publicHeaderArgVector(&argHelper, "PUBLIC_HEADER", &group);
   cmCAStringVector privateHeaderArgVector(&argHelper,"PRIVATE_HEADER", &group);
+  cmCAStringVector publicHeaderArgVector(&argHelper, "PUBLIC_HEADER", &group);
+  cmCAStringVector resourceArgVector   (&argHelper, "RESOURCE", &group);
   genericArgVector.Follows(0);
   group.Follows(&genericArgVector);
 
@@ -197,18 +197,18 @@
   cmInstallCommandArguments runtimeArgs;
   cmInstallCommandArguments frameworkArgs;
   cmInstallCommandArguments bundleArgs;
-  cmInstallCommandArguments resourcesArgs;
-  cmInstallCommandArguments publicHeaderArgs;
   cmInstallCommandArguments privateHeaderArgs;
+  cmInstallCommandArguments publicHeaderArgs;
+  cmInstallCommandArguments resourceArgs;
 
   archiveArgs.Parse      (&archiveArgVector.GetVector(),       &unknownArgs);
   libraryArgs.Parse      (&libraryArgVector.GetVector(),       &unknownArgs);
   runtimeArgs.Parse      (&runtimeArgVector.GetVector(),       &unknownArgs);
   frameworkArgs.Parse    (&frameworkArgVector.GetVector(),     &unknownArgs);
   bundleArgs.Parse       (&bundleArgVector.GetVector(),        &unknownArgs);
-  resourcesArgs.Parse    (&resourcesArgVector.GetVector(),     &unknownArgs);
-  publicHeaderArgs.Parse (&publicHeaderArgVector.GetVector(),  &unknownArgs);
   privateHeaderArgs.Parse(&privateHeaderArgVector.GetVector(), &unknownArgs);
+  publicHeaderArgs.Parse (&publicHeaderArgVector.GetVector(),  &unknownArgs);
+  resourceArgs.Parse     (&resourceArgVector.GetVector(),      &unknownArgs);
 
   if(!unknownArgs.empty())
     {
@@ -225,18 +225,18 @@
   runtimeArgs.SetGenericArguments(&genericArgs);
   frameworkArgs.SetGenericArguments(&genericArgs);
   bundleArgs.SetGenericArguments(&genericArgs);
-  resourcesArgs.SetGenericArguments(&genericArgs);
-  publicHeaderArgs.SetGenericArguments(&genericArgs);
   privateHeaderArgs.SetGenericArguments(&genericArgs);
+  publicHeaderArgs.SetGenericArguments(&genericArgs);
+  resourceArgs.SetGenericArguments(&genericArgs);
 
   success = success && archiveArgs.Finalize();
   success = success && libraryArgs.Finalize();
   success = success && runtimeArgs.Finalize();
   success = success && frameworkArgs.Finalize();
   success = success && bundleArgs.Finalize();
-  success = success && resourcesArgs.Finalize();
-  success = success && publicHeaderArgs.Finalize();
   success = success && privateHeaderArgs.Finalize();
+  success = success && publicHeaderArgs.Finalize();
+  success = success && resourceArgs.Finalize();
 
   if(!success)
     {
@@ -299,9 +299,9 @@
     cmInstallTargetGenerator* runtimeGenerator = 0;
     cmInstallTargetGenerator* frameworkGenerator = 0;
     cmInstallTargetGenerator* bundleGenerator = 0;
-    cmInstallFilesGenerator* resourcesGenerator = 0;
-    cmInstallFilesGenerator* publicHeaderGenerator = 0;
     cmInstallFilesGenerator* privateHeaderGenerator = 0;
+    cmInstallFilesGenerator* publicHeaderGenerator = 0;
+    cmInstallFilesGenerator* resourceGenerator = 0;
 
     switch(target.GetType())
       {
@@ -465,84 +465,98 @@
 
 //       if(target.GetProperty("ASSOCIATED_FILES");
 
-  const char* files = target.GetProperty("PUBLIC_HEADER");
-  if ((files) && (*files))
-    {
-    std::vector<std::string> relFiles;
-    cmSystemTools::ExpandListArgument(files, relFiles);
-    std::vector<std::string> absFiles;
-    if (!this->MakeFilesFullPath("PUBLIC_HEADER", relFiles, absFiles))
-      {
-      return false;
-      }
+  // These well-known sets of files are installed *automatically* for FRAMEWORK
+  // SHARED library targets on the Mac as part of installing the FRAMEWORK.
+  // For other target types or on other platforms, they are not installed
+  // automatically and so we need to create install files generators for them.
+  //
+  bool createInstallGeneratorsForTargetFileSets = true;
 
-    // Create the files install generator.
-    if (!publicHeaderArgs.GetDestination().empty())
-      {
-      publicHeaderGenerator = CreateInstallFilesGenerator(absFiles, 
-                                                      publicHeaderArgs, false);
-      }
-    else
-      {
-      cmOStringStream e;
-      e << "TARGETS given no PUBLIC_HEADER DESTINATION for header files\"" 
-          << target.GetName() << "\".";
-      this->SetError(e.str().c_str());
-      return false;
-      }
+  if(cmTarget::SHARED_LIBRARY == target.GetType() &&
+    target.GetPropertyAsBool("FRAMEWORK") &&
+    this->Makefile->IsOn("APPLE"))
+    {
+    createInstallGeneratorsForTargetFileSets = false;
     }
 
-  files = target.GetProperty("PRIVATE_HEADER");
-  if ((files) && (*files))
+  if(createInstallGeneratorsForTargetFileSets)
     {
-    std::vector<std::string> relFiles;
-    cmSystemTools::ExpandListArgument(files, relFiles);
-    std::vector<std::string> absFiles;
-    if (!this->MakeFilesFullPath("PRIVATE_HEADER", relFiles, absFiles))
+    const char* files = target.GetProperty("PRIVATE_HEADER");
+    if ((files) && (*files))
       {
-      return false;
-      }
+      std::vector<std::string> relFiles;
+      cmSystemTools::ExpandListArgument(files, relFiles);
+      std::vector<std::string> absFiles;
+      if (!this->MakeFilesFullPath("PRIVATE_HEADER", relFiles, absFiles))
+        {
+        return false;
+        }
 
-    // Create the files install generator.
-    if (!privateHeaderArgs.GetDestination().empty())
-      {
-      privateHeaderGenerator = CreateInstallFilesGenerator(absFiles, 
+      // Create the files install generator.
+      if (!privateHeaderArgs.GetDestination().empty())
+        {
+        privateHeaderGenerator = CreateInstallFilesGenerator(absFiles, 
                                                      privateHeaderArgs, false);
+        }
+      else
+        {
+        cmOStringStream e;
+        e << "INSTALL TARGETS - target " << target.GetName() << " has "
+          << "PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION.";
+        cmSystemTools::Message(e.str().c_str(), "Warning");
+        }
       }
-    else
-      {
-      cmOStringStream e;
-      e << "TARGETS given no PRIVATE_HEADER DESTINATION for header files\"" 
-          << target.GetName() << "\".";
-      this->SetError(e.str().c_str());
-      return false;
-      }
-    }
 
-  files = target.GetProperty("RESOURCE_FILES");
-  if ((files) && (*files))
-    {
-    std::vector<std::string> relFiles;
-    cmSystemTools::ExpandListArgument(files, relFiles);
-    std::vector<std::string> absFiles;
-    if (!this->MakeFilesFullPath("RESOURCE_FILES", relFiles, absFiles))
+    files = target.GetProperty("PUBLIC_HEADER");
+    if ((files) && (*files))
       {
-      return false;
-      }
+      std::vector<std::string> relFiles;
+      cmSystemTools::ExpandListArgument(files, relFiles);
+      std::vector<std::string> absFiles;
+      if (!this->MakeFilesFullPath("PUBLIC_HEADER", relFiles, absFiles))
+        {
+        return false;
+        }
 
-    // Create the files install generator.
-    if (!privateHeaderArgs.GetDestination().empty())
-      {
-      resourcesGenerator = CreateInstallFilesGenerator(absFiles, 
-                                                       resourcesArgs, false);
+      // Create the files install generator.
+      if (!publicHeaderArgs.GetDestination().empty())
+        {
+        publicHeaderGenerator = CreateInstallFilesGenerator(absFiles, 
+                                                      publicHeaderArgs, false);
+        }
+      else
+        {
+        cmOStringStream e;
+        e << "INSTALL TARGETS - target " << target.GetName() << " has "
+          << "PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION.";
+        cmSystemTools::Message(e.str().c_str(), "Warning");
+        }
       }
-    else
+
+    files = target.GetProperty("RESOURCE");
+    if ((files) && (*files))
       {
-      cmOStringStream e;
-      e << "TARGETS given no RESOURCES DESTINATION for resource files\"" 
-          << target.GetName() << "\".";
-      this->SetError(e.str().c_str());
-      return false;
+      std::vector<std::string> relFiles;
+      cmSystemTools::ExpandListArgument(files, relFiles);
+      std::vector<std::string> absFiles;
+      if (!this->MakeFilesFullPath("RESOURCE", relFiles, absFiles))
+        {
+        return false;
+        }
+
+      // Create the files install generator.
+      if (!resourceArgs.GetDestination().empty())
+        {
+        resourceGenerator = CreateInstallFilesGenerator(absFiles, 
+                                                        resourceArgs, false);
+        }
+      else
+        {
+        cmOStringStream e;
+        e << "INSTALL TARGETS - target " << target.GetName() << " has "
+          << "RESOURCE files but no RESOURCE DESTINATION.";
+        cmSystemTools::Message(e.str().c_str(), "Warning");
+        }
       }
     }
 
@@ -551,9 +565,9 @@
     this->Makefile->AddInstallGenerator(runtimeGenerator);
     this->Makefile->AddInstallGenerator(frameworkGenerator);
     this->Makefile->AddInstallGenerator(bundleGenerator);
-    this->Makefile->AddInstallGenerator(publicHeaderGenerator);
     this->Makefile->AddInstallGenerator(privateHeaderGenerator);
-    this->Makefile->AddInstallGenerator(resourcesGenerator);
+    this->Makefile->AddInstallGenerator(publicHeaderGenerator);
+    this->Makefile->AddInstallGenerator(resourceGenerator);
 
     if (!exports.GetString().empty())
       {
@@ -577,11 +591,11 @@
   this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
                       ->AddInstallComponent(bundleArgs.GetComponent().c_str());
   this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
-                   ->AddInstallComponent(resourcesArgs.GetComponent().c_str());
+               ->AddInstallComponent(privateHeaderArgs.GetComponent().c_str());
   this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
                 ->AddInstallComponent(publicHeaderArgs.GetComponent().c_str());
   this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
-               ->AddInstallComponent(privateHeaderArgs.GetComponent().c_str());
+                    ->AddInstallComponent(resourceArgs.GetComponent().c_str());
 
   return true;
 }

Index: cmOrderLinkDirectories.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmOrderLinkDirectories.cxx,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- cmOrderLinkDirectories.cxx	30 Nov 2006 22:50:40 -0000	1.37
+++ cmOrderLinkDirectories.cxx	10 Oct 2007 15:06:14 -0000	1.38
@@ -466,28 +466,29 @@
     // if it is a full path to an item then separate it from the path
     // this only works with files and paths
     cmStdString& item = this->RawLinkItems[i];
+
     if(cmSystemTools::FileIsFullPath(item.c_str()))
       {
-      if(cmSystemTools::FileIsDirectory(item.c_str()))
+      if(cmSystemTools::IsPathToFramework(item.c_str()))
         {
-        if(cmSystemTools::IsPathToFramework(item.c_str()))
+        this->SplitFramework.find(item.c_str());
+        cmStdString path = this->SplitFramework.match(1);
+        // Add the -F path if we have not yet done so
+        if(this->EmittedFrameworkPaths.insert(path).second)
           {
-          this->SplitFramework.find(item.c_str());
-          cmStdString path = this->SplitFramework.match(1);
-          // Add the -F path if we have not yet done so
-          if(this->EmittedFrameworkPaths.insert(path).second)
-            {
-            std::string fpath = "-F";
-            fpath += cmSystemTools::ConvertToOutputPath(path.c_str());
-            this->LinkItems.push_back(fpath);
-            }
-          // now add the -framework option
-          std::string frame = "-framework ";
-          frame += this->SplitFramework.match(2);
-          this->LinkItems.push_back(frame);
-          framework = true;
+          std::string fpath = "-F";
+          fpath += cmSystemTools::ConvertToOutputPath(path.c_str());
+          this->LinkItems.push_back(fpath);
           }
-        else
+        // now add the -framework option
+        std::string frame = "-framework ";
+        frame += this->SplitFramework.match(2);
+        this->LinkItems.push_back(frame);
+        framework = true;
+        }
+      if(cmSystemTools::FileIsDirectory(item.c_str()))
+        {
+        if(!framework)
           {
           // A full path to a directory was found as a link item
           // warn user 

Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -d -r1.91 -r1.92
--- cmTarget.h	24 Aug 2007 17:30:40 -0000	1.91
+++ cmTarget.h	10 Oct 2007 15:06:14 -0000	1.92
@@ -84,6 +84,23 @@
   void AddSourceFile(cmSourceFile* sf) { this->SourceFiles.push_back(sf); }
 
   /**
+   * Flags for a given source file as used in this target. Typically assigned
+   * via SET_TARGET_PROPERTIES when the property is a list of source files.
+   */
+  struct SourceFileFlags
+  {
+    bool PrivateHeader; // source is in "PRIVATE_HEADER" target property
+    bool PublicHeader;  // source is in "PUBLIC_HEADER" target property
+    bool Resource;      // source is in "RESOURCE" target property *or*
+                        // source has MACOSX_PACKAGE_LOCATION=="Resources"
+  };
+
+  /**
+   * Get the flags for a given source file as used in this target
+   */
+  struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf);
+
+  /**
    * Add sources to the target.
    */
   void AddSources(std::vector<std::string> const& srcs);
@@ -109,6 +126,7 @@
   void ClearDependencyInformation(cmMakefile& mf, const char* target);
 
   // Check to see if a library is a framework and treat it different on Mac
+  bool NameResolvesToFramework(const std::string& libname);
   bool AddFramework(const std::string& lib, LinkLibraryType llt);
   void AddLinkLibrary(cmMakefile& mf,
                       const char *target, const char* lib,
@@ -360,6 +378,9 @@
   void SetPropertyDefault(const char* property, const char* default_value);
 
   // Get the full path to the target output directory.
+  const char* GetAndCreateOutputDir(bool implib, bool create);
+
+  // Get the full path to the target output directory.
   const char* GetOutputDir(bool implib);
 
   const char* ImportedGetLocation(const char* config);

Index: cmInstallTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallTargetGenerator.cxx,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- cmInstallTargetGenerator.cxx	24 Aug 2007 17:30:40 -0000	1.46
+++ cmInstallTargetGenerator.cxx	10 Oct 2007 15:06:14 -0000	1.47
@@ -238,8 +238,18 @@
       {
       // Compute the build tree location of the framework directory
       std::string from1 = fromDirConfig;
-      // Remove trailing slashes
-      cmSystemTools::ConvertToUnixSlashes(from1);
+      if(config && *config)
+        {
+        from1 += "/";
+        from1 += targetName;
+        from1 += ".framework";
+        }
+      else
+        {
+        // Remove trailing slashes... so that from1 ends with ".framework":
+        //
+        cmSystemTools::ConvertToUnixSlashes(from1);
+        }
       files.push_back(from1);
 
       type = cmTarget::INSTALL_DIRECTORY;

Index: cmMakefileTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.cxx,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- cmMakefileTargetGenerator.cxx	17 Sep 2007 14:50:46 -0000	1.70
+++ cmMakefileTargetGenerator.cxx	10 Oct 2007 15:06:14 -0000	1.71
@@ -1170,7 +1170,7 @@
   // will already have added a -F for the framework
   for(i = includes.begin(); i != includes.end(); ++i)
     {
-    if(cmSystemTools::IsPathToFramework(i->c_str()))
+    if(this->Target->NameResolvesToFramework(i->c_str()))
       {
       std::string frameworkDir = *i;
       frameworkDir += "/../";

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.163
retrieving revision 1.164
diff -u -d -r1.163 -r1.164
--- cmTarget.cxx	10 Sep 2007 14:22:19 -0000	1.163
+++ cmTarget.cxx	10 Oct 2007 15:06:14 -0000	1.164
@@ -688,6 +688,83 @@
 }
 
 //----------------------------------------------------------------------------
+struct cmTarget::SourceFileFlags
+cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf)
+{
+  struct SourceFileFlags flags;
+  const char* files;
+  std::vector<std::string>::iterator it;
+
+  flags.PrivateHeader = false;
+  flags.PublicHeader = false;
+  flags.Resource = false;
+
+  files = this->GetProperty("PRIVATE_HEADER");
+  if ((files) && (*files))
+    {
+    std::vector<std::string> relFiles;
+    cmSystemTools::ExpandListArgument(files, relFiles);
+    for(it = relFiles.begin(); it != relFiles.end(); ++it)
+      {
+      if(sf == this->GetMakefile()->GetSource(it->c_str()))
+        {
+        flags.PrivateHeader = true;
+        break;
+        }
+      }
+    }
+
+  // Only consider marking it as a public header if it is *NOT* already marked
+  // as a private header:
+  //
+  if(!flags.PrivateHeader)
+    {
+    files = this->GetProperty("PUBLIC_HEADER");
+    if ((files) && (*files))
+      {
+      std::vector<std::string> relFiles;
+      cmSystemTools::ExpandListArgument(files, relFiles);
+      for(it = relFiles.begin(); it != relFiles.end(); ++it)
+        {
+        if(sf == this->GetMakefile()->GetSource(it->c_str()))
+          {
+          flags.PublicHeader = true;
+          break;
+          }
+        }
+      }
+    }
+
+  const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION");
+  if(location && cmStdString(location) == "Resources")
+    {
+    flags.Resource = true;
+    }
+
+  // Don't bother with the loop if it's already marked as a resource:
+  //
+  if(!flags.Resource)
+    {
+    files = this->GetProperty("RESOURCE");
+    if ((files) && (*files))
+      {
+      std::vector<std::string> relFiles;
+      cmSystemTools::ExpandListArgument(files, relFiles);
+      for(it = relFiles.begin(); it != relFiles.end(); ++it)
+        {
+        if(sf == this->GetMakefile()->GetSource(it->c_str()))
+          {
+          flags.Resource = true;
+          break;
+          }
+        }
+      }
+    }
+
+  return flags;
+}
+
+//----------------------------------------------------------------------------
 void cmTarget::MergeLinkLibraries( cmMakefile& mf,
                                    const char *selfname,
                                    const LinkLibraryVectorType& libs )
@@ -816,10 +893,17 @@
 }
 
 //----------------------------------------------------------------------------
+bool cmTarget::NameResolvesToFramework(const std::string& libname)
+{
+  return this->GetMakefile()->GetLocalGenerator()->GetGlobalGenerator()->
+    NameResolvesToFramework(libname);
+}
+
+//----------------------------------------------------------------------------
 bool cmTarget::AddFramework(const std::string& libname, LinkLibraryType llt)
 {
   (void)llt; // TODO: What is this?
-  if(cmSystemTools::IsPathToFramework(libname.c_str()))
+  if(this->NameResolvesToFramework(libname.c_str()))
     {
     std::string frameworkDir = libname;
     frameworkDir += "/../";
@@ -1239,7 +1323,8 @@
 {
   if(config && *config)
     {
-    this->Directory = this->GetOutputDir(implib);
+    // Do not create the directory when config is given:
+    this->Directory = this->GetAndCreateOutputDir(implib, false);
     // Add the configuration's subdirectory.
     this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
       AppendDirectoryForConfig("/", config, "", this->Directory);
@@ -2199,7 +2284,7 @@
 }
 
 //----------------------------------------------------------------------------
-const char* cmTarget::GetOutputDir(bool implib)
+const char* cmTarget::GetAndCreateOutputDir(bool implib, bool create)
 {
   // The implib option is only allowed for shared libraries, module
   // libraries, and executables.
@@ -2332,18 +2417,27 @@
       }
 #endif
 
-    // Make sure the output path exists on disk.
-    if(!cmSystemTools::MakeDirectory(out.c_str()))
+    // Optionally make sure the output path exists on disk.
+    if(create)
       {
-      cmSystemTools::Error("Error failed to create output directory:",
-                           out.c_str());
+      if(!cmSystemTools::MakeDirectory(out.c_str()))
+        {
+        cmSystemTools::Error("Error failed to create output directory: ",
+                             out.c_str());
+        }
       }
-    }
+  }
 
   return out.c_str();
 }
 
 //----------------------------------------------------------------------------
+const char* cmTarget::GetOutputDir(bool implib)
+{
+  return this->GetAndCreateOutputDir(implib, true);
+}
+
+//----------------------------------------------------------------------------
 const char* cmTarget::GetExportMacro()
 {
   // Define the symbol for targets that export symbols.



More information about the Cmake-commits mailing list