ENH: generate a sln and dsw file for each sub project in a project
This commit is contained in:
parent
945fcb581d
commit
5ccfaefb48
|
@ -156,12 +156,24 @@ cmLocalGenerator *cmGlobalVisualStudio6Generator::CreateLocalGenerator()
|
||||||
|
|
||||||
void cmGlobalVisualStudio6Generator::Generate()
|
void cmGlobalVisualStudio6Generator::Generate()
|
||||||
{
|
{
|
||||||
|
// collect sub-projects
|
||||||
|
this->CollectSubprojects();
|
||||||
|
|
||||||
// add a special target that depends on ALL projects for easy build
|
// add a special target that depends on ALL projects for easy build
|
||||||
// of Debug only
|
// of one configuration only.
|
||||||
std::vector<std::string> srcs;
|
std::vector<std::string> srcs;
|
||||||
m_LocalGenerators[0]->GetMakefile()->
|
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
|
||||||
AddUtilityCommand("ALL_BUILD", "echo","\"Build all projects\"",false,srcs);
|
for(it = m_SubProjectMap.begin(); it!= m_SubProjectMap.end(); ++it)
|
||||||
|
{
|
||||||
|
std::vector<cmLocalGenerator*>& gen = it->second;
|
||||||
|
// add the ALL_BUILD to the first local generator of each project
|
||||||
|
if(gen.size())
|
||||||
|
{
|
||||||
|
gen[0]->GetMakefile()->
|
||||||
|
AddUtilityCommand("ALL_BUILD", "echo","\"Build all projects\"",false,srcs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add the Run Tests command
|
// add the Run Tests command
|
||||||
this->SetupTests();
|
this->SetupTests();
|
||||||
|
|
||||||
|
@ -172,30 +184,177 @@ void cmGlobalVisualStudio6Generator::Generate()
|
||||||
this->OutputDSWFile();
|
this->OutputDSWFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// output the DSW file
|
// populate the m_SubProjectMap
|
||||||
void cmGlobalVisualStudio6Generator::OutputDSWFile()
|
void cmGlobalVisualStudio6Generator::CollectSubprojects()
|
||||||
{
|
{
|
||||||
// create the dsw file name
|
unsigned int i;
|
||||||
std::string fname;
|
for(i = 0; i < m_LocalGenerators.size(); ++i)
|
||||||
fname = m_CMakeInstance->GetStartOutputDirectory();
|
{
|
||||||
|
std::string name = m_LocalGenerators[i]->GetMakefile()->GetProjectName();
|
||||||
|
m_SubProjectMap[name].push_back(m_LocalGenerators[i]);
|
||||||
|
std::vector<std::string> const& pprojects
|
||||||
|
= m_LocalGenerators[i]->GetMakefile()->GetParentProjects();
|
||||||
|
for(int k =0; k < pprojects.size(); ++k)
|
||||||
|
{
|
||||||
|
m_SubProjectMap[pprojects[k]].push_back(m_LocalGenerators[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write a DSW file to the stream
|
||||||
|
void cmGlobalVisualStudio6Generator::WriteDSWFile(std::ostream& fout,
|
||||||
|
std::vector<cmLocalGenerator*>& generators)
|
||||||
|
{
|
||||||
|
// Write out the header for a DSW file
|
||||||
|
this->WriteDSWHeader(fout);
|
||||||
|
|
||||||
|
// Get the home directory with the trailing slash
|
||||||
|
std::string homedir = m_CMakeInstance->GetHomeDirectory();
|
||||||
|
homedir += "/";
|
||||||
|
|
||||||
|
unsigned int i;
|
||||||
|
bool doneAllBuild = false;
|
||||||
|
bool doneRunTests = false;
|
||||||
|
for(i = 0; i < generators.size(); ++i)
|
||||||
|
{
|
||||||
|
cmMakefile* mf = generators[i]->GetMakefile();
|
||||||
|
|
||||||
|
// Get the source directory from the makefile
|
||||||
|
std::string dir = mf->GetStartDirectory();
|
||||||
|
// remove the home directory and / from the source directory
|
||||||
|
// this gives a relative path
|
||||||
|
cmSystemTools::ReplaceString(dir, homedir.c_str(), "");
|
||||||
|
|
||||||
|
// Get the list of create dsp files names from the LocalGenerator, more
|
||||||
|
// than one dsp could have been created per input CMakeLists.txt file
|
||||||
|
// for each target
|
||||||
|
std::vector<std::string> dspnames =
|
||||||
|
static_cast<cmLocalVisualStudio6Generator *>(generators[i])
|
||||||
|
->GetCreatedProjectNames();
|
||||||
|
cmTargets &tgts = generators[i]->GetMakefile()->GetTargets();
|
||||||
|
cmTargets::iterator l = tgts.begin();
|
||||||
|
for(std::vector<std::string>::iterator si = dspnames.begin();
|
||||||
|
l != tgts.end(); ++l)
|
||||||
|
{
|
||||||
|
// special handling for the current makefile
|
||||||
|
if(mf == generators[0]->GetMakefile())
|
||||||
|
{
|
||||||
|
dir = "."; // no subdirectory for project generated
|
||||||
|
// if this is the special ALL_BUILD utility, then
|
||||||
|
// make it depend on every other non UTILITY project.
|
||||||
|
// This is done by adding the names to the GetUtilities
|
||||||
|
// vector on the makefile
|
||||||
|
if(l->first == "ALL_BUILD" && !doneAllBuild)
|
||||||
|
{
|
||||||
|
unsigned int j;
|
||||||
|
for(j = 0; j < generators.size(); ++j)
|
||||||
|
{
|
||||||
|
const cmTargets &atgts =
|
||||||
|
generators[j]->GetMakefile()->GetTargets();
|
||||||
|
for(cmTargets::const_iterator al = atgts.begin();
|
||||||
|
al != atgts.end(); ++al)
|
||||||
|
{
|
||||||
|
if (al->second.IsInAll())
|
||||||
|
{
|
||||||
|
if (al->second.GetType() == cmTarget::UTILITY)
|
||||||
|
{
|
||||||
|
l->second.AddUtility(al->first.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l->second.AddLinkLibrary(al->first, cmTarget::GENERAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Write the project into the DSW file
|
||||||
|
if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
|
||||||
|
{
|
||||||
|
cmCustomCommand cc = l->second.GetPreLinkCommands()[0];
|
||||||
|
|
||||||
|
// dodgy use of the cmCustomCommand's members to store the
|
||||||
|
// arguments from the INCLUDE_EXTERNAL_MSPROJECT command
|
||||||
|
std::vector<std::string> stuff = cc.GetDepends();
|
||||||
|
std::vector<std::string> depends;
|
||||||
|
depends.push_back(cc.GetOutput());
|
||||||
|
this->WriteExternalProject(fout, stuff[0].c_str(), stuff[1].c_str(), depends);
|
||||||
|
++si;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((l->second.GetType() != cmTarget::INSTALL_FILES)
|
||||||
|
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
|
||||||
|
{
|
||||||
|
bool skip = false;
|
||||||
|
// skip ALL_BUILD and RUN_TESTS if they have already been added
|
||||||
|
if(l->first == "ALL_BUILD" )
|
||||||
|
{
|
||||||
|
if(doneAllBuild)
|
||||||
|
{
|
||||||
|
skip = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
doneAllBuild = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(l->first == "RUN_TESTS")
|
||||||
|
{
|
||||||
|
if(doneRunTests)
|
||||||
|
{
|
||||||
|
skip = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
doneRunTests = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!skip)
|
||||||
|
{
|
||||||
|
this->WriteProject(fout, si->c_str(), dir.c_str(),l->second);
|
||||||
|
}
|
||||||
|
++si;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write the footer for the DSW file
|
||||||
|
this->WriteDSWFooter(fout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmGlobalVisualStudio6Generator::OutputDSWFile(const char* projectName,
|
||||||
|
std::vector<cmLocalGenerator*>& generators)
|
||||||
|
{
|
||||||
|
if(generators.size() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::string fname = generators[0]->GetMakefile()->GetStartOutputDirectory();
|
||||||
fname += "/";
|
fname += "/";
|
||||||
if(strlen(m_LocalGenerators[0]->GetMakefile()->GetProjectName()))
|
fname += generators[0]->GetMakefile()->GetProjectName();
|
||||||
{
|
|
||||||
fname += m_LocalGenerators[0]->GetMakefile()->GetProjectName();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fname += "Project";
|
|
||||||
}
|
|
||||||
fname += ".dsw";
|
fname += ".dsw";
|
||||||
std::ofstream fout(fname.c_str());
|
std::ofstream fout(fname.c_str());
|
||||||
if(!fout)
|
if(!fout)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error("Error can not open DSW file for write: "
|
cmSystemTools::Error("Error can not open DSW file for write: ",
|
||||||
,fname.c_str());
|
fname.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->WriteDSWFile(fout);
|
this->WriteDSWFile(fout, generators);
|
||||||
|
}
|
||||||
|
|
||||||
|
// output the DSW file
|
||||||
|
void cmGlobalVisualStudio6Generator::OutputDSWFile()
|
||||||
|
{
|
||||||
|
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
|
||||||
|
for(it = m_SubProjectMap.begin(); it!= m_SubProjectMap.end(); ++it)
|
||||||
|
{
|
||||||
|
std::vector<cmLocalGenerator*>& gen = it->second;
|
||||||
|
this->OutputDSWFile(it->first.c_str(), it->second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -249,105 +408,19 @@ void cmGlobalVisualStudio6Generator::SetupTests()
|
||||||
if (cmSystemTools::FileExists(fname.c_str()))
|
if (cmSystemTools::FileExists(fname.c_str()))
|
||||||
{
|
{
|
||||||
std::vector<std::string> srcs;
|
std::vector<std::string> srcs;
|
||||||
m_LocalGenerators[0]->GetMakefile()->
|
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
|
||||||
AddUtilityCommand("RUN_TESTS", ctest.c_str(), "-D $(IntDir)",false,srcs);
|
for(it = m_SubProjectMap.begin(); it!= m_SubProjectMap.end(); ++it)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write a DSW file to the stream
|
|
||||||
void cmGlobalVisualStudio6Generator::WriteDSWFile(std::ostream& fout)
|
|
||||||
{
|
|
||||||
// Write out the header for a DSW file
|
|
||||||
this->WriteDSWHeader(fout);
|
|
||||||
|
|
||||||
|
|
||||||
// Get the home directory with the trailing slash
|
|
||||||
std::string homedir = m_CMakeInstance->GetHomeDirectory();
|
|
||||||
homedir += "/";
|
|
||||||
|
|
||||||
unsigned int i;
|
|
||||||
for(i = 0; i < m_LocalGenerators.size(); ++i)
|
|
||||||
{
|
|
||||||
cmMakefile* mf = m_LocalGenerators[i]->GetMakefile();
|
|
||||||
|
|
||||||
// Get the source directory from the makefile
|
|
||||||
std::string dir = mf->GetStartDirectory();
|
|
||||||
// remove the home directory and / from the source directory
|
|
||||||
// this gives a relative path
|
|
||||||
cmSystemTools::ReplaceString(dir, homedir.c_str(), "");
|
|
||||||
|
|
||||||
// Get the list of create dsp files names from the LocalGenerator, more
|
|
||||||
// than one dsp could have been created per input CMakeLists.txt file
|
|
||||||
// for each target
|
|
||||||
std::vector<std::string> dspnames =
|
|
||||||
static_cast<cmLocalVisualStudio6Generator *>(m_LocalGenerators[i])
|
|
||||||
->GetCreatedProjectNames();
|
|
||||||
cmTargets &tgts = m_LocalGenerators[i]->GetMakefile()->GetTargets();
|
|
||||||
cmTargets::iterator l = tgts.begin();
|
|
||||||
for(std::vector<std::string>::iterator si = dspnames.begin();
|
|
||||||
l != tgts.end(); ++l)
|
|
||||||
{
|
|
||||||
// special handling for the current makefile
|
|
||||||
if(mf == m_LocalGenerators[0]->GetMakefile())
|
|
||||||
{
|
{
|
||||||
dir = "."; // no subdirectory for project generated
|
std::vector<cmLocalGenerator*>& gen = it->second;
|
||||||
// if this is the special ALL_BUILD utility, then
|
// add the ALL_BUILD to the first local generator of each project
|
||||||
// make it depend on every other non UTILITY project.
|
if(gen.size())
|
||||||
// This is done by adding the names to the GetUtilities
|
|
||||||
// vector on the makefile
|
|
||||||
if(l->first == "ALL_BUILD")
|
|
||||||
{
|
{
|
||||||
unsigned int j;
|
gen[0]->GetMakefile()->
|
||||||
for(j = 0; j < m_LocalGenerators.size(); ++j)
|
AddUtilityCommand("RUN_TESTS", ctest.c_str(), "-D $(IntDir)",false,srcs);
|
||||||
{
|
|
||||||
const cmTargets &atgts =
|
|
||||||
m_LocalGenerators[j]->GetMakefile()->GetTargets();
|
|
||||||
for(cmTargets::const_iterator al = atgts.begin();
|
|
||||||
al != atgts.end(); ++al)
|
|
||||||
{
|
|
||||||
if (al->second.IsInAll())
|
|
||||||
{
|
|
||||||
if (al->second.GetType() == cmTarget::UTILITY)
|
|
||||||
{
|
|
||||||
l->second.AddUtility(al->first.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
l->second.AddLinkLibrary(al->first, cmTarget::GENERAL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Write the project into the DSW file
|
|
||||||
if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
|
|
||||||
{
|
|
||||||
cmCustomCommand cc = l->second.GetPreLinkCommands()[0];
|
|
||||||
|
|
||||||
// dodgy use of the cmCustomCommand's members to store the
|
|
||||||
// arguments from the INCLUDE_EXTERNAL_MSPROJECT command
|
|
||||||
std::vector<std::string> stuff = cc.GetDepends();
|
|
||||||
std::vector<std::string> depends;
|
|
||||||
depends.push_back(cc.GetOutput());
|
|
||||||
this->WriteExternalProject(fout, stuff[0].c_str(), stuff[1].c_str(), depends);
|
|
||||||
++si;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ((l->second.GetType() != cmTarget::INSTALL_FILES)
|
|
||||||
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
|
|
||||||
{
|
|
||||||
this->WriteProject(fout, si->c_str(), dir.c_str(),l->second);
|
|
||||||
++si;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the footer for the DSW file
|
|
||||||
this->WriteDSWFooter(fout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,11 @@ public:
|
||||||
* Generate the DSW workspace file.
|
* Generate the DSW workspace file.
|
||||||
*/
|
*/
|
||||||
virtual void OutputDSWFile();
|
virtual void OutputDSWFile();
|
||||||
|
virtual void OutputDSWFile(const char* projectName, std::vector<cmLocalGenerator*>& generators);
|
||||||
|
virtual void WriteDSWFile(std::ostream& fout,
|
||||||
|
std::vector<cmLocalGenerator*>& generators);
|
||||||
private:
|
private:
|
||||||
|
void CollectSubprojects();
|
||||||
void GenerateConfigurations(cmMakefile* mf);
|
void GenerateConfigurations(cmMakefile* mf);
|
||||||
void SetupTests();
|
void SetupTests();
|
||||||
void WriteDSWFile(std::ostream& fout);
|
void WriteDSWFile(std::ostream& fout);
|
||||||
|
@ -81,6 +84,7 @@ private:
|
||||||
const char* name, const char* path,
|
const char* name, const char* path,
|
||||||
const std::vector<std::string>& dependencies);
|
const std::vector<std::string>& dependencies);
|
||||||
void WriteDSWFooter(std::ostream& fout);
|
void WriteDSWFooter(std::ostream& fout);
|
||||||
|
std::map<cmStdString, std::vector<cmLocalGenerator*> > m_SubProjectMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -157,8 +157,17 @@ void cmGlobalVisualStudio7Generator::SetupTests()
|
||||||
if (cmSystemTools::FileExists(fname.c_str()))
|
if (cmSystemTools::FileExists(fname.c_str()))
|
||||||
{
|
{
|
||||||
std::vector<std::string> srcs;
|
std::vector<std::string> srcs;
|
||||||
m_LocalGenerators[0]->GetMakefile()->
|
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
|
||||||
AddUtilityCommand("RUN_TESTS", ctest.c_str(), "-D $(IntDir)",false, srcs);
|
for(it = m_SubProjectMap.begin(); it!= m_SubProjectMap.end(); ++it)
|
||||||
|
{
|
||||||
|
std::vector<cmLocalGenerator*>& gen = it->second;
|
||||||
|
// add the ALL_BUILD to the first local generator of each project
|
||||||
|
if(gen.size())
|
||||||
|
{
|
||||||
|
gen[0]->GetMakefile()->
|
||||||
|
AddUtilityCommand("RUN_TESTS", ctest.c_str(), "-D $(IntDir)",false,srcs);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,11 +242,22 @@ void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf)
|
||||||
|
|
||||||
void cmGlobalVisualStudio7Generator::Generate()
|
void cmGlobalVisualStudio7Generator::Generate()
|
||||||
{
|
{
|
||||||
|
// collect sub-projects
|
||||||
|
this->CollectSubprojects();
|
||||||
// add a special target that depends on ALL projects for easy build
|
// add a special target that depends on ALL projects for easy build
|
||||||
// of Debug only
|
// of Debug only
|
||||||
std::vector<std::string> srcs;
|
std::vector<std::string> srcs;
|
||||||
m_LocalGenerators[0]->GetMakefile()->
|
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
|
||||||
AddUtilityCommand("ALL_BUILD", "echo","\"Build all projects\"",false, srcs);
|
for(it = m_SubProjectMap.begin(); it!= m_SubProjectMap.end(); ++it)
|
||||||
|
{
|
||||||
|
std::vector<cmLocalGenerator*>& gen = it->second;
|
||||||
|
// add the ALL_BUILD to the first local generator of each project
|
||||||
|
if(gen.size())
|
||||||
|
{
|
||||||
|
gen[0]->GetMakefile()->
|
||||||
|
AddUtilityCommand("ALL_BUILD", "echo","\"Build all projects\"",false,srcs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add the Run Tests command
|
// add the Run Tests command
|
||||||
this->SetupTests();
|
this->SetupTests();
|
||||||
|
@ -249,42 +269,42 @@ void cmGlobalVisualStudio7Generator::Generate()
|
||||||
this->OutputSLNFile();
|
this->OutputSLNFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// output the SLN file
|
void cmGlobalVisualStudio7Generator::OutputSLNFile(const char* projectName,
|
||||||
void cmGlobalVisualStudio7Generator::OutputSLNFile()
|
std::vector<cmLocalGenerator*>& generators)
|
||||||
{
|
{
|
||||||
// if this is an out of source build, create the output directory
|
if(generators.size() == 0)
|
||||||
if(strcmp(m_CMakeInstance->GetStartOutputDirectory(),
|
|
||||||
m_CMakeInstance->GetHomeDirectory()) != 0)
|
|
||||||
{
|
{
|
||||||
if(!cmSystemTools::MakeDirectory(m_CMakeInstance->GetStartOutputDirectory()))
|
return;
|
||||||
{
|
|
||||||
cmSystemTools::Error("Error creating output directory for SLN file",
|
|
||||||
m_CMakeInstance->GetStartOutputDirectory());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// create the dsw file name
|
std::string fname = generators[0]->GetMakefile()->GetStartOutputDirectory();
|
||||||
std::string fname;
|
|
||||||
fname = m_CMakeInstance->GetStartOutputDirectory();
|
|
||||||
fname += "/";
|
fname += "/";
|
||||||
if(strlen(m_LocalGenerators[0]->GetMakefile()->GetProjectName()) == 0)
|
fname += generators[0]->GetMakefile()->GetProjectName();
|
||||||
{
|
|
||||||
m_LocalGenerators[0]->GetMakefile()->SetProjectName("Project");
|
|
||||||
}
|
|
||||||
fname += m_LocalGenerators[0]->GetMakefile()->GetProjectName();
|
|
||||||
fname += ".sln";
|
fname += ".sln";
|
||||||
std::ofstream fout(fname.c_str());
|
std::ofstream fout(fname.c_str());
|
||||||
if(!fout)
|
if(!fout)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error("Error can not open SLN file for write: "
|
cmSystemTools::Error("Error can not open DSW file for write: ",
|
||||||
,fname.c_str());
|
fname.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->WriteSLNFile(fout);
|
this->WriteSLNFile(fout, generators);
|
||||||
|
}
|
||||||
|
|
||||||
|
// output the SLN file
|
||||||
|
void cmGlobalVisualStudio7Generator::OutputSLNFile()
|
||||||
|
{
|
||||||
|
std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
|
||||||
|
for(it = m_SubProjectMap.begin(); it!= m_SubProjectMap.end(); ++it)
|
||||||
|
{
|
||||||
|
std::vector<cmLocalGenerator*>& gen = it->second;
|
||||||
|
this->OutputSLNFile(it->first.c_str(), it->second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Write a SLN file to the stream
|
// Write a SLN file to the stream
|
||||||
void cmGlobalVisualStudio7Generator::WriteSLNFile(std::ostream& fout)
|
void cmGlobalVisualStudio7Generator::WriteSLNFile(std::ostream& fout,
|
||||||
|
std::vector<cmLocalGenerator*>& generators)
|
||||||
{
|
{
|
||||||
// Write out the header for a SLN file
|
// Write out the header for a SLN file
|
||||||
this->WriteSLNHeader(fout);
|
this->WriteSLNHeader(fout);
|
||||||
|
@ -292,13 +312,15 @@ void cmGlobalVisualStudio7Generator::WriteSLNFile(std::ostream& fout)
|
||||||
// Get the home directory with the trailing slash
|
// Get the home directory with the trailing slash
|
||||||
std::string homedir = m_CMakeInstance->GetHomeDirectory();
|
std::string homedir = m_CMakeInstance->GetHomeDirectory();
|
||||||
homedir += "/";
|
homedir += "/";
|
||||||
|
bool doneAllBuild = false;
|
||||||
|
bool doneRunTests = false;
|
||||||
|
|
||||||
// For each cmMakefile, create a VCProj for it, and
|
// For each cmMakefile, create a VCProj for it, and
|
||||||
// add it to this SLN file
|
// add it to this SLN file
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for(i = 0; i < m_LocalGenerators.size(); ++i)
|
for(i = 0; i < generators.size(); ++i)
|
||||||
{
|
{
|
||||||
cmMakefile* mf = m_LocalGenerators[i]->GetMakefile();
|
cmMakefile* mf = generators[i]->GetMakefile();
|
||||||
|
|
||||||
// Get the source directory from the makefile
|
// Get the source directory from the makefile
|
||||||
std::string dir = mf->GetStartDirectory();
|
std::string dir = mf->GetStartDirectory();
|
||||||
|
@ -310,28 +332,28 @@ void cmGlobalVisualStudio7Generator::WriteSLNFile(std::ostream& fout)
|
||||||
// than one dsp could have been created per input CMakeLists.txt file
|
// than one dsp could have been created per input CMakeLists.txt file
|
||||||
// for each target
|
// for each target
|
||||||
std::vector<std::string> dspnames =
|
std::vector<std::string> dspnames =
|
||||||
static_cast<cmLocalVisualStudio7Generator *>(m_LocalGenerators[i])
|
static_cast<cmLocalVisualStudio7Generator *>(generators[i])
|
||||||
->GetCreatedProjectNames();
|
->GetCreatedProjectNames();
|
||||||
cmTargets &tgts = m_LocalGenerators[i]->GetMakefile()->GetTargets();
|
cmTargets &tgts = generators[i]->GetMakefile()->GetTargets();
|
||||||
cmTargets::iterator l = tgts.begin();
|
cmTargets::iterator l = tgts.begin();
|
||||||
for(std::vector<std::string>::iterator si = dspnames.begin();
|
for(std::vector<std::string>::iterator si = dspnames.begin();
|
||||||
l != tgts.end(); ++l)
|
l != tgts.end(); ++l)
|
||||||
{
|
{
|
||||||
// special handling for the current makefile
|
// special handling for the current makefile
|
||||||
if(mf == m_LocalGenerators[0]->GetMakefile())
|
if(mf == generators[0]->GetMakefile())
|
||||||
{
|
{
|
||||||
dir = "."; // no subdirectory for project generated
|
dir = "."; // no subdirectory for project generated
|
||||||
// if this is the special ALL_BUILD utility, then
|
// if this is the special ALL_BUILD utility, then
|
||||||
// make it depend on every other non UTILITY project.
|
// make it depend on every other non UTILITY project.
|
||||||
// This is done by adding the names to the GetUtilities
|
// This is done by adding the names to the GetUtilities
|
||||||
// vector on the makefile
|
// vector on the makefile
|
||||||
if(l->first == "ALL_BUILD")
|
if(l->first == "ALL_BUILD" && !doneAllBuild)
|
||||||
{
|
{
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
for(j = 0; j < m_LocalGenerators.size(); ++j)
|
for(j = 0; j < generators.size(); ++j)
|
||||||
{
|
{
|
||||||
const cmTargets &atgts =
|
const cmTargets &atgts =
|
||||||
m_LocalGenerators[j]->GetMakefile()->GetTargets();
|
generators[j]->GetMakefile()->GetTargets();
|
||||||
for(cmTargets::const_iterator al = atgts.begin();
|
for(cmTargets::const_iterator al = atgts.begin();
|
||||||
al != atgts.end(); ++al)
|
al != atgts.end(); ++al)
|
||||||
{
|
{
|
||||||
|
@ -369,7 +391,33 @@ void cmGlobalVisualStudio7Generator::WriteSLNFile(std::ostream& fout)
|
||||||
if ((l->second.GetType() != cmTarget::INSTALL_FILES)
|
if ((l->second.GetType() != cmTarget::INSTALL_FILES)
|
||||||
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
|
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
|
||||||
{
|
{
|
||||||
this->WriteProject(fout, si->c_str(), dir.c_str(),l->second);
|
bool skip = false;
|
||||||
|
if(l->first == "ALL_BUILD" )
|
||||||
|
{
|
||||||
|
if(doneAllBuild)
|
||||||
|
{
|
||||||
|
skip = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
doneAllBuild = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(l->first == "RUN_TESTS")
|
||||||
|
{
|
||||||
|
if(doneRunTests)
|
||||||
|
{
|
||||||
|
skip = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
doneRunTests = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!skip)
|
||||||
|
{
|
||||||
|
this->WriteProject(fout, si->c_str(), dir.c_str(),l->second);
|
||||||
|
}
|
||||||
++si;
|
++si;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -389,11 +437,11 @@ void cmGlobalVisualStudio7Generator::WriteSLNFile(std::ostream& fout)
|
||||||
<< "\tGlobalSection(ProjectDependencies) = postSolution\n";
|
<< "\tGlobalSection(ProjectDependencies) = postSolution\n";
|
||||||
|
|
||||||
// loop over again and compute the depends
|
// loop over again and compute the depends
|
||||||
for(i = 0; i < m_LocalGenerators.size(); ++i)
|
for(i = 0; i < generators.size(); ++i)
|
||||||
{
|
{
|
||||||
cmMakefile* mf = m_LocalGenerators[i]->GetMakefile();
|
cmMakefile* mf = generators[i]->GetMakefile();
|
||||||
cmLocalVisualStudio7Generator* pg =
|
cmLocalVisualStudio7Generator* pg =
|
||||||
static_cast<cmLocalVisualStudio7Generator*>(m_LocalGenerators[i]);
|
static_cast<cmLocalVisualStudio7Generator*>(generators[i]);
|
||||||
// Get the list of create dsp files names from the cmVCProjWriter, more
|
// Get the list of create dsp files names from the cmVCProjWriter, more
|
||||||
// than one dsp could have been created per input CMakeLists.txt file
|
// than one dsp could have been created per input CMakeLists.txt file
|
||||||
// for each target
|
// for each target
|
||||||
|
@ -416,11 +464,11 @@ void cmGlobalVisualStudio7Generator::WriteSLNFile(std::ostream& fout)
|
||||||
fout << "\tEndGlobalSection\n";
|
fout << "\tEndGlobalSection\n";
|
||||||
fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n";
|
fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n";
|
||||||
// loop over again and compute the depends
|
// loop over again and compute the depends
|
||||||
for(i = 0; i < m_LocalGenerators.size(); ++i)
|
for(i = 0; i < generators.size(); ++i)
|
||||||
{
|
{
|
||||||
cmMakefile* mf = m_LocalGenerators[i]->GetMakefile();
|
cmMakefile* mf = generators[i]->GetMakefile();
|
||||||
cmLocalVisualStudio7Generator* pg =
|
cmLocalVisualStudio7Generator* pg =
|
||||||
static_cast<cmLocalVisualStudio7Generator*>(m_LocalGenerators[i]);
|
static_cast<cmLocalVisualStudio7Generator*>(generators[i]);
|
||||||
// Get the list of create dsp files names from the cmVCProjWriter, more
|
// Get the list of create dsp files names from the cmVCProjWriter, more
|
||||||
// than one dsp could have been created per input CMakeLists.txt file
|
// than one dsp could have been created per input CMakeLists.txt file
|
||||||
// for each target
|
// for each target
|
||||||
|
@ -603,3 +651,20 @@ void cmGlobalVisualStudio7Generator::GetDocumentation(cmDocumentationEntry& entr
|
||||||
entry.brief = "Generates Visual Studio .NET 2002 project files.";
|
entry.brief = "Generates Visual Studio .NET 2002 project files.";
|
||||||
entry.full = "";
|
entry.full = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// populate the m_SubProjectMap
|
||||||
|
void cmGlobalVisualStudio7Generator::CollectSubprojects()
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
for(i = 0; i < m_LocalGenerators.size(); ++i)
|
||||||
|
{
|
||||||
|
std::string name = m_LocalGenerators[i]->GetMakefile()->GetProjectName();
|
||||||
|
m_SubProjectMap[name].push_back(m_LocalGenerators[i]);
|
||||||
|
std::vector<std::string> const& pprojects
|
||||||
|
= m_LocalGenerators[i]->GetMakefile()->GetParentProjects();
|
||||||
|
for(int k =0; k < pprojects.size(); ++k)
|
||||||
|
{
|
||||||
|
m_SubProjectMap[pprojects[k]].push_back(m_LocalGenerators[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -82,7 +82,10 @@ public:
|
||||||
std::vector<std::string> *GetConfigurations();
|
std::vector<std::string> *GetConfigurations();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void WriteSLNFile(std::ostream& fout);
|
void CollectSubprojects();
|
||||||
|
void OutputSLNFile(const char* projectName,
|
||||||
|
std::vector<cmLocalGenerator*>& generators);
|
||||||
|
virtual void WriteSLNFile(std::ostream& fout, std::vector<cmLocalGenerator*>& generators);
|
||||||
virtual void WriteProject(std::ostream& fout,
|
virtual void WriteProject(std::ostream& fout,
|
||||||
const char* name, const char* path,
|
const char* name, const char* path,
|
||||||
const cmTarget &t);
|
const cmTarget &t);
|
||||||
|
@ -103,6 +106,7 @@ protected:
|
||||||
|
|
||||||
std::vector<std::string> m_Configurations;
|
std::vector<std::string> m_Configurations;
|
||||||
std::map<cmStdString, cmStdString> m_GUIDMap;
|
std::map<cmStdString, cmStdString> m_GUIDMap;
|
||||||
|
std::map<cmStdString, std::vector<cmLocalGenerator*> > m_SubProjectMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -954,6 +954,10 @@ void cmMakefile::RemoveDefinition(const char* name)
|
||||||
|
|
||||||
void cmMakefile::SetProjectName(const char* p)
|
void cmMakefile::SetProjectName(const char* p)
|
||||||
{
|
{
|
||||||
|
if(m_ProjectName.size())
|
||||||
|
{
|
||||||
|
m_ParentProjects.push_back(m_ProjectName);
|
||||||
|
}
|
||||||
m_ProjectName = p;
|
m_ProjectName = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -252,6 +252,10 @@ public:
|
||||||
return m_ProjectName.c_str();
|
return m_ProjectName.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> const& GetParentProjects()
|
||||||
|
{
|
||||||
|
return m_ParentProjects;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Set the name of the library.
|
* Set the name of the library.
|
||||||
*/
|
*/
|
||||||
|
@ -630,6 +634,7 @@ protected:
|
||||||
std::string m_cmCurrentListFile;
|
std::string m_cmCurrentListFile;
|
||||||
|
|
||||||
std::string m_ProjectName; // project name
|
std::string m_ProjectName; // project name
|
||||||
|
std::vector<std::string> m_ParentProjects;
|
||||||
|
|
||||||
// libraries, classes, and executables
|
// libraries, classes, and executables
|
||||||
cmTargets m_Targets;
|
cmTargets m_Targets;
|
||||||
|
|
Loading…
Reference in New Issue