ENH: use full paths for object compile rules
This commit is contained in:
parent
33dbd7acf8
commit
1a8e3ba1e6
|
@ -1423,7 +1423,8 @@ void cmUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fout)
|
||||||
// filename of the object file. Otherwise, we will use just
|
// filename of the object file. Otherwise, we will use just
|
||||||
// the filename portion.
|
// the filename portion.
|
||||||
if((cmSystemTools::GetFilenamePath(source->GetFullPath()).find(m_Makefile->GetCurrentDirectory()) == 0)
|
if((cmSystemTools::GetFilenamePath(source->GetFullPath()).find(m_Makefile->GetCurrentDirectory()) == 0)
|
||||||
|| (cmSystemTools::GetFilenamePath(source->GetFullPath()).find(m_Makefile->GetCurrentOutputDirectory()) == 0))
|
|| (cmSystemTools::GetFilenamePath(source->GetFullPath()).find(m_Makefile->
|
||||||
|
GetCurrentOutputDirectory()) == 0))
|
||||||
{
|
{
|
||||||
sourceName = source->GetSourceName()+"."+source->GetSourceExtension();
|
sourceName = source->GetSourceName()+"."+source->GetSourceExtension();
|
||||||
shortName = source->GetSourceName();
|
shortName = source->GetSourceName();
|
||||||
|
@ -1448,21 +1449,41 @@ 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())
|
||||||
{
|
{
|
||||||
rules.insert(shortName);
|
std::string comment = "Build ";
|
||||||
fout << shortName.c_str() << ".o : " << source->GetFullPath().c_str() << "\n";
|
std::string objectFile = shortName + ".o";
|
||||||
|
comment += objectFile + " From ";
|
||||||
|
comment += source->GetFullPath();
|
||||||
|
std::string compileCommand;
|
||||||
std::string ext = source->GetSourceExtension();
|
std::string ext = source->GetSourceExtension();
|
||||||
if ( ext == "cxx" || ext == "cc" || ext == "cpp" || ext == "C" ||
|
if(ext == "c" )
|
||||||
ext =="m" || ext == "M" || ext == "mm")
|
|
||||||
{
|
{
|
||||||
fout << "\t$(CMAKE_CXX_COMPILER) $(CMAKE_CXXFLAGS) " << exportsDef.c_str()
|
compileCommand = "$(CMAKE_C_COMPILER) $(CMAKE_CFLAGS) ";
|
||||||
<< (shared? "$(CMAKE_SHLIB_CFLAGS) ":"")
|
compileCommand += exportsDef;
|
||||||
<< "$(INCLUDE_FLAGS) -c $< -o $@\n\n ";
|
if(shared)
|
||||||
|
{
|
||||||
|
compileCommand += "$(CMAKE_SHLIB_CFLAGS) ";
|
||||||
|
}
|
||||||
|
compileCommand += "$(INCLUDE_FLAGS) -c $< -o $@";
|
||||||
}
|
}
|
||||||
else if ( ext == "c" )
|
else
|
||||||
{
|
{
|
||||||
fout << "\t$(CMAKE_C_COMPILER) $(CMAKE_CFLAGS) " << exportsDef.c_str()
|
compileCommand = "$(CMAKE_CXX_COMPILER) $(CMAKE_CXXFLAGS) ";
|
||||||
<< (shared? "$(CMAKE_SHLIB_CFLAGS) ":"") << "$(INCLUDE_FLAGS) -c $< -o $@\n\n";
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue