clean up object file build rule, and do not attempt to remove link_directories that are in the build tree

This commit is contained in:
Bill Hoffman 2001-11-13 15:54:41 -05:00
parent 274099f7ec
commit 6220a187ba
2 changed files with 98 additions and 78 deletions

View File

@ -397,15 +397,6 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
libDir != libdirs.end(); ++libDir) libDir != libdirs.end(); ++libDir)
{ {
std::string libpath = cmSystemTools::EscapeSpaces(libDir->c_str()); std::string libpath = cmSystemTools::EscapeSpaces(libDir->c_str());
if (m_LibraryOutputPath.size())
{
if(m_LibraryOutputPath != libpath
&& (libpath.find(m_Makefile->GetHomeOutputDirectory())
!= std::string::npos))
{
emitted.insert(libpath);
}
}
if(emitted.insert(libpath).second) if(emitted.insert(libpath).second)
{ {
std::string::size_type pos = libDir->find("-L"); std::string::size_type pos = libDir->find("-L");
@ -646,8 +637,11 @@ void cmUnixMakefileGenerator::OutputTargets(std::ostream& fout)
this->OutputExecutableRule(fout, l->first.c_str(), l->second); this->OutputExecutableRule(fout, l->first.c_str(), l->second);
break; break;
case cmTarget::UTILITY: case cmTarget::UTILITY:
// This is handled by the OutputCustomRules method
case cmTarget::INSTALL_FILES: case cmTarget::INSTALL_FILES:
// This is handled by the OutputInstallRules method
case cmTarget::INSTALL_PROGRAMS: case cmTarget::INSTALL_PROGRAMS:
// This is handled by the OutputInstallRules method
break; break;
} }
} }
@ -1061,7 +1055,6 @@ void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout)
fout << "# End of source group \"" << name.c_str() << "\"\n\n"; fout << "# End of source group \"" << name.c_str() << "\"\n\n";
} }
} }
} }
@ -1387,6 +1380,55 @@ void cmUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
} }
} }
void
cmUnixMakefileGenerator::
OutputBuildObjectFromSource(std::ostream& fout,
const char* shortName,
const cmSourceFile& source,
const char* extraCompileFlags,
bool shared)
{
std::string comment = "Build ";
std::string objectFile = std::string(shortName) + ".o";
comment += objectFile + " From ";
comment += source.GetFullPath();
std::string compileCommand;
std::string ext = source.GetSourceExtension();
if(ext == "c" )
{
compileCommand = "$(CMAKE_C_COMPILER) $(CMAKE_CFLAGS) ";
compileCommand += extraCompileFlags;
if(shared)
{
compileCommand += "$(CMAKE_SHLIB_CFLAGS) ";
}
compileCommand += "$(INCLUDE_FLAGS) -c ";
compileCommand += source.GetFullPath();
compileCommand += " -o ";
compileCommand += objectFile;
}
else
{
compileCommand = "$(CMAKE_CXX_COMPILER) $(CMAKE_CXXFLAGS) ";
compileCommand += extraCompileFlags;
if(shared)
{
compileCommand += "$(CMAKE_SHLIB_CFLAGS) ";
}
compileCommand += "$(INCLUDE_FLAGS) -c ";
compileCommand += source.GetFullPath();
compileCommand += " -o ";
compileCommand += objectFile;
}
this->OutputMakeRule(fout,
comment.c_str(),
objectFile.c_str(),
source.GetFullPath().c_str(),
compileCommand.c_str());
}
void cmUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fout) void cmUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fout)
{ {
@ -1446,43 +1488,11 @@ void cmUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fout)
// Only output a rule for each .o once. // Only output a rule for each .o once.
if(rules.find(shortName) == rules.end()) if(rules.find(shortName) == rules.end())
{ {
std::string comment = "Build "; this->OutputBuildObjectFromSource(fout,
std::string objectFile = shortName + ".o"; shortName.c_str(),
comment += objectFile + " From "; *source,
comment += source->GetFullPath(); exportsDef.c_str(),
std::string compileCommand; shared);
std::string ext = source->GetSourceExtension();
if(ext == "c" )
{
compileCommand = "$(CMAKE_C_COMPILER) $(CMAKE_CFLAGS) ";
compileCommand += exportsDef;
if(shared)
{
compileCommand += "$(CMAKE_SHLIB_CFLAGS) ";
}
compileCommand += "$(INCLUDE_FLAGS) -c ";
compileCommand += source->GetFullPath();
compileCommand += " -o ";
compileCommand += objectFile;
}
else
{
compileCommand = "$(CMAKE_CXX_COMPILER) $(CMAKE_CXXFLAGS) ";
compileCommand += exportsDef;
if(shared)
{
compileCommand += "$(CMAKE_SHLIB_CFLAGS) ";
}
compileCommand += "$(INCLUDE_FLAGS) -c ";
compileCommand += source->GetFullPath();
compileCommand += " -o ";
compileCommand += objectFile;
}
this->OutputMakeRule(fout,
comment.c_str(),
objectFile.c_str(),
source->GetFullPath().c_str(),
compileCommand.c_str());
rules.insert(shortName); rules.insert(shortName);
} }
} }

View File

@ -56,7 +56,7 @@ public:
///! Set cache only and recurse to false by default. ///! Set cache only and recurse to false by default.
cmUnixMakefileGenerator(); cmUnixMakefileGenerator();
~cmUnixMakefileGenerator(); virtual ~cmUnixMakefileGenerator();
///! Get the name for the generator. ///! Get the name for the generator.
virtual const char* GetName() {return "Unix Makefiles";} virtual const char* GetName() {return "Unix Makefiles";}
@ -91,7 +91,7 @@ public:
* in the makefile. These would have been generated * in the makefile. These would have been generated
* by the class cmMakeDepend. * by the class cmMakeDepend.
*/ */
void OutputObjectDepends(std::ostream&); virtual void OutputObjectDepends(std::ostream&);
/** /**
* Try to determine system infomation such as shared library * Try to determine system infomation such as shared library
@ -99,36 +99,46 @@ public:
*/ */
virtual void ComputeSystemInfo(); virtual void ComputeSystemInfo();
private: protected:
void RecursiveGenerateCacheOnly(); virtual void RecursiveGenerateCacheOnly();
void ProcessDepends(const cmMakeDepend &md); virtual void ProcessDepends(const cmMakeDepend &md);
void GenerateCacheOnly(); virtual void GenerateCacheOnly();
void OutputMakefile(const char* file); virtual void OutputMakefile(const char* file);
void OutputTargetRules(std::ostream& fout); virtual void OutputTargetRules(std::ostream& fout);
void OutputLinkLibraries(std::ostream&, const char* name, const cmTarget &); virtual void OutputLinkLibraries(std::ostream&, const char* name, const cmTarget &);
void OutputSharedLibraryRule(std::ostream&, const char* name, const cmTarget &); virtual void OutputSharedLibraryRule(std::ostream&, const char* name,
void OutputModuleLibraryRule(std::ostream&, const char* name, const cmTarget &); const cmTarget &);
void OutputStaticLibraryRule(std::ostream&, const char* name, const cmTarget &); virtual void OutputModuleLibraryRule(std::ostream&, const char* name,
void OutputExecutableRule(std::ostream&, const char* name, const cmTarget &); const cmTarget &);
virtual void OutputStaticLibraryRule(std::ostream&, const char* name,
const cmTarget &);
virtual void OutputExecutableRule(std::ostream&, const char* name,
const cmTarget &);
void OutputTargets(std::ostream&); virtual void OutputTargets(std::ostream&);
void OutputSubDirectoryRules(std::ostream&); virtual void OutputSubDirectoryRules(std::ostream&);
void OutputDependInformation(std::ostream&); virtual void OutputDependLibs(std::ostream&);
void OutputDependLibs(std::ostream&); virtual void OutputLibDepend(std::ostream&, const char*);
void OutputLibDepend(std::ostream&, const char*); virtual void OutputCustomRules(std::ostream&);
void OutputCustomRules(std::ostream&); virtual void OutputMakeVariables(std::ostream&);
void OutputMakeVariables(std::ostream&); virtual void OutputMakeRules(std::ostream&);
void OutputMakeRules(std::ostream&); virtual void OutputInstallRules(std::ostream&);
void OutputInstallRules(std::ostream&); virtual void OutputSourceObjectBuildRules(std::ostream& fout);
void OutputSourceObjectBuildRules(std::ostream& fout); virtual void OutputBuildObjectFromSource(std::ostream& fout,
void OutputSubDirectoryVars(std::ostream& fout, const char* shortName,
const char* var, const cmSourceFile& source,
const char* target, const char* extraCompileFlags,
const char* target1, bool sharedTarget);
const char* target2,
const std::vector<std::string>& SubDirectories); virtual void OutputSubDirectoryVars(std::ostream& fout,
void OutputMakeRule(std::ostream&, const char* var,
const char* target,
const char* target1,
const char* target2,
const std::vector<std::string>&
SubDirectories);
virtual void OutputMakeRule(std::ostream&,
const char* comment, const char* comment,
const char* target, const char* target,
const char* depends, const char* depends,