summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalVisualStudio7Generator.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2007-01-31 18:34:18 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2007-01-31 18:34:18 (GMT)
commit345df44dc5dc5b17f340d45c11eac76f5b5d4501 (patch)
tree8f7f74449568d96b5eb011b8930260827995b1b7 /Source/cmLocalVisualStudio7Generator.cxx
parentc6c4e3aa60547d9f45ff1fb04907419e2414ddb9 (diff)
downloadCMake-345df44dc5dc5b17f340d45c11eac76f5b5d4501.zip
CMake-345df44dc5dc5b17f340d45c11eac76f5b5d4501.tar.gz
CMake-345df44dc5dc5b17f340d45c11eac76f5b5d4501.tar.bz2
BUG: make sure external vs projects use the GUID in the project if it has one.
Diffstat (limited to 'Source/cmLocalVisualStudio7Generator.cxx')
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx82
1 files changed, 81 insertions, 1 deletions
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 95bd539..2efeb9c 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -16,6 +16,8 @@
=========================================================================*/
#include "cmGlobalVisualStudio7Generator.h"
#include "cmLocalVisualStudio7Generator.h"
+#include "cmXMLParser.h"
+#include <cm_expat.h>
#include "cmMakefile.h"
#include "cmSystemTools.h"
#include "cmSourceFile.h"
@@ -1637,6 +1639,84 @@ std::string cmLocalVisualStudio7Generator
return ret;
}
+
+// This class is used to parse an existing vs 7 project
+// and extract the GUID
+class cmVS7XMLParser : public cmXMLParser
+{
+public:
+ virtual void EndElement(const char* name)
+ {
+ }
+ virtual void StartElement(const char* name, const char** atts)
+ {
+ // once the GUID is found do nothing
+ if(this->GUID.size())
+ {
+ return;
+ }
+ int i =0;
+ if(strcmp("VisualStudioProject", name) == 0)
+ {
+ while(atts[i])
+ {
+ if(strcmp(atts[i], "ProjectGUID") == 0)
+ {
+ if(atts[i+1])
+ {
+ this->GUID = atts[i+1];
+ this->GUID = this->GUID.substr(1, this->GUID.size()-2);
+ }
+ else
+ {
+ this->GUID = "";
+ }
+ return;
+ }
+ ++i;
+ }
+ }
+ }
+ int InitializeParser()
+ {
+ int ret = cmXMLParser::InitializeParser();
+ if(ret == 0)
+ {
+ return ret;
+ }
+ // visual studio projects have a strange encoding, but it is
+ // really utf-8
+ XML_SetEncoding(static_cast<XML_Parser>(this->Parser), "utf-8");
+ return 1;
+ }
+ std::string GUID;
+};
+
+void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID(
+ const char* name,
+ const char* path)
+{
+ cmVS7XMLParser parser;
+ parser.ParseFile(path);
+ // if we can not find a GUID then create one
+ if(parser.GUID.size() == 0)
+ {
+ cmGlobalVisualStudio7Generator* gg =
+ static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
+ gg->CreateGUID(name);
+ return;
+ }
+ std::string guidStoreName = name;
+ guidStoreName += "_GUID_CMAKE";
+ // save the GUID in the cache
+ this->GlobalGenerator->GetCMakeInstance()->
+ AddCacheEntry(guidStoreName.c_str(),
+ parser.GUID.c_str(),
+ "Stored GUID",
+ cmCacheManager::INTERNAL);
+}
+
+
void cmLocalVisualStudio7Generator::ConfigureFinalPass()
{
cmLocalGenerator::ConfigureFinalPass();
@@ -1651,7 +1731,7 @@ void cmLocalVisualStudio7Generator::ConfigureFinalPass()
cmCustomCommand cc = l->second.GetPostBuildCommands()[0];
const cmCustomCommandLines& cmds = cc.GetCommandLines();
std::string project_name = cmds[0][0];
- gg->CreateGUID(project_name.c_str());
+ this->ReadAndStoreExternalGUID(project_name.c_str(), cmds[0][1].c_str());
}
else
{