BUG: make sure global generate is done when cmakelist file chagnes, also make sure guids are stored in the cache so the .sln file does not change every time

This commit is contained in:
Bill Hoffman 2004-05-20 16:29:09 -04:00
parent 44803a00c5
commit 70eaddbf8e
7 changed files with 69 additions and 38 deletions

View File

@ -18,6 +18,7 @@
#define cmGeneratedFileStream_h
#include "cmStandardIncludes.h"
#include "cmSystemTools.h"
/** \class cmGeneratedFileStream
* \brief Output stream for generated files that does copy-if-different.

View File

@ -231,7 +231,7 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
<< dspname << "\", \""
<< d << "\\" << dspname << ".vcproj\", \"{"
<< this->CreateGUID(dspname) << "}\"\n";
<< this->GetGUID(dspname) << "}\"\n";
fout << "\tProjectSection(ProjectDependencies) = postProject\n";
this->WriteProjectDepends(fout, dspname, dir, t);
fout << "\tEndProjectSection\n";
@ -266,8 +266,8 @@ void cmGlobalVisualStudio71Generator::WriteProjectDepends(std::ostream& fout,
= m_CMakeInstance->GetCacheDefinition(libPath.c_str());
if(cacheValue && *cacheValue)
{
fout << "\t\t{" << this->CreateGUID(j->first.c_str()) << "} = {"
<< this->CreateGUID(j->first.c_str()) << "}\n";
fout << "\t\t{" << this->GetGUID(j->first.c_str()) << "} = {"
<< this->GetGUID(j->first.c_str()) << "}\n";
}
}
}
@ -281,8 +281,8 @@ void cmGlobalVisualStudio71Generator::WriteProjectDepends(std::ostream& fout,
{
if(*i != dspname)
{
fout << "\t\t{" << this->CreateGUID(i->c_str()) << "} = {"
<< this->CreateGUID(i->c_str()) << "}\n";
fout << "\t\t{" << this->GetGUID(i->c_str()) << "} = {"
<< this->GetGUID(i->c_str()) << "}\n";
}
}
}
@ -296,7 +296,7 @@ cmGlobalVisualStudio71Generator::WriteProjectConfigurations(std::ostream& fout,
const char* name,
bool in_all_build)
{
std::string guid = this->CreateGUID(name);
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = m_Configurations.begin();
i != m_Configurations.end(); ++i)
{

View File

@ -16,6 +16,7 @@
=========================================================================*/
#include "cmGlobalVisualStudio7Generator.h"
#include "cmLocalVisualStudio7Generator.h"
#include "cmGeneratedFileStream.h"
#include "cmMakefile.h"
#include "cmake.h"
#include "windows.h"
@ -285,14 +286,14 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile(cmLocalGenerator* root,
fname += "/";
fname += root->GetMakefile()->GetProjectName();
fname += ".sln";
std::ofstream fout(fname.c_str());
cmGeneratedFileStream fout(fname.c_str());
if(!fout)
{
cmSystemTools::Error("Error can not open DSW file for write: ",
fname.c_str());
return;
}
this->WriteSLNFile(fout, root, generators);
this->WriteSLNFile(fout.GetStream(), root, generators);
}
// output the SLN file
@ -528,7 +529,7 @@ void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout,
fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
<< dspname << "\", \""
<< d << "\\" << dspname << ".vcproj\", \"{"
<< this->CreateGUID(dspname) << "}\"\nEndProject\n";
<< this->GetGUID(dspname) << "}\"\nEndProject\n";
}
@ -559,8 +560,8 @@ void cmGlobalVisualStudio7Generator::WriteProjectDepends(std::ostream& fout,
= m_CMakeInstance->GetCacheDefinition(libPath.c_str());
if(cacheValue && *cacheValue)
{
fout << "\t\t{" << this->CreateGUID(dspname) << "}." << depcount << " = {"
<< this->CreateGUID(j->first.c_str()) << "}\n";
fout << "\t\t{" << this->GetGUID(dspname) << "}." << depcount << " = {"
<< this->GetGUID(j->first.c_str()) << "}\n";
depcount++;
}
}
@ -575,8 +576,8 @@ void cmGlobalVisualStudio7Generator::WriteProjectDepends(std::ostream& fout,
{
if(*i != dspname)
{
fout << "\t\t{" << this->CreateGUID(dspname) << "}." << depcount << " = {"
<< this->CreateGUID(i->c_str()) << "}\n";
fout << "\t\t{" << this->GetGUID(dspname) << "}." << depcount << " = {"
<< this->GetGUID(i->c_str()) << "}\n";
depcount++;
}
}
@ -591,7 +592,7 @@ cmGlobalVisualStudio7Generator::WriteProjectConfigurations(std::ostream& fout,
const char* name,
bool in_all_build)
{
std::string guid = this->CreateGUID(name);
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = m_Configurations.begin();
i != m_Configurations.end(); ++i)
{
@ -617,7 +618,7 @@ void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout,
fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
<< name << "\", \""
<< d << "\", \"{"
<< this->CreateGUID(name) << "}\"\nEndProject\n";
<< this->GetGUID(name) << "}\"\nEndProject\n";
}
@ -639,13 +640,28 @@ void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout)
fout << "Microsoft Visual Studio Solution File, Format Version 7.00\n";
}
std::string cmGlobalVisualStudio7Generator::CreateGUID(const char* name)
std::string cmGlobalVisualStudio7Generator::GetGUID(const char* name)
{
std::map<cmStdString, cmStdString>::iterator i = m_GUIDMap.find(name);
if(i != m_GUIDMap.end())
std::string guidStoreName = name;
guidStoreName += "_GUID_CMAKE";
const char* storedGUID = m_CMakeInstance->GetCacheDefinition(guidStoreName.c_str());
if(storedGUID)
{
return i->second;
return std::string(storedGUID);
}
cmSystemTools::Error("Internal CMake Error, Could not find GUID for target: ",
name);
return guidStoreName;
}
void cmGlobalVisualStudio7Generator::CreateGUID(const char* name)
{
std::string guidStoreName = name;
guidStoreName += "_GUID_CMAKE";
if(m_CMakeInstance->GetCacheDefinition(guidStoreName.c_str()))
{
return;
}
std::string ret;
UUID uid;
@ -655,8 +671,8 @@ std::string cmGlobalVisualStudio7Generator::CreateGUID(const char* name)
ret = reinterpret_cast<char*>(uidstr);
RpcStringFree(&uidstr);
ret = cmSystemTools::UpperCase(ret);
m_GUIDMap[name] = ret;
return ret;
m_CMakeInstance->AddCacheEntry(guidStoreName.c_str(), ret.c_str(), "Stored GUID",
cmCacheManager::INTERNAL);
}
void cmGlobalVisualStudio7Generator::LocalGenerate()
@ -693,3 +709,12 @@ void cmGlobalVisualStudio7Generator::CollectSubprojects()
}
}
}
// make sure "special" targets have GUID's
void cmGlobalVisualStudio7Generator::Configure()
{
cmGlobalGenerator::Configure();
this->CreateGUID("ALL_BUILD");
this->CreateGUID("INSTALL");
this->CreateGUID("RUN_TESTS");
}

View File

@ -80,8 +80,14 @@ public:
* Get the list of configurations
*/
std::vector<std::string> *GetConfigurations();
///! Create a GUID
void CreateGUID(const char* name);
///! do configure step
virtual void Configure();
protected:
std::string GetGUID(const char* name);
void CollectSubprojects();
virtual void OutputSLNFile(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
@ -103,7 +109,6 @@ protected:
void WriteExternalProject(std::ostream& fout,
const char* name, const char* path,
const std::vector<std::string>& dependencies);
std::string CreateGUID(const char* name);
std::vector<std::string> m_Configurations;
std::map<cmStdString, cmStdString> m_GUIDMap;

View File

@ -178,11 +178,6 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule()
args +=
this->ConvertToRelativeOutputPath(m_Makefile->GetHomeDirectory());
argv.push_back(args);
args = "-S";
args +=
this->ConvertToRelativeOutputPath(m_Makefile->GetStartDirectory());
argv.push_back(args);
args = "-O";
args +=
this->ConvertToRelativeOutputPath(m_Makefile->GetStartOutputDirectory());
argv.push_back(args);

View File

@ -151,14 +151,6 @@ void cmLocalVisualStudio7Generator::AddVCProjBuildRule()
args +=
this->ConvertToRelativeOutputPath(m_Makefile->GetHomeDirectory());
argv.push_back(args);
args = "-S";
args +=
this->ConvertToRelativeOutputPath(m_Makefile->GetStartDirectory());
argv.push_back(args);
args = "-O";
args +=
this->ConvertToRelativeOutputPath(m_Makefile->GetStartOutputDirectory());
argv.push_back(args);
args = "-B";
args +=
this->ConvertToRelativeOutputPath(m_Makefile->GetHomeOutputDirectory());
@ -1237,4 +1229,17 @@ std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPathSingle(const ch
return ret;
}
void cmLocalVisualStudio7Generator::ConfigureFinalPass()
{
cmLocalGenerator::ConfigureFinalPass();
cmTargets &tgts = m_Makefile->GetTargets();
cmGlobalVisualStudio7Generator* gg =
static_cast<cmGlobalVisualStudio7Generator *>(m_GlobalGenerator);
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
{
gg->CreateGUID(l->first.c_str());
}
}

View File

@ -64,7 +64,7 @@ public:
return m_CreatedProjectNames;
}
void SetVersion71() {m_Version71 = true;}
virtual void ConfigureFinalPass();
private:
void OutputVCProjFile();
void WriteVCProjHeader(std::ostream& fout, const char *libName,