Browse Source

BUG: fix jump to directory and build for nmake if library path is not set. combine OutputBuildExecutableInDir and OutputBuildLibraryInDir into OutputBuildTargetInDir

Bill Hoffman 23 năm trước cách đây
mục cha
commit
fc7e4169e1

+ 11 - 6
Source/cmNMakeMakefileGenerator.cxx

@@ -676,22 +676,27 @@ bool cmNMakeMakefileGenerator::SamePath(const char* path1, const char* path2)
     cmSystemTools::LowerCase(ShortPath(path2));
 }
 
-void cmNMakeMakefileGenerator::OutputBuildLibraryInDir(std::ostream& fout,
-						       const char* path,
-						       const char* ,
-						       const char* fullpath)
+void cmNMakeMakefileGenerator::OutputBuildTargetInDir(std::ostream& fout,
+                                                      const char* path,
+                                                      const char* library,
+                                                      const char* fullpath,
+                                                      const char* libOutPath)
 {
-
+  const char* makeTarget = library;
   std::string currentDir = 
     this->ConvertToOutputPath(m_Makefile->GetCurrentOutputDirectory());
   std::string wpath = this->ConvertToOutputPath(path);
   std::string wfullpath = this->ConvertToOutputPath(fullpath);
+  if(libOutPath && strcmp( libOutPath, "" ) != 0)
+    {
+    makeTarget = wfullpath.c_str();
+    }
   fout << wfullpath
        << ":\n\tcd " << wpath  << "\n"
        << "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.depends\n"
        << "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.check_depends\n"
        << "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) -f cmake.check_depends\n"
-       << "\t$(MAKE) $(MAKESILENT) " << wfullpath
+       << "\t$(MAKE) $(MAKESILENT) " << makeTarget
        << "\n\tcd " << currentDir << "\n";
 }
 

+ 5 - 4
Source/cmNMakeMakefileGenerator.h

@@ -79,10 +79,11 @@ protected:
                                    const cmTarget &tgt);
   virtual std::string GetOutputExtension(const char* sourceExtension); 
   virtual void OutputIncludeMakefile(std::ostream&, const char* file);
-  virtual void OutputBuildLibraryInDir(std::ostream& fout,
-				       const char* path,
-				       const char* library,
-				       const char* fullpath); 
+  virtual void OutputBuildTargetInDir(std::ostream& fout,
+                                      const char* path,
+                                      const char* library,
+                                      const char* fullpath,
+                                      const char* outputPath); 
   ///! return true if the two paths are the same (checks short paths)
   virtual bool SamePath(const char* path1, const char* path2);
   void SetLibraryPathOption(const char* lib){ m_LibraryPathOption = lib;}

+ 22 - 33
Source/cmUnixMakefileGenerator.cxx

@@ -986,10 +986,13 @@ void cmUnixMakefileGenerator::OutputDependLibs(std::ostream& fout)
           }
         libpath += library;
         // put out a rule to build the library if it does not exist
-        this->OutputBuildLibraryInDir(fout,
-                                      cacheValue,
-                                      library.c_str(),
-                                      libpath.c_str());
+        this->OutputBuildTargetInDir(fout,
+                                     cacheValue,
+                                     library.c_str(),
+                                     libpath.c_str(),
+                                     m_Makefile->
+                                     GetDefinition("LIBRARY_OUTPUT_PATH")
+                                     );
         }
       // something other than a library...
       else
@@ -1004,23 +1007,26 @@ void cmUnixMakefileGenerator::OutputDependLibs(std::ostream& fout)
           exepath += "/";
           }
         exepath += *lib;
-        this->OutputBuildExecutableInDir(fout,
-                                         cacheValue,
-                                         lib->c_str(),
-                                         exepath.c_str());
+        this->OutputBuildTargetInDir(fout,
+                                      cacheValue,
+                                      lib->c_str(),
+                                      exepath.c_str(),
+                                      m_Makefile->
+                                     GetDefinition("EXECUTABLE_OUTPUT_PATH")
+                                      );
         }
       }
     }
 }
 
-void cmUnixMakefileGenerator::OutputBuildLibraryInDir(std::ostream& fout,
-						      const char* path,
-						      const char* library,
-						      const char* fullpath)
+void cmUnixMakefileGenerator::OutputBuildTargetInDir(std::ostream& fout,
+                                                     const char* path,
+                                                     const char* library,
+                                                     const char* fullpath,
+                                                     const char* outputPath)
 {
   const char* makeTarget = library;
-  const char* libOutPath = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH");
-  if(libOutPath && strcmp( libOutPath, "" ) != 0)
+  if(outputPath && strcmp( outputPath, "" ) != 0)
     {
     makeTarget = fullpath;
     }
@@ -1029,27 +1035,10 @@ void cmUnixMakefileGenerator::OutputBuildLibraryInDir(std::ostream& fout,
        << "; $(MAKE) $(MAKESILENT) cmake.depends"
        << "; $(MAKE) $(MAKESILENT) cmake.check_depends"
        << "; $(MAKE) $(MAKESILENT) -f cmake.check_depends"
-       << "; $(MAKE) $(MAKESILENT) " << makeTarget << "\n\n"; 
+       << "; $(MAKE) $(MAKESILENT) "
+       << this->ConvertToOutputPath(makeTarget) << "\n\n"; 
 }
 
-void cmUnixMakefileGenerator::OutputBuildExecutableInDir(std::ostream& fout,
-                                                         const char* path,
-                                                         const char* library,
-                                                         const char* fullpath)
-{
-  const char* makeTarget = library;
-  const char* libOutPath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
-  if(libOutPath && strcmp( libOutPath, "" ) != 0)
-    {
-    makeTarget = fullpath;
-    }
-  fout << this->ConvertToOutputPath(fullpath)
-       << ":\n\tcd " << this->ConvertToOutputPath(path)
-       << "; $(MAKE) $(MAKESILENT) cmake.depends"
-       << "; $(MAKE) $(MAKESILENT) cmake.check_depends"
-       << "; $(MAKE) $(MAKESILENT) -f cmake.check_depends"
-       << "; $(MAKE) $(MAKESILENT) " << makeTarget << "\n\n"; 
-}
 
 bool cmUnixMakefileGenerator::SamePath(const char* path1, const char* path2)
 {

+ 5 - 8
Source/cmUnixMakefileGenerator.h

@@ -141,14 +141,11 @@ protected:
                               const char* command2 = 0,
                               const char* command3 = 0,
                               const char* command4 = 0);
-  virtual void OutputBuildLibraryInDir(std::ostream& fout,
-				       const char* path,
-				       const char* library,
-				       const char* fullpath);
-  virtual void OutputBuildExecutableInDir(std::ostream& fout,
-                                          const char* path,
-                                          const char* library,
-                                          const char* fullpath);
+  virtual void OutputBuildTargetInDir(std::ostream& fout,
+                                      const char* path,
+                                      const char* library,
+                                      const char* fullpath,
+                                      const char* outputPath);
   ///! return true if the two paths are the same
   virtual bool SamePath(const char* path1, const char* path2);
   virtual std::string GetOutputExtension(const char* sourceExtension);