summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalVisualStudio7Generator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmLocalVisualStudio7Generator.cxx')
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx79
1 files changed, 76 insertions, 3 deletions
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 6a0ab0d..bb969aa 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -92,8 +92,82 @@ void cmLocalVisualStudio7Generator::OutputVCProjFile()
// clear project names
m_CreatedProjectNames.clear();
- // build any targets
- cmTargets &tgts = m_Makefile->GetTargets();
+ // Call TraceVSDependencies on all targets
+ cmTargets &tgts = m_Makefile->GetTargets();
+ for(cmTargets::iterator l = tgts.begin();
+ l != tgts.end(); l++)
+ {
+ // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
+ // so don't build a projectfile for it
+ if ((l->second.GetType() != cmTarget::INSTALL_FILES)
+ && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)
+ && (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0))
+ {
+ cmTarget& target = l->second;
+ target.TraceVSDependencies(target.GetName(), m_Makefile);
+ }
+ }
+ // now for all custom commands that are not used directly in a
+ // target, add them to all targets in the current directory or
+ // makefile
+ std::vector<cmSourceFile*> & classesmf = m_Makefile->GetSourceFiles();
+ for(std::vector<cmSourceFile*>::const_iterator i = classesmf.begin();
+ i != classesmf.end(); i++)
+ {
+ if(cmCustomCommand* cc = (*i)->GetCustomCommand())
+ {
+ // while we are at it, if it is a .rule file then for visual studio 7 we
+ // must generate it so that depend information works correctly
+ if ((*i)->GetSourceExtension() == "rule")
+ {
+ std::string source = (*i)->GetFullPath();
+ if(!cmSystemTools::FileExists(source.c_str()))
+ {
+ cmSystemTools::ReplaceString(source, "$(IntDir)/", "");
+#if defined(_WIN32) || defined(__CYGWIN__)
+ std::ofstream fout(source.c_str(),
+ std::ios::binary | std::ios::out | std::ios::trunc);
+#else
+ std::ofstream fout(source.c_str(),
+ std::ios::out | std::ios::trunc);
+#endif
+ if(fout)
+ {
+ fout.write("# generated from CMake",22);
+ fout.flush();
+ fout.close();
+ }
+ }
+ }
+ if(!cc->IsUsed())
+ {
+ for(cmTargets::iterator l = tgts.begin();
+ l != tgts.end(); l++)
+ {
+ if ((l->second.GetType() != cmTarget::INSTALL_FILES)
+ && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)
+ && (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0))
+ {
+ cmTarget& target = l->second;
+ bool sameAsTarget = false;
+ // make sure we don't add a custom command that depends on
+ // this target
+ for(unsigned int k =0; k < cc->GetDepends().size(); k++)
+ {
+ if(cmSystemTools::GetFilenameName(cc->GetDepends()[k]) == target.GetFullName())
+ {
+ sameAsTarget = true;
+ }
+ }
+ if(!sameAsTarget)
+ {
+ target.GetSourceFiles().push_back(*i);
+ }
+ }
+ }
+ }
+ }
+ }
for(cmTargets::iterator l = tgts.begin();
l != tgts.end(); l++)
{
@@ -968,7 +1042,6 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
// trace the visual studio dependencies
std::string name = libName;
name += ".vcproj.cmake";
- target.TraceVSDependencies(name, m_Makefile);
// We may be modifying the source groups temporarily, so make a copy.
std::vector<cmSourceGroup> sourceGroups = m_Makefile->GetSourceGroups();