Browse Source

BUG: Fixed optional file install support for multi-configuration generators.

Brad King 19 years ago
parent
commit
3ca9ef09b7
3 changed files with 21 additions and 43 deletions
  1. 8 21
      Source/cmFileCommand.cxx
  2. 5 21
      Source/cmInstallGenerator.cxx
  3. 8 1
      Source/cmInstallTargetGenerator.cxx

+ 8 - 21
Source/cmFileCommand.cxx

@@ -290,13 +290,6 @@ bool cmFileCommand::HandleInstallCommand(
 
   const char* destdir = cmSystemTools::GetEnv("DESTDIR");
 
-  std::string extra_dir = "";
-  if ( build_type )
-    {
-    extra_dir = build_type;
-    std::string btype = cmSystemTools::LowerCase(build_type);
-    }
-
   std::vector<std::string> files;
   int itype = cmTarget::INSTALL_FILES;
 
@@ -553,14 +546,9 @@ bool cmFileCommand::HandleInstallCommand(
           }
 
         // Reconstruct the source file path taking into account the
-        // extra directory and possible new file name.
+        // possibly new file name.
         cmOStringStream str;
-        str << cmSystemTools::GetFilenamePath(ctarget) << "/";
-        if ( extra_dir.size() > 0 )
-          {
-          str << extra_dir << "/";
-          }
-        str << fname;
+        str << cmSystemTools::GetFilenamePath(ctarget) << "/" << fname;
         ctarget = str.str();
         }
       break;
@@ -597,23 +585,22 @@ bool cmFileCommand::HandleInstallCommand(
         }
 
       // Reconstruct the source file path taking into account the
-      // extra directory and possible new file name.
+      // possibly new file name.
       cmOStringStream str;
-      str << cmSystemTools::GetFilenamePath(ctarget) << "/";
-      if ( extra_dir.size() > 0 )
-        {
-        str << extra_dir << "/";
-        }
-      str << fname;
+      str << cmSystemTools::GetFilenamePath(ctarget) << "/" << fname;
       ctarget = str.str();
       }
       break;
       }
 
+    std::string message;
     if ( !cmSystemTools::SameFile(ctarget.c_str(), destfile.c_str()) )
       {
       if ( cmSystemTools::FileExists(ctarget.c_str()) )
         {
+        message = "Installing ";
+        message += destfile.c_str();
+        m_Makefile->DisplayStatus(message.c_str(), -1);
         cmSystemTools::RemoveFile(destfile.c_str());
         if ( !cmSystemTools::CopyFileAlways(ctarget.c_str(), 
             destination.c_str()) )

+ 5 - 21
Source/cmInstallGenerator.cxx

@@ -54,19 +54,6 @@ void cmInstallGenerator::AddInstallRule(std::ostream& os,
                                         bool optional /* = false */,
                                         const char* properties /* = 0 */)
 {
-  // If the file is optional test its existence before installing.
-  const char* indent = "";
-  if(optional)
-    {
-    os << "IF(EXISTS \"" << file << "\")\n";
-    indent = "  ";
-    }
-
-  // Write a message indicating the file is being installed.
-  std::string fname = cmSystemTools::GetFilenameName(file);
-  os << indent << "MESSAGE(STATUS \"Installing " << dest
-     << "/" << fname.c_str() << "\")\n";
-
   // Use the FILE command to install the file.
   std::string stype;
   switch(type)
@@ -79,17 +66,14 @@ void cmInstallGenerator::AddInstallRule(std::ostream& os,
     case cmTarget::INSTALL_FILES:
     default:                         stype = "FILE"; break;
     }
-  os << indent << "FILE(INSTALL DESTINATION \"" << dest
-     << "\" TYPE " << stype.c_str() ;
+  os << "FILE(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype.c_str();
+  if(optional)
+    {
+    os << " OPTIONAL";
+    }
   if(properties && *properties)
     {
     os << " PROPERTIES" << properties;
     }
   os << " FILES \"" << file << "\")\n";
-
-  // If the file is optional close the IF block.
-  if(optional)
-    {
-    os << "ENDIF(EXISTS \"" << file << "\")\n";
-    }
 }

+ 8 - 1
Source/cmInstallTargetGenerator.cxx

@@ -16,6 +16,8 @@
 =========================================================================*/
 #include "cmInstallTargetGenerator.h"
 
+#include "cmGlobalGenerator.h"
+#include "cmLocalGenerator.h"
 #include "cmMakefile.h"
 #include "cmTarget.h"
 
@@ -162,8 +164,13 @@ cmInstallTargetGenerator
         this->ConfigurationTypes->begin();
       i != this->ConfigurationTypes->end(); ++i)
     {
+    // Start with the configuration's subdirectory.
+    fname = "";
+    this->Target->GetMakefile()->GetLocalGenerator()->GetGlobalGenerator()->
+      AppendDirectoryForConfig(i->c_str(), fname);
+
     // Set a variable with the target name for this configuration.
-    fname = this->Target->GetFullName(i->c_str(), this->ImportLibrary);
+    fname += this->Target->GetFullName(i->c_str(), this->ImportLibrary);
     os << "SET(" << this->Target->GetName()
        << (this->ImportLibrary? "_IMPNAME_" : "_NAME_") << *i
        << " \"" << fname << "\")\n";