Fix Xcode project references to the source tree
[cmake.git] / Source / cmLocalVisualStudio10Generator.cxx
blob1469f1f3e3c32125d5aa6857017ca124312b841a
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmLocalVisualStudio10Generator.cxx,v $
5 Language: C++
6 Date: $Date: 2009-09-07 14:11:11 $
7 Version: $Revision: 1.5 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmLocalVisualStudio10Generator.h"
18 #include "cmTarget.h"
19 #include "cmMakefile.h"
20 #include "cmVisualStudio10TargetGenerator.h"
21 #include "cmGlobalVisualStudio7Generator.h"
22 #include <cm_expat.h>
23 #include "cmXMLParser.h"
24 class cmVS10XMLParser : public cmXMLParser
26 public:
27 virtual void EndElement(const char* /* name */)
30 virtual void CharacterDataHandler(const char* data, int length)
32 if(this->DoGUID )
34 this->GUID.assign(data+1, length-2);
35 this->DoGUID = false;
38 virtual void StartElement(const char* name, const char**)
40 // once the GUID is found do nothing
41 if(this->GUID.size())
43 return;
45 if(strcmp("ProjectGUID", name) == 0)
47 this->DoGUID = true;
50 int InitializeParser()
52 this->DoGUID = false;
53 int ret = cmXMLParser::InitializeParser();
54 if(ret == 0)
56 return ret;
58 // visual studio projects have a strange encoding, but it is
59 // really utf-8
60 XML_SetEncoding(static_cast<XML_Parser>(this->Parser), "utf-8");
61 return 1;
63 std::string GUID;
64 bool DoGUID;
68 //----------------------------------------------------------------------------
69 cmLocalVisualStudio10Generator::cmLocalVisualStudio10Generator()
73 cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator()
77 void cmLocalVisualStudio10Generator::Generate()
80 cmTargets &tgts = this->Makefile->GetTargets();
81 // Create the regeneration custom rule.
82 if(!this->Makefile->IsOn("CMAKE_SUPPRESS_REGENERATION"))
84 // Create a rule to regenerate the build system when the target
85 // specification source changes.
86 if(cmSourceFile* sf = this->CreateVCProjBuildRule())
88 // Add the rule to targets that need it.
89 for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l)
91 if(l->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET)
93 l->second.AddSourceFile(sf);
99 for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l)
101 cmVisualStudio10TargetGenerator tg(&l->second,
102 (cmGlobalVisualStudio7Generator*)
103 this->GetGlobalGenerator());
104 tg.Generate();
106 this->WriteStampFiles();
110 void cmLocalVisualStudio10Generator
111 ::ReadAndStoreExternalGUID(const char* name,
112 const char* path)
114 cmVS10XMLParser parser;
115 parser.ParseFile(path);
116 std::string guidStoreName = name;
117 guidStoreName += "_GUID_CMAKE";
118 // save the GUID in the cache
119 this->GlobalGenerator->GetCMakeInstance()->
120 AddCacheEntry(guidStoreName.c_str(),
121 parser.GUID.c_str(),
122 "Stored GUID",
123 cmCacheManager::INTERNAL);