[Cmake-commits] [cmake-commits] king committed cmComputeLinkInformation.cxx 1.32 1.33 cmGlobalXCodeGenerator.cxx 1.186 1.187 cmInstallTargetGenerator.cxx 1.62 1.63 cmLocalVisualStudio7Generator.cxx 1.221 1.222 cmMakefileLibraryTargetGenerator.cxx 1.59 1.60 cmMakefileLibraryTargetGenerator.h 1.6 1.7 cmMakefileTargetGenerator.cxx 1.94 1.95 cmMakefileTargetGenerator.h 1.24 1.25 cmTarget.cxx 1.213 1.214 cmTarget.h 1.112 1.113

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Apr 8 00:06:49 EDT 2008


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

Modified Files:
	cmComputeLinkInformation.cxx cmGlobalXCodeGenerator.cxx 
	cmInstallTargetGenerator.cxx cmLocalVisualStudio7Generator.cxx 
	cmMakefileLibraryTargetGenerator.cxx 
	cmMakefileLibraryTargetGenerator.h 
	cmMakefileTargetGenerator.cxx cmMakefileTargetGenerator.h 
	cmTarget.cxx cmTarget.h 
Log Message:
BUG: Correct Mac OS X framework behavior

  - Place the built library in foo.framework/Versions/A/foo
  - Do not create unused content symlinks (like PrivateHeaders)
  - Do not use VERSION/SOVERSION properties for frameworks
  - Make cmTarget::GetDirectory return by value
  - Remove the foo.framework part from cmTarget::GetDirectory
  - Correct install_name construction and conversion on install
  - Fix MACOSX_PACKAGE_LOCATION under Xcode to use the
    Versions/<version> directory for frameworks
  - Update the Framework test to try these things


Index: cmLocalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v
retrieving revision 1.221
retrieving revision 1.222
diff -C 2 -d -r1.221 -r1.222
*** cmLocalVisualStudio7Generator.cxx	31 Mar 2008 14:59:02 -0000	1.221
--- cmLocalVisualStudio7Generator.cxx	8 Apr 2008 04:06:46 -0000	1.222
***************
*** 669,673 ****
      {
      // Check the filesystem type where the target will be written.
!     if(cmLVS6G_IsFAT(target.GetDirectory(configName)))
        {
        // Add a flag telling the manifest tool to use a workaround
--- 669,673 ----
      {
      // Check the filesystem type where the target will be written.
!     if(cmLVS6G_IsFAT(target.GetDirectory(configName).c_str()))
        {
        // Add a flag telling the manifest tool to use a workaround

Index: cmGlobalXCodeGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.cxx,v
retrieving revision 1.186
retrieving revision 1.187
diff -C 2 -d -r1.186 -r1.187
*** cmGlobalXCodeGenerator.cxx	18 Feb 2008 21:38:34 -0000	1.186
--- cmGlobalXCodeGenerator.cxx	8 Apr 2008 04:06:46 -0000	1.187
***************
*** 804,809 ****
            this->CreateString("6"));
          cmOStringStream ostr;
!         if ( mit->first != "MacOS" )
            {
            ostr << "../" << mit->first.c_str();
            }
--- 804,815 ----
            this->CreateString("6"));
          cmOStringStream ostr;
!         if (cmtarget.IsFrameworkOnApple())
!           {
!           // dstPath in frameworks is relative to Versions/<version>
!           ostr << mit->first;
!           }
!         else if ( mit->first != "MacOS" )
            {
+           // dstPath in bundles is relative to Contents/MacOS
            ostr << "../" << mit->first.c_str();
            }
***************
*** 1358,1366 ****
      {
      std::string pndir = target.GetDirectory();
-     if(target.IsFrameworkOnApple())
-       {
-       pndir += "/..";
-       pndir = cmSystemTools::CollapseFullPath(pndir.c_str());
-       }
      buildSettings->AddAttribute("SYMROOT", 
                                  this->CreateString(pndir.c_str()));
--- 1364,1367 ----
***************
*** 1430,1444 ****
        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));
        }
      else
--- 1431,1437 ----
        productType = "com.apple.product-type.framework";
  
!       std::string version = target.GetFrameworkVersion();
        buildSettings->AddAttribute("FRAMEWORK_VERSION",
!                                   this->CreateString(version.c_str()));
        }
      else
***************
*** 1650,1665 ****
      {
      // Get the install_name directory for the build tree.
!     install_name_dir = target.GetInstallNameDirForBuildTree(configName);
!     if(target.GetPropertyAsBool("FRAMEWORK"))
!       {
!       if(install_name_dir.find(".framework") != install_name_dir.npos)
!         {
!         install_name_dir = install_name_dir + "/..";
!         install_name_dir = 
!             cmSystemTools::CollapseFullPath(install_name_dir.c_str());
!         //std::cerr << "new install name " << install_name_dir << "\n";
!         }
!       }
!     
      if(install_name_dir.empty())
        {
--- 1643,1647 ----
      {
      // Get the install_name directory for the build tree.
!     install_name_dir = target.GetInstallNameDirForBuildTree(configName, true);
      if(install_name_dir.empty())
        {
***************
*** 2869,2892 ****
      if(config)
        {
!       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 = dir.substr(0, pos);
!         newDir += "/";
!         newDir += config;
!         dir = newDir;
!         dir += framework;
!         }
!       else
!         {
!         dir += prefix;
!         dir += config;
!         dir += suffix;
!         }
        }
      }
--- 2851,2857 ----
      if(config)
        {
!       dir += prefix;
!       dir += config;
!       dir += suffix;
        }
      }

Index: cmComputeLinkInformation.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkInformation.cxx,v
retrieving revision 1.32
retrieving revision 1.33
diff -C 2 -d -r1.32 -r1.33
*** cmComputeLinkInformation.cxx	31 Mar 2008 16:47:31 -0000	1.32
--- cmComputeLinkInformation.cxx	8 Apr 2008 04:06:46 -0000	1.33
***************
*** 612,627 ****
        this->Depends.push_back(lib);
  
!       if(tgt->IsFrameworkOnApple())
!         {
!         // Frameworks on OS X need only the framework directory to
!         // link.
!         std::string fw = tgt->GetDirectory(config, implib);
!         this->AddFrameworkItem(fw);
!         }
!       else
!         {
!         this->AddTargetItem(lib, tgt);
!         this->AddLibraryRuntimeInfo(lib, tgt);
!         }
        }
      }
--- 612,617 ----
        this->Depends.push_back(lib);
  
!       this->AddTargetItem(lib, tgt);
!       this->AddLibraryRuntimeInfo(lib, tgt);
        }
      }
***************
*** 1024,1028 ****
    // For compatibility with CMake 2.4 include the item's directory in
    // the linker search path.
!   if(this->OldLinkDirMode &&
       this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
       this->OldLinkDirMask.end())
--- 1014,1018 ----
    // For compatibility with CMake 2.4 include the item's directory in
    // the linker search path.
!   if(this->OldLinkDirMode && !target->IsFrameworkOnApple() &&
       this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
       this->OldLinkDirMask.end())

Index: cmMakefileLibraryTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileLibraryTargetGenerator.cxx,v
retrieving revision 1.59
retrieving revision 1.60
diff -C 2 -d -r1.59 -r1.60
*** cmMakefileLibraryTargetGenerator.cxx	7 Apr 2008 17:39:13 -0000	1.59
--- cmMakefileLibraryTargetGenerator.cxx	8 Apr 2008 04:06:46 -0000	1.60
***************
*** 40,57 ****
    if(this->Target->IsFrameworkOnApple())
      {
!     if(const char* fversion = this->Target->GetProperty("FRAMEWORK_VERSION"))
!       {
!       this->FrameworkVersion = fversion;
!       }
!     else if(const char* tversion = this->Target->GetProperty("VERSION"))
!       {
!       this->FrameworkVersion = tversion;
!       }
!     else
!       {
!       this->FrameworkVersion = "A";
!       }
      this->MacContentDirectory = this->Target->GetDirectory();
!     this->MacContentDirectory += "/Versions/";
      this->MacContentDirectory += this->FrameworkVersion;
      this->MacContentDirectory += "/";
--- 40,48 ----
    if(this->Target->IsFrameworkOnApple())
      {
!     this->FrameworkVersion = this->Target->GetFrameworkVersion();
      this->MacContentDirectory = this->Target->GetDirectory();
!     this->MacContentDirectory += "/";
!     this->MacContentDirectory += this->TargetNameOut;
!     this->MacContentDirectory += ".framework/Versions/";
      this->MacContentDirectory += this->FrameworkVersion;
      this->MacContentDirectory += "/";
***************
*** 245,292 ****
  
  //----------------------------------------------------------------------------
! void cmMakefileLibraryTargetGenerator::CreateFramework(
!   std::string& targetName,
!   std::string& outpath)
  {
!   std::string symlink;
!   std::string symlink2;
    // Make foo.framework/Versions
!   std::string dir = outpath;
!   dir += "Versions";
!   cmSystemTools::MakeDirectory(dir.c_str());
!   std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
!   // cd foo.framework to setup symlinks with relative paths
!   cmSystemTools::ChangeDirectory((outpath+"Versions").c_str());
    // Current -> version
!   symlink = this->FrameworkVersion;
!   symlink2 = "Current";
!   cmSystemTools::RemoveFile("Current");
!   cmSystemTools::CreateSymlink(symlink.c_str(), symlink2.c_str());
!   this->Makefile->AddCMakeOutputFile((outpath + "Versions/Current").c_str());
!   // change to top level of framework to create next set of symlinks
!   cmSystemTools::ChangeDirectory(outpath.c_str());
    // foo -> Versions/Current/foo
!   symlink = "Versions/Current/";
!   symlink += targetName;
!   symlink2 = targetName;
!   cmSystemTools::CreateSymlink(symlink.c_str(), symlink2.c_str());
!   this->Makefile->AddCMakeOutputFile((outpath + targetName).c_str());
!   // Resources -> Versions/Current/Resources 
!   symlink = "Versions/Current/Resources";
!   symlink2 = "Resources";
!   cmSystemTools::CreateSymlink(symlink.c_str(), symlink2.c_str());
!   this->Makefile->AddCMakeOutputFile((outpath + "Resources").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());
!   this->Makefile->AddCMakeOutputFile((outpath + "PrivateHeaders").c_str());
!   // go back to where we were
!   cmSystemTools::ChangeDirectory(cwd.c_str());
  }
  
--- 236,315 ----
  
  //----------------------------------------------------------------------------
! void cmMakefileLibraryTargetGenerator::CreateFramework()
  {
!   // 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();
!   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());
!     }
  }
  
***************
*** 355,359 ****
    std::string outpath;
    std::string outpathImp;
!   if(relink)
      {
      outpath = this->Makefile->GetStartOutputDirectory();
--- 378,387 ----
    std::string outpath;
    std::string outpathImp;
!   if(this->Target->IsFrameworkOnApple())
!     {
!     outpath = this->MacContentDirectory;
!     this->CreateFramework();
!     }
!   else if(relink)
      {
      outpath = this->Makefile->GetStartOutputDirectory();
***************
*** 380,389 ****
      }
  
-   // If we're creating a framework, place the output into a framework directory
-   if(this->Target->IsFrameworkOnApple())
-     {
-     this->CreateFramework(targetName, outpath);
-     }
- 
    std::string targetFullPath = outpath + targetName;
    std::string targetFullPathPDB = outpath + targetNamePDB;
--- 408,411 ----

Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.112
retrieving revision 1.113
diff -C 2 -d -r1.112 -r1.113
*** cmTarget.h	7 Apr 2008 17:39:13 -0000	1.112
--- cmTarget.h	8 Apr 2008 04:06:46 -0000	1.113
***************
*** 254,258 ****
        subdirectory for that configuration.  Otherwise just the canonical
        output directory is given.  */
!   const char* GetDirectory(const char* config = 0, bool implib = false);
  
    /** Get the location of the target in the build tree for the given
--- 254,258 ----
        subdirectory for that configuration.  Otherwise just the canonical
        output directory is given.  */
!   std::string GetDirectory(const char* config = 0, bool implib = false);
  
    /** Get the location of the target in the build tree for the given
***************
*** 349,354 ****
    bool IsChrpathUsed();
  
!   std::string GetInstallNameDirForBuildTree(const char* config);
!   std::string GetInstallNameDirForInstallTree(const char* config);
  
    cmComputeLinkInformation* GetLinkInformation(const char* config);
--- 349,356 ----
    bool IsChrpathUsed();
  
!   std::string GetInstallNameDirForBuildTree(const char* config,
!                                             bool for_xcode = false);
!   std::string GetInstallNameDirForInstallTree(const char* config,
!                                               bool for_xcode = false);
  
    cmComputeLinkInformation* GetLinkInformation(const char* config);
***************
*** 385,388 ****
--- 387,394 ----
    bool IsAppBundleOnApple();
  
+   /** Return the framework version string.  Undefined if
+       IsFrameworkOnApple returns false.  */
+   std::string GetFrameworkVersion();
+ 
    /** Get a backtrace from the creation of the target.  */
    cmListFileBacktrace const& GetBacktrace() const;
***************
*** 465,469 ****
  
    // Get the full path to the target output directory.
!   const char* GetOutputDir(bool implib);
  
    const char* ImportedGetLocation(const char* config);
--- 471,476 ----
  
    // Get the full path to the target output directory.
!   std::string GetOutputDir(bool implib);
!   std::string const& cmTarget::ComputeBaseOutputDir(bool implib);
  
    const char* ImportedGetLocation(const char* config);
***************
*** 472,478 ****
    std::string GetFullNameImported(const char* config, bool implib);
  
-   const char* ImportedGetDirectory(const char* config, bool implib);
-   const char* NormalGetDirectory(const char* config, bool implib);
- 
    std::string ImportedGetFullPath(const char* config, bool implib);
    std::string NormalGetFullPath(const char* config, bool implib,
--- 479,482 ----
***************
*** 501,507 ****
    std::string InstallPath;
    std::string RuntimeInstallPath;
!   std::string OutputDir;
!   std::string OutputDirImplib;
!   std::string Directory;
    std::string Location;
    std::string ExportMacro;
--- 505,510 ----
    std::string InstallPath;
    std::string RuntimeInstallPath;
!   std::string BaseOutputDir;
!   std::string BaseOutputDirImplib;
    std::string Location;
    std::string ExportMacro;

Index: cmInstallTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallTargetGenerator.cxx,v
retrieving revision 1.62
retrieving revision 1.63
diff -C 2 -d -r1.62 -r1.63
*** cmInstallTargetGenerator.cxx	2 Mar 2008 21:48:50 -0000	1.62
--- cmInstallTargetGenerator.cxx	8 Apr 2008 04:06:46 -0000	1.63
***************
*** 240,246 ****
        // Compute the build tree location of the framework directory
        std::string from1 = fromDirConfig;
!       // Remove trailing slashes... so that from1 ends with ".framework":
!       //
!       cmSystemTools::ConvertToUnixSlashes(from1);
        files.push_back(from1);
  
--- 240,245 ----
        // Compute the build tree location of the framework directory
        std::string from1 = fromDirConfig;
!       from1 += targetName;
!       from1 += ".framework";
        files.push_back(from1);
  
***************
*** 249,253 ****
        // Need to apply install_name_tool and stripping to binary
        // inside framework.
!       toInstallPath += ".framework/";
        toInstallPath += this->GetInstallFilename(this->Target, config,
                                                  NameNormal);
--- 248,254 ----
        // Need to apply install_name_tool and stripping to binary
        // inside framework.
!       toInstallPath += ".framework/Versions/";
!       toInstallPath += this->Target->GetFrameworkVersion();
!       toInstallPath += "/";
        toInstallPath += this->GetInstallFilename(this->Target, config,
                                                  NameNormal);

Index: cmMakefileTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.cxx,v
retrieving revision 1.94
retrieving revision 1.95
diff -C 2 -d -r1.94 -r1.95
*** cmMakefileTargetGenerator.cxx	3 Apr 2008 15:11:54 -0000	1.94
--- cmMakefileTargetGenerator.cxx	8 Apr 2008 04:06:46 -0000	1.95
***************
*** 335,338 ****
--- 335,341 ----
    cmSystemTools::MakeDirectory(macdir.c_str());
  
+   // Record use of this content location.
+   this->MacContentFolders.insert(pkgloc);
+ 
    // Get the input file location.
    std::string input = source.GetFullPath();
***************
*** 1457,1465 ****
           this->GlobalGenerator->FindTarget(0, lib->first.c_str()))
          {
!         if(const char* location =
!            tgt->GetLocation(this->LocalGenerator->ConfigurationName.c_str()))
!           {
!           depends.push_back(location);
!           }
          }
        // depend on full path libs as well
--- 1460,1465 ----
           this->GlobalGenerator->FindTarget(0, lib->first.c_str()))
          {
!         const char* config = this->LocalGenerator->ConfigurationName.c_str();
!         depends.push_back(tgt->GetFullPath(config, false));
          }
        // depend on full path libs as well

Index: cmMakefileTargetGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -C 2 -d -r1.24 -r1.25
*** cmMakefileTargetGenerator.h	27 Feb 2008 22:10:45 -0000	1.24
--- cmMakefileTargetGenerator.h	8 Apr 2008 04:06:46 -0000	1.25
***************
*** 205,208 ****
--- 205,209 ----
    // Mac OS X content info.
    std::string MacContentDirectory;
+   std::set<cmStdString> MacContentFolders;
  
    // Target-wide Fortran module output directory.

Index: cmMakefileLibraryTargetGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileLibraryTargetGenerator.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C 2 -d -r1.6 -r1.7
*** cmMakefileLibraryTargetGenerator.h	18 Feb 2008 21:38:34 -0000	1.6
--- cmMakefileLibraryTargetGenerator.h	8 Apr 2008 04:06:46 -0000	1.7
***************
*** 38,43 ****
    // MacOSX Framework support methods
    void WriteFrameworkRules(bool relink);
!   void CreateFramework(std::string& targetName,
!                        std::string& outpath);
  
    // Store the computd framework version for OS X Frameworks.
--- 38,42 ----
    // MacOSX Framework support methods
    void WriteFrameworkRules(bool relink);
!   void CreateFramework();
  
    // Store the computd framework version for OS X Frameworks.

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.213
retrieving revision 1.214
diff -C 2 -d -r1.213 -r1.214
*** cmTarget.cxx	7 Apr 2008 17:39:13 -0000	1.213
--- cmTarget.cxx	8 Apr 2008 04:06:46 -0000	1.214
***************
*** 1627,1666 ****
  
  //----------------------------------------------------------------------------
! const char* cmTarget::GetDirectory(const char* config, bool implib)
  {
    if (this->IsImported())
      {
!     return this->ImportedGetDirectory(config, implib);
!     }
!   else
!     {
!     return this->NormalGetDirectory(config, implib);
!     }
! }
! 
! //----------------------------------------------------------------------------
! const char* cmTarget::ImportedGetDirectory(const char* config, bool implib)
! {
!   this->Directory =
!     cmSystemTools::GetFilenamePath(
        this->ImportedGetFullPath(config, implib));
-   return this->Directory.c_str();
- }
- 
- //----------------------------------------------------------------------------
- const char* cmTarget::NormalGetDirectory(const char* config, bool implib)
- {
-   if(config && *config)
-     {
-     // Do not create the directory when config is given:
-     this->Directory = this->GetOutputDir(implib);
-     // Add the configuration's subdirectory.
-     this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
-       AppendDirectoryForConfig("/", config, "", this->Directory);
-     return this->Directory.c_str();
      }
    else
      {
!     return this->GetOutputDir(implib);
      }
  }
--- 1627,1654 ----
  
  //----------------------------------------------------------------------------
! std::string cmTarget::GetDirectory(const char* config, bool implib)
  {
    if (this->IsImported())
      {
!     // Return the directory from which the target is imported.
!     return
!       cmSystemTools::GetFilenamePath(
        this->ImportedGetFullPath(config, implib));
      }
    else
      {
!     // Return the directory in which the target will be built.
!     if(config && *config)
!       {
!       // Add the configuration's subdirectory.
!       std::string dir = this->GetOutputDir(implib);
!       this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
!         AppendDirectoryForConfig("/", config, "", dir);
!       return dir;
!       }
!     else
!       {
!       return this->GetOutputDir(implib);
!       }
      }
  }
***************
*** 1689,1708 ****
  const char* cmTarget::NormalGetLocation(const char* config)
  {
!   this->Location = this->GetDirectory(config);
    if(!this->Location.empty())
      {
      this->Location += "/";
      }
!   if(!config)
      {
!     // No specific configuration was given so it will not appear on
!     // the result of GetDirectory.  Add a name here to be replaced at
!     // build time.
!     const char* cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR");
!     if(cfgid && strcmp(cfgid, ".") != 0)
!       {
!       this->Location += cfgid;
!       this->Location += "/";
!       }
      }
    this->Location += this->GetFullName(config, false);
--- 1677,1705 ----
  const char* cmTarget::NormalGetLocation(const char* config)
  {
!   // Handle the configuration-specific case first.
!   if(config)
!     {
!     this->Location = this->GetFullPath(config, false);
!     return this->Location.c_str();
!     }
! 
!   // Now handle the deprecated build-time configuration location.
!   this->Location = this->GetDirectory();
    if(!this->Location.empty())
      {
      this->Location += "/";
      }
!   const char* cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR");
!   if(cfgid && strcmp(cfgid, ".") != 0)
      {
!     this->Location += cfgid;
!     this->Location += "/";
!     }
!    if(this->IsFrameworkOnApple())
!     {
!     this->Location += this->GetFullName(config, false);
!     this->Location += ".framework/Versions/";
!     this->Location += this->GetFrameworkVersion();
!     this->Location += "/";
      }
    this->Location += this->GetFullName(config, false);
***************
*** 2204,2207 ****
--- 2201,2212 ----
    fpath += "/";
  
+   if(this->IsFrameworkOnApple())
+     {
+     fpath += this->GetFullName(config, false);
+     fpath += ".framework/Versions/";
+     fpath += this->GetFrameworkVersion();
+     fpath += "/";
+     }
+ 
    // Add the full name of the target.
    if(implib)
***************
*** 2475,2479 ****
    const char* soversion = this->GetProperty("SOVERSION");
    if((type != cmTarget::SHARED_LIBRARY && type != cmTarget::MODULE_LIBRARY) ||
!      !this->Makefile->GetDefinition(sonameFlag.c_str()))
      {
      // Versioning is supported only for shared libraries and modules,
--- 2480,2485 ----
    const char* soversion = this->GetProperty("SOVERSION");
    if((type != cmTarget::SHARED_LIBRARY && type != cmTarget::MODULE_LIBRARY) ||
!      !this->Makefile->GetDefinition(sonameFlag.c_str()) ||
!      this->IsFrameworkOnApple())
      {
      // Versioning is supported only for shared libraries and modules,
***************
*** 2802,2806 ****
  
  //----------------------------------------------------------------------------
! std::string cmTarget::GetInstallNameDirForBuildTree(const char* config)
  {
    // If building directly for installation then the build tree install_name
--- 2808,2813 ----
  
  //----------------------------------------------------------------------------
! std::string cmTarget::GetInstallNameDirForBuildTree(const char* config,
!                                                     bool for_xcode)
  {
    // If building directly for installation then the build tree install_name
***************
*** 2808,2812 ****
    if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"))
      {
!     return GetInstallNameDirForInstallTree(config);
      }
  
--- 2815,2819 ----
    if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"))
      {
!     return GetInstallNameDirForInstallTree(config, for_xcode);
      }
  
***************
*** 2818,2821 ****
--- 2825,2835 ----
      std::string dir = this->GetDirectory(config);
      dir += "/";
+     if(this->IsFrameworkOnApple() && !for_xcode)
+       {
+       dir += this->GetFullName(config, false);
+       dir += ".framework/Versions/";
+       dir += this->GetFrameworkVersion();
+       dir += "/";
+       }
      return dir;
      }
***************
*** 2827,2831 ****
  
  //----------------------------------------------------------------------------
! std::string cmTarget::GetInstallNameDirForInstallTree(const char*)
  {
    // Lookup the target property.
--- 2841,2846 ----
  
  //----------------------------------------------------------------------------
! std::string cmTarget::GetInstallNameDirForInstallTree(const char* config,
!                                                       bool for_xcode)
  {
    // Lookup the target property.
***************
*** 2837,2840 ****
--- 2852,2862 ----
      std::string dir = install_name_dir;
      dir += "/";
+     if(this->IsFrameworkOnApple() && !for_xcode)
+       {
+       dir += this->GetFullName(config, false);
+       dir += ".framework/Versions/";
+       dir += this->GetFrameworkVersion();
+       dir += "/";
+       }
      return dir;
      }
***************
*** 2846,2850 ****
  
  //----------------------------------------------------------------------------
! const char* cmTarget::GetOutputDir(bool implib)
  {
    // The implib option is only allowed for shared libraries, module
--- 2868,2872 ----
  
  //----------------------------------------------------------------------------
! std::string cmTarget::GetOutputDir(bool implib)
  {
    // The implib option is only allowed for shared libraries, module
***************
*** 2880,2939 ****
      }
  
    // Select whether we are constructing the directory for the main
    // target or the import library.
!   std::string& out = implib? this->OutputDirImplib : this->OutputDir;
  
!   if(out.empty())
      {
!     // Look for a target property defining the target output directory
!     // based on the target type.
!     const char* propertyName = 0;
!     switch(this->GetType())
        {
!       case cmTarget::SHARED_LIBRARY:
!         {
!         // For non-DLL platforms shared libraries are treated as
!         // library targets.  For DLL platforms the DLL part of a
!         // shared library is treated as a runtime target and the
!         // corresponding import library is treated as an archive
!         // target.
!         if(this->DLLPlatform)
!           {
!           if(implib)
!             {
!             propertyName = "ARCHIVE_OUTPUT_DIRECTORY";
!             }
!           else
!             {
!             propertyName = "RUNTIME_OUTPUT_DIRECTORY";
!             }
!           }
!         else
!           {
!           propertyName = "LIBRARY_OUTPUT_DIRECTORY";
!           }
!         } break;
!       case cmTarget::STATIC_LIBRARY:
!         {
!         // Static libraries are always treated as archive targets.
!         propertyName = "ARCHIVE_OUTPUT_DIRECTORY";
!         } break;
!       case cmTarget::MODULE_LIBRARY:
!         {
!         // Module libraries are always treated as library targets.
!         // Module import libraries are treated as archive targets.
!         if(implib)
!           {
!           propertyName = "ARCHIVE_OUTPUT_DIRECTORY";
!           }
!         else
!           {
!           propertyName = "LIBRARY_OUTPUT_DIRECTORY";
!           }
!         } break;
!       case cmTarget::EXECUTABLE:
          {
-         // Executables are always treated as runtime targets.
-         // Executable import libraries are treated as archive targets.
          if(implib)
            {
--- 2902,2935 ----
      }
  
+   return this->ComputeBaseOutputDir(implib);
+ }
+ 
+ //----------------------------------------------------------------------------
+ std::string const& cmTarget::ComputeBaseOutputDir(bool implib)
+ {
    // Select whether we are constructing the directory for the main
    // target or the import library.
!   std::string& out = implib? this->BaseOutputDirImplib : this->BaseOutputDir;
  
!   // Return immediately if the directory has already been computed.
!   if(!out.empty())
      {
!     return out;
!     }
! 
!   // Look for a target property defining the target output directory
!   // based on the target type.
!   const char* propertyName = 0;
!   switch(this->GetType())
!     {
!     case cmTarget::SHARED_LIBRARY:
        {
!       // For non-DLL platforms shared libraries are treated as
!       // library targets.  For DLL platforms the DLL part of a
!       // shared library is treated as a runtime target and the
!       // corresponding import library is treated as an archive
!       // target.
!       if(this->DLLPlatform)
          {
          if(implib)
            {
***************
*** 2944,2994 ****
            propertyName = "RUNTIME_OUTPUT_DIRECTORY";
            }
!         } break;
!       default: break;
!       }
! 
!     // Select an output directory.
!     if(const char* outdir = this->GetProperty(propertyName))
!       {
!       // Use the user-specified output directory.
!       out = outdir;
!       }
!     else if(this->GetType() == cmTarget::EXECUTABLE)
        {
!       // Lookup the output path for executables.
!       out = this->Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
!       }
!     else if(this->GetType() == cmTarget::STATIC_LIBRARY ||
!             this->GetType() == cmTarget::SHARED_LIBRARY ||
!             this->GetType() == cmTarget::MODULE_LIBRARY)
        {
!       // Lookup the output path for libraries.
!       out = this->Makefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH");
!       }
!     if(out.empty())
        {
!       // Default to the current output directory.
!       out = ".";
!       }
!     // Convert the output path to a full path in case it is
!     // specified as a relative path.  Treat a relative path as
!     // relative to the current output directory for this makefile.
!     out =
!       cmSystemTools::CollapseFullPath
!       (out.c_str(), this->Makefile->GetStartOutputDirectory());
  
!     // TODO: Make AppBundle and Framework directory computation in
!     // target consistent.  Why do we add the .framework part here for
!     // frameworks but not the .app part for bundles?  We should
!     // probably not add it for either.
!     if(this->IsFrameworkOnApple())
!       {
!       out += "/";
!       out += this->GetFullName(0, implib);
!       out += ".framework";
!       }
!   }
  
!   return out.c_str();
  }
  
--- 2940,3030 ----
            propertyName = "RUNTIME_OUTPUT_DIRECTORY";
            }
!         }
!       else
!         {
!         propertyName = "LIBRARY_OUTPUT_DIRECTORY";
!         }
!       } break;
!     case cmTarget::STATIC_LIBRARY:
        {
!       // Static libraries are always treated as archive targets.
!       propertyName = "ARCHIVE_OUTPUT_DIRECTORY";
!       } break;
!     case cmTarget::MODULE_LIBRARY:
        {
!       // Module libraries are always treated as library targets.
!       // Module import libraries are treated as archive targets.
!       if(implib)
!         {
!         propertyName = "ARCHIVE_OUTPUT_DIRECTORY";
!         }
!       else
!         {
!         propertyName = "LIBRARY_OUTPUT_DIRECTORY";
!         }
!       } break;
!     case cmTarget::EXECUTABLE:
        {
!       // Executables are always treated as runtime targets.
!       // Executable import libraries are treated as archive targets.
!       if(implib)
!         {
!         propertyName = "ARCHIVE_OUTPUT_DIRECTORY";
!         }
!       else
!         {
!         propertyName = "RUNTIME_OUTPUT_DIRECTORY";
!         }
!       } break;
!     default: break;
!     }
  
!   // Select an output directory.
!   if(const char* outdir = this->GetProperty(propertyName))
!     {
!     // Use the user-specified output directory.
!     out = outdir;
!     }
!   else if(this->GetType() == cmTarget::EXECUTABLE)
!     {
!     // Lookup the output path for executables.
!     out = this->Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
!     }
!   else if(this->GetType() == cmTarget::STATIC_LIBRARY ||
!           this->GetType() == cmTarget::SHARED_LIBRARY ||
!           this->GetType() == cmTarget::MODULE_LIBRARY)
!     {
!     // Lookup the output path for libraries.
!     out = this->Makefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH");
!     }
!   if(out.empty())
!     {
!     // Default to the current output directory.
!     out = ".";
!     }
  
!   // Convert the output path to a full path in case it is
!   // specified as a relative path.  Treat a relative path as
!   // relative to the current output directory for this makefile.
!   out = (cmSystemTools::CollapseFullPath
!          (out.c_str(), this->Makefile->GetStartOutputDirectory()));
!   return out;
! }
! 
! //----------------------------------------------------------------------------
! std::string cmTarget::GetFrameworkVersion()
! {
!   if(const char* fversion = this->GetProperty("FRAMEWORK_VERSION"))
!     {
!     return fversion;
!     }
!   else if(const char* tversion = this->GetProperty("VERSION"))
!     {
!     return tversion;
!     }
!   else
!     {
!     return "A";
!     }
  }
  



More information about the Cmake-commits mailing list