Quellcode durchsuchen

ENH: name pdb files for visual studio make based builds

Bill Hoffman vor 19 Jahren
Ursprung
Commit
e6ef33f598

+ 5 - 5
Modules/Platform/Windows-cl.cmake

@@ -14,7 +14,7 @@ ELSE(CMAKE_VERBOSE_MAKEFILE)
 ENDIF(CMAKE_VERBOSE_MAKEFILE)
 # create a shared C++ library 
 SET(CMAKE_CXX_CREATE_SHARED_LIBRARY 
-  "link ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out:<TARGET> /dll  <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
+  "link ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out:<TARGET> /PDB:<TARGET_PDB> /dll  <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
 SET(CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
 
 # create a C shared library
@@ -31,18 +31,18 @@ SET(CMAKE_C_CREATE_STATIC_LIBRARY "${CMAKE_CXX_CREATE_STATIC_LIBRARY}")
 
 # compile a C++ file into an object file
 SET(CMAKE_CXX_COMPILE_OBJECT
-    "<CMAKE_CXX_COMPILER>  ${CMAKE_START_TEMP_FILE}  ${CMAKE_CL_NOLOGO} <FLAGS>  /TP /Fo<OBJECT> -c <SOURCE>${CMAKE_END_TEMP_FILE}")
+    "<CMAKE_CXX_COMPILER>  ${CMAKE_START_TEMP_FILE}  ${CMAKE_CL_NOLOGO} <FLAGS>  /TP /Fo<OBJECT> /Fd<TARGET_PDB> -c <SOURCE>${CMAKE_END_TEMP_FILE}")
 
 # compile a C file into an object file
 SET(CMAKE_C_COMPILE_OBJECT
-    "<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> /Fo<OBJECT>   -c <SOURCE>${CMAKE_END_TEMP_FILE}")
+    "<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO} <FLAGS> /Fo<OBJECT> /Fd<TARGET_PDB>  -c <SOURCE>${CMAKE_END_TEMP_FILE}")
 
 
 SET(CMAKE_C_LINK_EXECUTABLE
-    "<CMAKE_C_COMPILER> ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} <FLAGS> <OBJECTS> /Fe<TARGET> -link <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
+    "<CMAKE_C_COMPILER> ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} <FLAGS> <OBJECTS> /Fe<TARGET> /Fd<TARGET_PDB> -link <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
 
 SET(CMAKE_CXX_LINK_EXECUTABLE
-    "<CMAKE_CXX_COMPILER> ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} <FLAGS> <OBJECTS> /Fe<TARGET> -link <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
+    "<CMAKE_CXX_COMPILER> ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} <FLAGS> <OBJECTS> /Fe<TARGET> /Fd<TARGET_PDB> -link <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
 
 SET(CMAKE_CREATE_WIN32_EXE /subsystem:windows)
 SET(CMAKE_CREATE_CONSOLE_EXE /subsystem:console)

+ 8 - 0
Source/cmLocalGenerator.cxx

@@ -734,6 +734,14 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
       return replaceValues.ObjectsQuoted;
       }
     }
+  if(replaceValues.TargetPDB )
+    {
+    if(variable == "TARGET_PDB")
+      {
+      return replaceValues.TargetPDB;
+      }
+    }
+
   if(replaceValues.Target)
     { 
     if(variable == "TARGET_QUOTED")

+ 1 - 0
Source/cmLocalGenerator.h

@@ -192,6 +192,7 @@ public:
         this->TargetInstallNameDir = 0;
         this->LinkFlags= 0;
       }
+    const char* TargetPDB;
     const char* Language;
     const char* Objects;
     const char* Target;

+ 12 - 6
Source/cmMakefileExecutableTargetGenerator.cxx

@@ -168,17 +168,22 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
     }
   std::string targetFullPath = outpath + targetName;
   std::string targetFullPathReal = outpath + targetNameReal;
-
+  std::string targetFullPathPDB = outpath + this->Target->GetName();
+  targetFullPathPDB += ".pdb";
+  std::string targetOutPathPDB = 
+    this->Convert(targetFullPathPDB.c_str(),
+                  cmLocalGenerator::FULL,
+                  cmLocalGenerator::MAKEFILE); 
   // Convert to the output path to use in constructing commands.
   std::string targetOutPath =
     this->Convert(targetFullPath.c_str(),
-                                  cmLocalGenerator::START_OUTPUT,
-                                  cmLocalGenerator::MAKEFILE);
+                  cmLocalGenerator::START_OUTPUT,
+                  cmLocalGenerator::MAKEFILE); 
   std::string targetOutPathReal =
     this->Convert(targetFullPathReal.c_str(),
-                                  cmLocalGenerator::START_OUTPUT,
-                                  cmLocalGenerator::MAKEFILE);
-
+                  cmLocalGenerator::START_OUTPUT,
+                  cmLocalGenerator::MAKEFILE);
+  
   // Get the language to use for linking this executable.
   const char* linkLanguage =
     this->Target->GetLinkerLanguage(this->GlobalGenerator);
@@ -328,6 +333,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   vars.Language = linkLanguage;
   vars.Objects = buildObjs.c_str();
   vars.Target = targetOutPathReal.c_str();
+  vars.TargetPDB = targetOutPathPDB.c_str();
   std::string linkString = linklibs.str();
   vars.LinkLibraries = linkString.c_str();
   vars.Flags = flags.c_str();

+ 5 - 0
Source/cmMakefileLibraryTargetGenerator.cxx

@@ -233,12 +233,16 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
     outpath += "/";
     }
   std::string targetFullPath = outpath + targetName;
+  std::string targetFullPathPDB = outpath + this->Target->GetName() + std::string(".pdb");
   std::string targetFullPathSO = outpath + targetNameSO;
   std::string targetFullPathReal = outpath + targetNameReal;
   std::string targetFullPathImport = outpath + targetNameImport;
 
   // Construct the output path version of the names for use in command
   // arguments.
+  std::string targetOutPathPDB = 
+    this->Convert(targetFullPathPDB.c_str(),cmLocalGenerator::FULL,
+                  cmLocalGenerator::MAKEFILE);
   std::string targetOutPath = 
     this->Convert(targetFullPath.c_str(),cmLocalGenerator::START_OUTPUT,
                   cmLocalGenerator::MAKEFILE);
@@ -402,6 +406,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   cleanObjs += variableName;
   cleanObjs += ")";
   cmLocalGenerator::RuleVariables vars;
+  vars.TargetPDB = targetOutPathPDB.c_str();
   vars.Language = linkLanguage;
   vars.Objects = buildObjs.c_str();
   std::string objdir = "CMakeFiles/";

+ 8 - 0
Source/cmMakefileTargetGenerator.cxx

@@ -385,8 +385,16 @@ cmMakefileTargetGenerator
   std::string compileRule =
     this->Makefile->GetRequiredDefinition(compileRuleVar.c_str());
   cmSystemTools::ExpandListArgument(compileRule, commands);
+
+  std::string outpath = this->Makefile->GetStartOutputDirectory();
+  outpath += "/";
+  outpath += this->Target->GetName();
+  outpath += ".pdb";
+  outpath = this->Convert(outpath.c_str(), cmLocalGenerator::FULL,
+                          cmLocalGenerator::MAKEFILE);
   cmLocalGenerator::RuleVariables vars;
   vars.Language = lang;
+  vars.TargetPDB = outpath.c_str();
   vars.Source = sourceFile.c_str();
   vars.Object = relativeObj.c_str();
   std::string objdir = this->LocalGenerator->GetHomeRelativeOutputPath();