Commit aa47caab authored by Bill Hoffman's avatar Bill Hoffman
Browse files

FIX: apply patch from bug# 1965

parent 1e72091e
......@@ -207,8 +207,8 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule()
void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
const char *libName,
cmTarget &target)
const char *libName,
cmTarget &target)
{
// if we should add regen rule then...
const char *suppRegenRule =
......@@ -316,110 +316,127 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
for(std::vector<cmSourceGroup>::const_iterator sg = sourceGroups.begin();
sg != sourceGroups.end(); ++sg)
{
const std::vector<const cmSourceFile *> &sourceFiles =
sg->GetSourceFiles();
// If the group is empty, don't write it at all.
if(sourceFiles.empty())
{
continue;
}
this->WriteGroup(&(*sg), target, fout, libName);
}
// Write the DSP file's footer.
this->WriteDSPFooter(fout);
}
void cmLocalVisualStudio6Generator::WriteGroup(const cmSourceGroup *sg, cmTarget target, std::ostream &fout, const char *libName)
{
const std::vector<const cmSourceFile *> &sourceFiles =
sg->GetSourceFiles();
// If the group is empty, don't write it at all.
if(sourceFiles.empty())
{
return;
}
// If the group has a name, write the header.
std::string name = sg->GetName();
if(name != "")
{
this->WriteDSPBeginGroup(fout, name.c_str(), "");
}
// If the group has a name, write the header.
std::string name = sg->GetName();
if(name != "")
// Loop through each source in the source group.
for(std::vector<const cmSourceFile *>::const_iterator sf =
sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
{
std::string source = (*sf)->GetFullPath();
const cmCustomCommand *command =
(*sf)->GetCustomCommand();
std::string compileFlags;
std::vector<std::string> depends;
const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS");
if(cflags)
{
this->WriteDSPBeginGroup(fout, name.c_str(), "");
compileFlags = cflags;
}
// Loop through each source in the source group.
for(std::vector<const cmSourceFile *>::const_iterator sf =
sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
const char* lang =
m_GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str());
if(lang && strcmp(lang, "CXX") == 0)
{
std::string source = (*sf)->GetFullPath();
const cmCustomCommand *command =
(*sf)->GetCustomCommand();
std::string compileFlags;
std::vector<std::string> depends;
const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS");
if(cflags)
{
compileFlags = cflags;
}
const char* lang =
m_GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str());
if(lang && strcmp(lang, "CXX") == 0)
// force a C++ file type
compileFlags += " /TP ";
}
// Check for extra object-file dependencies.
const char* dependsValue = (*sf)->GetProperty("OBJECT_DEPENDS");
if(dependsValue)
{
cmSystemTools::ExpandListArgument(dependsValue, depends);
}
if (source != libName || target.GetType() == cmTarget::UTILITY)
{
fout << "# Begin Source File\n\n";
// Tell MS-Dev what the source is. If the compiler knows how to
// build it, then it will.
fout << "SOURCE=" <<
this->ConvertToOptionallyRelativeOutputPath(source.c_str()) << "\n\n";
if(!depends.empty())
{
// force a C++ file type
compileFlags += " /TP ";
// Write out the dependencies for the rule.
fout << "USERDEP__HACK=";
for(std::vector<std::string>::const_iterator d = depends.begin();
d != depends.end(); ++d)
{
fout << "\\\n\t" <<
this->ConvertToOptionallyRelativeOutputPath(d->c_str());
}
fout << "\n";
}
// Check for extra object-file dependencies.
const char* dependsValue = (*sf)->GetProperty("OBJECT_DEPENDS");
if(dependsValue)
if (command)
{
cmSystemTools::ExpandListArgument(dependsValue, depends);
std::string script =
this->ConstructScript(command->GetCommandLines(), "\\\n\t");
const char* comment = command->GetComment();
const char* flags = compileFlags.size() ? compileFlags.c_str(): 0;
this->WriteCustomRule(fout, source.c_str(), script.c_str(),
(*comment?comment:"Custom Rule"),
command->GetDepends(),
command->GetOutput(), flags);
}
if (source != libName || target.GetType() == cmTarget::UTILITY)
else if(compileFlags.size())
{
fout << "# Begin Source File\n\n";
// Tell MS-Dev what the source is. If the compiler knows how to
// build it, then it will.
fout << "SOURCE=" <<
this->ConvertToOptionallyRelativeOutputPath(source.c_str()) << "\n\n";
if(!depends.empty())
{
// Write out the dependencies for the rule.
fout << "USERDEP__HACK=";
for(std::vector<std::string>::const_iterator d = depends.begin();
d != depends.end(); ++d)
{
fout << "\\\n\t" <<
this->ConvertToOptionallyRelativeOutputPath(d->c_str());
for(std::vector<std::string>::iterator i
= m_Configurations.begin(); i != m_Configurations.end(); ++i)
{
if (i == m_Configurations.begin())
{
fout << "!IF \"$(CFG)\" == " << i->c_str() << std::endl;
}
fout << "\n";
}
if (command)
{
std::string script =
this->ConstructScript(command->GetCommandLines(), "\\\n\t");
const char* comment = command->GetComment();
const char* flags = compileFlags.size() ? compileFlags.c_str(): 0;
this->WriteCustomRule(fout, source.c_str(), script.c_str(),
(*comment?comment:"Custom Rule"),
command->GetDepends(),
command->GetOutput(), flags);
}
else if(compileFlags.size())
{
for(std::vector<std::string>::iterator i
= m_Configurations.begin(); i != m_Configurations.end(); ++i)
{
if (i == m_Configurations.begin())
{
fout << "!IF \"$(CFG)\" == " << i->c_str() << std::endl;
}
else
{
fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl;
}
fout << "\n# ADD CPP " << compileFlags << "\n\n";
}
fout << "!ENDIF\n\n";
}
fout << "# End Source File\n";
else
{
fout << "!ELSEIF \"$(CFG)\" == " << i->c_str() << std::endl;
}
fout << "\n# ADD CPP " << compileFlags << "\n\n";
}
fout << "!ENDIF\n\n";
}
fout << "# End Source File\n";
}
}
std::vector<cmSourceGroup> children = sg->GetGroupChildren();
for(unsigned int i=0;i<children.size();++i)
{
this->WriteGroup(&children[i], target, fout, libName);
}
// If the group has a name, write the footer.
if(name != "")
{
this->WriteDSPEndGroup(fout);
}
}
// If the group has a name, write the footer.
if(name != "")
{
this->WriteDSPEndGroup(fout);
}
// Write the DSP file's footer.
this->WriteDSPFooter(fout);
}
......@@ -458,13 +475,13 @@ cmLocalVisualStudio6Generator
}
void cmLocalVisualStudio6Generator::WriteCustomRule(std::ostream& fout,
const char* source,
const char* command,
const char* comment,
const std::vector<std::string>& depends,
const char *output,
const char* flags
)
const char* source,
const char* command,
const char* comment,
const std::vector<std::string>& depends,
const char *output,
const char* flags
)
{
std::vector<std::string>::iterator i;
for(i = m_Configurations.begin(); i != m_Configurations.end(); ++i)
......@@ -544,8 +561,8 @@ void cmLocalVisualStudio6Generator::WriteCustomRule(std::ostream& fout,
void cmLocalVisualStudio6Generator::WriteDSPBeginGroup(std::ostream& fout,
const char* group,
const char* filter)
const char* group,
const char* filter)
{
fout << "# Begin Group \"" << group << "\"\n"
"# PROP Default_Filter \"" << filter << "\"\n";
......@@ -763,9 +780,11 @@ void cmLocalVisualStudio6Generator
libPath = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH");
}
std::string exePath = "";
std::string exePathDebug = "";
if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
{
exePath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
}
if(libPath.size())
{
......@@ -952,13 +971,37 @@ void cmLocalVisualStudio6Generator
extraLinkOptions =
m_Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS");
// if the executable has an output name then add the appropriate flag
if (target.GetProperty("OUTPUT_NAME"))
{
std::string outputname = target.GetProperty("OUTPUT_NAME");
libMultiLineOptions += "# ADD LINK32 /out:";
libMultiLineOptions += target.GetProperty("OUTPUT_NAME");
libMultiLineOptions += outputname;
libMultiLineOptions += " \n";
}
else
{
libMultiLineOptions += "# ADD LINK32 /out:\"";
if(exePath != "")
libMultiLineOptions += exePath + "/" + libName + ".exe";
else
libMultiLineOptions += std::string(libName) + ".exe";
libMultiLineOptions += "\"\n";
libMultiLineOptionsForDebug += "# ADD LINK32 /out:\"";
if(exePath != "")
libMultiLineOptionsForDebug += exePath + "/" + libName + "D.exe";
else
libMultiLineOptionsForDebug += std::string(libName) + "D.exe";
libMultiLineOptionsForDebug += "\"\n";
}
}
if(target.GetType() == cmTarget::SHARED_LIBRARY)
{
......@@ -1087,16 +1130,35 @@ void cmLocalVisualStudio6Generator
cmSystemTools::ReplaceString(line, "LIBRARY_OUTPUT_PATH",
removeQuotes(
this->ConvertToOptionallyRelativeOutputPath(libPath.c_str())).c_str());
cmSystemTools::ReplaceString(line, "EXECUTABLE_OUTPUT_PATH",
removeQuotes(
this->ConvertToOptionallyRelativeOutputPath(exePath.c_str())).c_str());
if (!m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH_OVERRIDE") || exePath == "")
{
cmSystemTools::ReplaceString(line, "EXECUTABLE_OUTPUT_PATH",
removeQuotes(
this->ConvertToOptionallyRelativeOutputPath(exePath.c_str())).c_str());
} else
{
cmSystemTools::ReplaceString(line, "EXECUTABLE_OUTPUT_PATHRelease",
removeQuotes(
this->ConvertToOptionallyRelativeOutputPath(exePath.c_str())).c_str());
cmSystemTools::ReplaceString(line, "EXECUTABLE_OUTPUT_PATHDebug",
removeQuotes(
this->ConvertToOptionallyRelativeOutputPath(exePath.c_str())).c_str());
cmSystemTools::ReplaceString(line, "EXECUTABLE_OUTPUT_PATHMinSizeRel",
removeQuotes(
this->ConvertToOptionallyRelativeOutputPath(exePath.c_str())).c_str());
cmSystemTools::ReplaceString(line, "EXECUTABLE_OUTPUT_PATHRelWithDebInfo",
removeQuotes(
this->ConvertToOptionallyRelativeOutputPath(exePath.c_str())).c_str());
}
cmSystemTools::ReplaceString(line,
"EXTRA_DEFINES",
m_Makefile->GetDefineFlags());
const char* debugPostfix
= m_Makefile->GetDefinition("CMAKE_DEBUG_POSTFIX");
cmSystemTools::ReplaceString(line, "DEBUG_POSTFIX",
debugPostfix?debugPostfix:"");
debugPostfix?debugPostfix:"");
// store flags for each configuration
std::string flags = " ";
std::string flagsRelease = " ";
......
......@@ -90,7 +90,8 @@ private:
void AddUtilityCommandHack(cmTarget& target, int count,
std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines);
void WriteGroup(const cmSourceGroup *sg, cmTarget target,
std::ostream &fout, const char *libName);
std::string CreateTargetRules(cmTarget &target,
const char *libName);
std::string m_IncludeOptions;
......
This diff is collapsed.
......@@ -111,6 +111,8 @@ private:
const char* output,
const char* extraFlags);
void WriteGroup(const cmSourceGroup *sg, cmTarget target, std::ostream &fout, const char *libName, std::vector<std::string> *configs);
std::vector<std::string> m_CreatedProjectNames;
std::string m_LibraryOutputPath;
std::string m_ExecutableOutputPath;
......
This diff is collapsed.
......@@ -162,7 +162,7 @@ public:
* Add an executable to the build.
*/
cmTarget* AddExecutable(const char *exename,
const std::vector<std::string> &srcs);
const std::vector<std::string> &srcs);
/**
* Add a utility to the build. A utiltity target is a command that
......@@ -200,15 +200,15 @@ public:
*/
std::vector<std::string>& GetLinkDirectories()
{
return m_LinkDirectories;
return m_LinkDirectories;
}
const std::vector<std::string>& GetLinkDirectories() const
{
return m_LinkDirectories;
return m_LinkDirectories;
}
void SetLinkDirectories(const std::vector<std::string>& vec)
{
m_LinkDirectories = vec;
m_LinkDirectories = vec;
}
/**
......@@ -268,7 +268,7 @@ public:
*/
const char* GetProjectName()
{
return m_ProjectName.c_str();
return m_ProjectName.c_str();
}
/**
......@@ -280,7 +280,7 @@ public:
/**
* Add a source group for consideration when adding a new source.
*/
void AddSourceGroup(const char* name, const char* regex=0);
void AddSourceGroup(const char* name, const char* regex=0, const char* parent=0);
/**
* Add an auxiliary directory to the build.
......@@ -310,12 +310,12 @@ public:
void SetHomeDirectory(const char* dir);
const char* GetHomeDirectory() const
{
return m_cmHomeDirectory.c_str();
return m_cmHomeDirectory.c_str();
}
void SetHomeOutputDirectory(const char* lib);
const char* GetHomeOutputDirectory() const
{
return m_HomeOutputDirectory.c_str();
return m_HomeOutputDirectory.c_str();
}
//@}
......@@ -394,7 +394,7 @@ public:
}
const char* GetComplainRegularExpression()
{
return m_ComplainFileRegularExpression.c_str();
return m_ComplainFileRegularExpression.c_str();
}
/**
......@@ -409,15 +409,15 @@ public:
*/
std::vector<std::string>& GetIncludeDirectories()
{
return m_IncludeDirectories;
return m_IncludeDirectories;
}
const std::vector<std::string>& GetIncludeDirectories() const
{
return m_IncludeDirectories;
return m_IncludeDirectories;
}
void SetIncludeDirectories(const std::vector<std::string>& vec)
{
m_IncludeDirectories = vec;
m_IncludeDirectories = vec;
}
/** Expand out any arguements in the vector that have ; separated
......@@ -554,7 +554,7 @@ public:
* Copy file but change lines acording to ConfigureString
*/
int ConfigureFile(const char* infile, const char* outfile,
bool copyonly, bool atOnly, bool escapeQuotes);
bool copyonly, bool atOnly, bool escapeQuotes);
/**
* find what source group this source is in
......
......@@ -81,3 +81,88 @@ std::vector<const cmSourceFile*>& cmSourceGroup::GetSourceFiles()
{
return m_SourceFiles;
}
//----------------------------------------------------------------------------
void cmSourceGroup::AddChild(cmSourceGroup child)
{
m_GroupChildren.push_back(child);
}
//----------------------------------------------------------------------------
cmSourceGroup *cmSourceGroup::lookupChild(const char* name)
{
// initializing iterators
std::vector<cmSourceGroup>::iterator iter = m_GroupChildren.begin();
std::vector<cmSourceGroup>::iterator end = m_GroupChildren.end();
// st
for(;iter!=end; ++iter)
{
std::string sgName = iter->GetName();
// look if descenened is the one were looking for
if(sgName == name)
{
return &(*iter); // if it so return it
}
// if the descendend isn't the one where looking for ask it's traverse
cmSourceGroup *result = iter->lookupChild(name);
// if one of it's descendeds is the one we're looking for return it
if(result)
{
return result;
}
}
// if no child with this name was found return NULL
return NULL;
}
cmSourceGroup *cmSourceGroup::MatchChildrenFiles(const char *name)
{
// initializing iterators
std::vector<cmSourceGroup>::iterator iter = m_GroupChildren.begin();
std::vector<cmSourceGroup>::iterator end = m_GroupChildren.end();
if(this->MatchesFiles(name))
{
return this;
}
for(;iter!=end;++iter)
{
cmSourceGroup *result = iter->MatchChildrenFiles(name);
if(result)
{
return result;
}
}
return 0;
}
cmSourceGroup *cmSourceGroup::MatchChildrenRegex(const char *name)
{
// initializing iterators
std::vector<cmSourceGroup>::iterator iter = m_GroupChildren.begin();
std::vector<cmSourceGroup>::iterator end = m_GroupChildren.end();
if(this->MatchesRegex(name))
{
return this;
}
for(;iter!=end; ++iter)
{
cmSourceGroup *result = iter->MatchChildrenRegex(name);
if(result)
{
return result;
}
}
return 0;
}
std::vector<cmSourceGroup> cmSourceGroup::GetGroupChildren() const
{
return m_GroupChildren;
}
......@@ -47,6 +47,16 @@ public:
* Add a file name to the explicit list of files for this group.
*/
void AddGroupFile(const char* name);
/**
* Add child to this sourcegroup
*/
void AddChild(cmSourceGroup child);
/**
* Looks up child and returns it
*/
cmSourceGroup *lookupChild(const char *name);
/**
* Get the name of this group.
......@@ -62,6 +72,16 @@ public:
* Check if the given name matches this group's explicit file list.
*/
bool MatchesFiles(const char* name);
/**
* Check if the given name matches this group's explicit file list in children.
*/
cmSourceGroup *MatchChildrenFiles(const char *name);
/**
* Check if the given name matches this group's regex in children.
*/
cmSourceGroup *MatchChildrenRegex(const char *name);
/**
* Assign the given source file to this group. Used only by
......@@ -76,6 +96,7 @@ public:
const std::vector<const cmSourceFile*>& GetSourceFiles() const;
std::vector<const cmSourceFile*>& GetSourceFiles();
std::vector<cmSourceGroup> GetGroupChildren() const;
private:
/**
* The name of the source group.
......@@ -97,6 +118,8 @@ private:
* this group.
*/
std::vector<const cmSourceFile*> m_SourceFiles;
std::vector<cmSourceGroup> m_GroupChildren;
};
#endif