Browse Source

ENH: Attempt to add debug library postfix for visual studio 6

Andy Cedilnik 22 years ago
parent
commit
368d7f7c18

+ 46 - 1
Source/cmLocalVisualStudio6Generator.cxx

@@ -20,6 +20,7 @@
 #include "cmSystemTools.h"
 #include "cmSourceFile.h"
 #include "cmCacheManager.h"
+#include "cmake.h"
 
 #include <cmsys/RegularExpression.hxx>
 
@@ -732,6 +733,7 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
   std::string libOptimizedOptions;
 
   std::string libMultiLineOptions;
+  std::string libMultiLineOptionsForDebug;
   std::string libMultiLineDebugOptions;
   std::string libMultiLineOptimizedOptions;
 
@@ -772,6 +774,12 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
       libMultiLineOptions += " /LIBPATH:";
       libMultiLineOptions += lpath;
       libMultiLineOptions += " \n";
+      libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
+      libMultiLineOptionsForDebug += lpathIntDir;
+      libMultiLineOptionsForDebug += " ";
+      libMultiLineOptionsForDebug += " /LIBPATH:";
+      libMultiLineOptionsForDebug += lpath;
+      libMultiLineOptionsForDebug += " \n";
       }
     }
   if(exePath.size())
@@ -800,6 +808,12 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
       libMultiLineOptions += " /LIBPATH:";
       libMultiLineOptions += lpath;
       libMultiLineOptions += " \n";
+      libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
+      libMultiLineOptionsForDebug += lpathIntDir;
+      libMultiLineOptionsForDebug += " ";
+      libMultiLineOptionsForDebug += " /LIBPATH:";
+      libMultiLineOptionsForDebug += lpath;
+      libMultiLineOptionsForDebug += " \n";
       }
     }
   std::vector<std::string>::const_iterator i;
@@ -830,6 +844,12 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
       libMultiLineOptions += " /LIBPATH:";
       libMultiLineOptions += lpath;
       libMultiLineOptions += " \n";
+      libMultiLineOptionsForDebug += "# ADD LINK32 /LIBPATH:";
+      libMultiLineOptionsForDebug += lpathIntDir;
+      libMultiLineOptionsForDebug += " ";
+      libMultiLineOptionsForDebug += " /LIBPATH:";
+      libMultiLineOptionsForDebug += lpath;
+      libMultiLineOptionsForDebug += " \n";
       }
     }
   
@@ -847,9 +867,19 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
         (target.GetType()==cmTarget::MODULE_LIBRARY && libName != j->first))
       {
       std::string lib = j->first;
+      std::string libDebug = j->first;
+      std::string libPath = j->first + "_CMAKE_PATH";
+      const char* cacheValue
+        = m_GlobalGenerator->GetCMakeInstance()->GetCacheDefinition(
+          libPath.c_str());
+      if ( cacheValue && m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX") )
+        { 
+        libDebug += m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX");
+        }
       if(j->first.find(".lib") == std::string::npos)
         {
         lib += ".lib";
+        libDebug += ".lib";
         }
       lib = cmSystemTools::ConvertToOutputPath(lib.c_str());
 
@@ -861,6 +891,9 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
         libMultiLineOptions += "# ADD LINK32 ";
         libMultiLineOptions +=  lib;
         libMultiLineOptions += "\n";
+        libMultiLineOptionsForDebug += "# ADD LINK32 ";
+        libMultiLineOptionsForDebug +=  libDebug;
+        libMultiLineOptionsForDebug += "\n";
         }
       if (j->second == cmTarget::DEBUG)
         {
@@ -868,7 +901,7 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
         libDebugOptions += lib;
 
         libMultiLineDebugOptions += "# ADD LINK32 ";
-        libMultiLineDebugOptions += lib;
+        libMultiLineDebugOptions += libDebug;
         libMultiLineDebugOptions += "\n";
         }
       if (j->second == cmTarget::OPTIMIZED)
@@ -904,6 +937,9 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
     libMultiLineOptions += "# ADD LINK32 ";
     libMultiLineOptions +=  extraLinkOptions;
     libMultiLineOptions += " \n";
+    libMultiLineOptionsForDebug += "# ADD LINK32 ";
+    libMultiLineOptionsForDebug +=  extraLinkOptions;
+    libMultiLineOptionsForDebug += " \n";
     }
 
   if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"))
@@ -914,6 +950,9 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
     libMultiLineOptions += "# ADD LINK32 ";
     libMultiLineOptions +=  targetLinkFlags;
     libMultiLineOptions += " \n";
+    libMultiLineOptionsForDebug += "# ADD LINK32 ";
+    libMultiLineOptionsForDebug +=  targetLinkFlags;
+    libMultiLineOptionsForDebug += " \n";
     }
 
   
@@ -947,6 +986,8 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
     cmSystemTools::ReplaceString(line, "CM_OPTIMIZED_LIBRARIES",
                                  libOptimizedOptions.c_str());
 
+    cmSystemTools::ReplaceString(line, "CM_MULTILINE_LIBRARIES_FOR_DEBUG",
+                                 libMultiLineOptionsForDebug.c_str());
     cmSystemTools::ReplaceString(line, "CM_MULTILINE_LIBRARIES",
                                  libMultiLineOptions.c_str());
     cmSystemTools::ReplaceString(line, "CM_MULTILINE_DEBUG_LIBRARIES",
@@ -970,6 +1011,10 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
     cmSystemTools::ReplaceString(line, 
                                  "EXTRA_DEFINES", 
                                  m_Makefile->GetDefineFlags());
+    const char* debugPostfix
+      = m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX");
+    cmSystemTools::ReplaceString(line, "DEBUG_POSTFIX", 
+      debugPostfix?debugPostfix:"");
     cmGlobalGenerator* gen = this->GetGlobalGenerator();
     // store flags for each configuration
     std::string flags = " ";

+ 3 - 1
Templates/DLLHeader.dsptemplate

@@ -102,7 +102,9 @@ BSC32=bscmake.exe
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 CM_DEBUG_LIBRARIES CM_LIBRARIES kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+CM_MULTILINE_DEBUG_LIBRARIES
+CM_MULTILINE_LIBRARIES_FOR_DEBUG
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"LIBRARY_OUTPUT_PATHDebug/OUTPUT_LIBNAMEDEBUG_POSTFIX.dll" /pdbtype:sept
 
 CMAKE_CUSTOM_RULE_CODE
 

+ 1 - 1
Templates/EXEHeader.dsptemplate

@@ -102,7 +102,7 @@ LINK32=link.exe
 # ADD BASE LINK32   kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /IGNORE:4089
 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /IGNORE:4089
 CM_MULTILINE_DEBUG_LIBRARIES
-CM_MULTILINE_LIBRARIES
+CM_MULTILINE_LIBRARIES_FOR_DEBUG
 
 CMAKE_CUSTOM_RULE_CODE
 

+ 1 - 1
Templates/EXEWinHeader.dsptemplate

@@ -104,7 +104,7 @@ LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /IGNORE:4089
 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /IGNORE:4089
 CM_MULTILINE_DEBUG_LIBRARIES
-CM_MULTILINE_LIBRARIES
+CM_MULTILINE_LIBRARIES_FOR_DEBUG
 
 
 CMAKE_CUSTOM_RULE_CODE

+ 1 - 0
Templates/staticLibHeader.dsptemplate

@@ -93,6 +93,7 @@ BSC32=bscmake.exe
 # ADD BSC32 /nologo
 LIB32=link.exe -lib
 # ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo /out:"LIBRARY_OUTPUT_PATHDebug\OUTPUT_LIBNAMEDEBUG_POSTFIX.lib"
 
 CMAKE_CUSTOM_RULE_CODE
 

+ 2 - 0
Tests/COnly/CMakeLists.txt

@@ -1,5 +1,7 @@
 # a simple C only test case
 PROJECT (conly C)
+
+SET(CMAKE_DEBUG_POSTFIX "_test_debug_postfix")
 ADD_LIBRARY(testc1 STATIC libc1.c)
 ADD_LIBRARY(testc2 SHARED libc2.c)
 ADD_EXECUTABLE (conly conly.c foo.c foo.h)