[Cmake-commits] [cmake-commits] king committed cmInstallTargetGenerator.cxx 1.73 1.74

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Oct 21 13:10:57 EDT 2009


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

Modified Files:
	cmInstallTargetGenerator.cxx 
Log Message:
Compute install destination for all target files

In cmInstallTargetGenerator::GenerateScriptForConfig we were computing
the full 'from' paths for all target files to be installed, but only
computing a 'to' path for the "main" target file.  This commit teaches
the method to compute both 'from' and 'to' paths for every target file
to be installed.  The result is cleaner, easier to follow, and will
allow installation tweaks to be added later on all target files.


Index: cmInstallTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallTargetGenerator.cxx,v
retrieving revision 1.73
retrieving revision 1.74
diff -C 2 -d -r1.73 -r1.74
*** cmInstallTargetGenerator.cxx	21 Oct 2009 17:09:54 -0000	1.73
--- cmInstallTargetGenerator.cxx	21 Oct 2009 17:10:51 -0000	1.74
***************
*** 76,85 ****
      fromDirConfig += "/";
      }
! 
!   // Compute the full path to the main installed file for this target.
!   NameType nameType = this->ImportLibrary? NameImplib : NameNormal;
!   std::string toInstallPath = this->GetInstallDestination();
!   toInstallPath += "/";
!   toInstallPath += this->GetInstallFilename(this->Target, config, nameType);
  
    // Track whether post-install operations should be added to the
--- 76,81 ----
      fromDirConfig += "/";
      }
!   std::string toDir = this->GetInstallDestination();
!   toDir += "/";
  
    // Track whether post-install operations should be added to the
***************
*** 88,92 ****
  
    // Compute the list of files to install for this target.
!   std::vector<std::string> files;
    std::string literal_args;
    cmTarget::TargetType type = this->Target->GetType();
--- 84,89 ----
  
    // Compute the list of files to install for this target.
!   std::vector<std::string> filesFrom;
!   std::vector<std::string> filesTo;
    std::string literal_args;
    cmTarget::TargetType type = this->Target->GetType();
***************
*** 105,111 ****
      if(this->ImportLibrary)
        {
!       std::string from1 = fromDirConfig;
!       from1 += targetNameImport;
!       files.push_back(from1);
  
        // An import library looks like a static library.
--- 102,109 ----
      if(this->ImportLibrary)
        {
!       std::string from1 = fromDirConfig + targetNameImport;
!       std::string to1 = toDir + targetNameImport;
!       filesFrom.push_back(from1);
!       filesTo.push_back(to1);
  
        // An import library looks like a static library.
***************
*** 114,151 ****
      else
        {
!       std::string from1 = fromDirConfig;
!       from1 += targetName;
  
        // Handle OSX Bundles.
        if(this->Target->IsAppBundleOnApple())
          {
!         // Compute the source locations of the bundle executable and
!         // Info.plist file.
!         from1 += ".app";
!         files.push_back(from1);
          type = cmTarget::INSTALL_DIRECTORY;
-         // Need to apply install_name_tool and stripping to binary
-         // inside bundle.
-         toInstallPath += ".app/Contents/MacOS/";
-         toInstallPath +=
-           this->GetInstallFilename(this->Target, config, nameType);
          literal_args += " USE_SOURCE_PERMISSIONS";
          }
        else
          {
!         // Operations done at install time on the installed file should
!         // be done on the real file and not any of the symlinks.
!         toInstallPath = this->GetInstallDestination();
!         toInstallPath += "/";
!         toInstallPath += targetNameReal;
! 
!         files.push_back(from1);
          if(targetNameReal != targetName)
            {
!           std::string from2 = fromDirConfig;
!           from2 += targetNameReal;
!           files.push_back(from2);
            }
          }
        }
      }
--- 112,144 ----
      else
        {
!       std::string from1 = fromDirConfig + targetName;
!       std::string to1 = toDir + targetName;
  
        // Handle OSX Bundles.
        if(this->Target->IsAppBundleOnApple())
          {
!         // Install the whole app bundle directory.
          type = cmTarget::INSTALL_DIRECTORY;
          literal_args += " USE_SOURCE_PERMISSIONS";
+         from1 += ".app";
+ 
+         // Tweaks apply to the binary inside the bundle.
+         to1 += ".app/Contents/MacOS/";
+         to1 += targetName;
          }
        else
          {
!         // Tweaks apply to the real file, so list it first.
          if(targetNameReal != targetName)
            {
!           std::string from2 = fromDirConfig + targetNameReal;
!           std::string to2 = toDir += targetNameReal;
!           filesFrom.push_back(from2);
!           filesTo.push_back(to2);
            }
          }
+ 
+       filesFrom.push_back(from1);
+       filesTo.push_back(to1);
        }
      }
***************
*** 165,171 ****
        assert(this->NamelinkMode == NamelinkModeNone);
  
!       std::string from1 = fromDirConfig;
!       from1 += targetNameImport;
!       files.push_back(from1);
  
        // An import library looks like a static library.
--- 158,165 ----
        assert(this->NamelinkMode == NamelinkModeNone);
  
!       std::string from1 = fromDirConfig + targetNameImport;
!       std::string to1 = toDir + targetNameImport;
!       filesFrom.push_back(from1);
!       filesTo.push_back(to1);
  
        // An import library looks like a static library.
***************
*** 177,225 ****
        assert(this->NamelinkMode == NamelinkModeNone);
  
!       // Compute the build tree location of the framework directory
!       std::string from1 = fromDirConfig;
!       from1 += targetName;
!       from1 += ".framework";
!       files.push_back(from1);
! 
        type = cmTarget::INSTALL_DIRECTORY;
  
!       // 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);
  
!       literal_args += " USE_SOURCE_PERMISSIONS";
        }
      else
        {
-       // Operations done at install time on the installed file should
-       // be done on the real file and not any of the symlinks.
-       toInstallPath = this->GetInstallDestination();
-       toInstallPath += "/";
-       toInstallPath += targetNameReal;
- 
-       // Construct the list of file names to install for this library.
        bool haveNamelink = false;
!       std::string fromName;
        std::string fromSOName;
!       std::string fromRealName;
!       fromName = fromDirConfig;
!       fromName += targetName;
        if(targetNameSO != targetName)
          {
          haveNamelink = true;
!         fromSOName = fromDirConfig;
!         fromSOName += targetNameSO;
          }
        if(targetNameReal != targetName &&
           targetNameReal != targetNameSO)
          {
          haveNamelink = true;
!         fromRealName = fromDirConfig;
!         fromRealName += targetNameReal;
          }
  
--- 171,216 ----
        assert(this->NamelinkMode == NamelinkModeNone);
  
!       // Install the whole framework directory.
        type = cmTarget::INSTALL_DIRECTORY;
+       literal_args += " USE_SOURCE_PERMISSIONS";
+       std::string from1 = fromDirConfig + targetName + ".framework";
  
!       // Tweaks apply to the binary inside the bundle.
!       std::string to1 = toDir + targetName;
!       to1 += ".framework/Versions/";
!       to1 += this->Target->GetFrameworkVersion();
!       to1 += "/";
!       to1 += targetName;
  
!       filesFrom.push_back(from1);
!       filesTo.push_back(to1);
        }
      else
        {
        bool haveNamelink = false;
! 
!       // Library link name.
!       std::string fromName = fromDirConfig + targetName;
!       std::string toName = toDir + targetName;
! 
!       // Library interface name.
        std::string fromSOName;
!       std::string toSOName;
        if(targetNameSO != targetName)
          {
          haveNamelink = true;
!         fromSOName = fromDirConfig + targetNameSO;
!         toSOName = toDir + targetNameSO;
          }
+ 
+       // Library implementation name.
+       std::string fromRealName;
+       std::string toRealName;
        if(targetNameReal != targetName &&
           targetNameReal != targetNameSO)
          {
          haveNamelink = true;
!         fromRealName = fromDirConfig + targetNameReal;
!         toRealName = toDir + targetNameReal;
          }
  
***************
*** 231,235 ****
            {
            // Install the namelink only.
!           files.push_back(fromName);
            tweakInstalledFile = false;
            }
--- 222,227 ----
            {
            // Install the namelink only.
!           filesFrom.push_back(fromName);
!           filesTo.push_back(toName);
            tweakInstalledFile = false;
            }
***************
*** 239,243 ****
            if(!fromRealName.empty())
              {
!             files.push_back(fromRealName);
              }
  
--- 231,236 ----
            if(!fromRealName.empty())
              {
!             filesFrom.push_back(fromRealName);
!             filesTo.push_back(toRealName);
              }
  
***************
*** 245,249 ****
            if(!fromSOName.empty())
              {
!             files.push_back(fromSOName);
              }
  
--- 238,243 ----
            if(!fromSOName.empty())
              {
!             filesFrom.push_back(fromSOName);
!             filesTo.push_back(toSOName);
              }
  
***************
*** 251,255 ****
            if(this->NamelinkMode != NamelinkModeSkip)
              {
!             files.push_back(fromName);
              }
            }
--- 245,250 ----
            if(this->NamelinkMode != NamelinkModeSkip)
              {
!             filesFrom.push_back(fromName);
!             filesTo.push_back(toName);
              }
            }
***************
*** 261,265 ****
          if(this->NamelinkMode != NamelinkModeOnly)
            {
!           files.push_back(fromName);
            }
          }
--- 256,261 ----
          if(this->NamelinkMode != NamelinkModeOnly)
            {
!           filesFrom.push_back(fromName);
!           filesTo.push_back(toName);
            }
          }
***************
*** 267,272 ****
      }
  
    // Skip this rule if no files are to be installed for the target.
!   if(files.empty())
      {
      return;
--- 263,271 ----
      }
  
+   // If this fails the above code is buggy.
+   assert(filesFrom.size() == filesTo.size());
+ 
    // Skip this rule if no files are to be installed for the target.
!   if(filesFrom.empty())
      {
      return;
***************
*** 275,278 ****
--- 274,278 ----
    // Construct the path of the file on disk after installation on
    // which tweaks may be performed.
+   std::string const& toInstallPath = filesTo[0];
    std::string toDestDirPath = "$ENV{DESTDIR}";
    if(toInstallPath[0] != '/' && toInstallPath[0] != '$')
***************
*** 303,307 ****
    const char* no_rename = 0;
    bool optional = this->Optional || this->ImportLibrary;
!   this->AddInstallRule(os, type, files,
                         optional,
                         this->FilePermissions.c_str(), no_dir_permissions,
--- 303,307 ----
    const char* no_rename = 0;
    bool optional = this->Optional || this->ImportLibrary;
!   this->AddInstallRule(os, type, filesFrom,
                         optional,
                         this->FilePermissions.c_str(), no_dir_permissions,



More information about the Cmake-commits mailing list