Browse Source

ENH: Add support for install postfix

Andy Cedilnik 22 years ago
parent
commit
038abb867e
3 changed files with 28 additions and 1 deletions
  1. 16 1
      Source/cmFileCommand.cxx
  2. 7 0
      Source/cmLocalGenerator.cxx
  3. 5 0
      Source/cmSetCommand.h

+ 16 - 1
Source/cmFileCommand.cxx

@@ -238,10 +238,18 @@ bool cmFileCommand::HandleInstallCommand(std::vector<std::string> const& args)
   std::string destination = "";
   std::string stype = "FILES";
   const char* build_type = m_Makefile->GetDefinition("BUILD_TYPE");
+  const char* debug_postfix = m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX");
   std::string extra_dir = "";
+  int debug = 0;
   if ( build_type )
     {
     extra_dir = build_type;
+    std::string btype = build_type;
+    cmSystemTools::LowerCase(btype);
+    if ( btype == "debug" )
+      {
+      debug = 1;
+      }
     }
 
 
@@ -341,17 +349,24 @@ bool cmFileCommand::HandleInstallCommand(std::vector<std::string> const& args)
     {
     std::string destfile = destination + "/" + cmSystemTools::GetFilenameName(files[i]);
     std::string ctarget = files[i].c_str();
+    std::string fname = cmSystemTools::GetFilenameName(ctarget);
+    std::string ext = cmSystemTools::GetFilenameExtension(ctarget);
+    std::string fnamewe = cmSystemTools::GetFilenameWithoutExtension(ctarget);
     switch( itype )
       {
     case cmTarget::MODULE_LIBRARY:
     case cmTarget::STATIC_LIBRARY:
     case cmTarget::SHARED_LIBRARY:
+      if ( debug )
+        {
+        fname = fnamewe + debug_postfix + "." + ext;
+        }
     case cmTarget::EXECUTABLE:
       if ( extra_dir.size() > 0 )
         {
         cmOStringStream str;
         str << cmSystemTools::GetFilenamePath(ctarget) << "/" << extra_dir << "/" 
-          << cmSystemTools::GetFilenameName(ctarget);
+          << fname;
         ctarget = str.str();
         }
       break;

+ 7 - 0
Source/cmLocalGenerator.cxx

@@ -83,6 +83,13 @@ void cmLocalGenerator::GenerateInstallRules()
   fout << "# Install script for directory: " << m_Makefile->GetCurrentDirectory() 
     << std::endl << std::endl;
 
+  const char* cmakeDebugPosfix = m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX");
+  if ( cmakeDebugPosfix )
+    {
+    fout << "SET(CMAKE_DEBUG_POSTFIX \"" << cmakeDebugPosfix << "\")"
+      << std::endl << std::endl;
+    }
+
   std::string libOutPath = "";
   if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"))
     {

+ 5 - 0
Source/cmSetCommand.h

@@ -47,6 +47,11 @@ public:
    */
   virtual bool IsInherited() {return true;}
 
+  /**
+   * This determines if the command is invoked when in script mode.
+   */
+  virtual bool IsScriptable() { return true; }
+
   /**
    * The name of the command as specified in CMakeList.txt.
    */