1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #include "cmLocalVisualStudio10Generator.h"
14 #include "cmMakefile.h"
15 #include "cmVisualStudio10TargetGenerator.h"
16 #include "cmGlobalVisualStudio10Generator.h"
18 #include "cmXMLParser.h"
19 class cmVS10XMLParser : public cmXMLParser
22 virtual void EndElement(const char* /* name */)
25 virtual void CharacterDataHandler(const char* data, int length)
29 this->GUID.assign(data+1, length-2);
33 virtual void StartElement(const char* name, const char**)
35 // once the GUID is found do nothing
40 if(strcmp("ProjectGUID", name) == 0 || strcmp("ProjectGuid", name) == 0)
45 int InitializeParser()
48 int ret = cmXMLParser::InitializeParser();
53 // visual studio projects have a strange encoding, but it is
55 XML_SetEncoding(static_cast<XML_Parser>(this->Parser), "utf-8");
63 //----------------------------------------------------------------------------
64 cmLocalVisualStudio10Generator::cmLocalVisualStudio10Generator(VSVersion v):
65 cmLocalVisualStudio7Generator(v)
69 cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator()
73 void cmLocalVisualStudio10Generator::Generate()
76 cmTargets &tgts = this->Makefile->GetTargets();
77 for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l)
79 if(static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
80 ->TargetIsFortranOnly(l->second))
82 this->CreateSingleVCProj(l->first.c_str(),l->second);
86 cmVisualStudio10TargetGenerator tg(
87 &l->second, static_cast<cmGlobalVisualStudio10Generator*>(
88 this->GetGlobalGenerator()));
92 this->WriteStampFiles();
96 void cmLocalVisualStudio10Generator
97 ::ReadAndStoreExternalGUID(const char* name,
100 cmVS10XMLParser parser;
101 parser.ParseFile(path);
103 // if we can not find a GUID then create one
104 if(parser.GUID.empty())
106 this->GlobalGenerator->CreateGUID(name);
110 std::string guidStoreName = name;
111 guidStoreName += "_GUID_CMAKE";
112 // save the GUID in the cache
113 this->GlobalGenerator->GetCMakeInstance()->
114 AddCacheEntry(guidStoreName.c_str(),
117 cmCacheManager::INTERNAL);
120 //----------------------------------------------------------------------------
121 const char* cmLocalVisualStudio10Generator::ReportErrorLabel() const