1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmLocalVisualStudio10Generator.cxx,v $
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"
19 #include "cmMakefile.h"
20 #include "cmVisualStudio10TargetGenerator.h"
21 #include "cmGlobalVisualStudio7Generator.h"
23 #include "cmXMLParser.h"
24 class cmVS10XMLParser
: public cmXMLParser
27 virtual void EndElement(const char* /* name */)
30 virtual void CharacterDataHandler(const char* data
, int length
)
34 this->GUID
.assign(data
+1, length
-2);
38 virtual void StartElement(const char* name
, const char**)
40 // once the GUID is found do nothing
45 if(strcmp("ProjectGUID", name
) == 0)
50 int InitializeParser()
53 int ret
= cmXMLParser::InitializeParser();
58 // visual studio projects have a strange encoding, but it is
60 XML_SetEncoding(static_cast<XML_Parser
>(this->Parser
), "utf-8");
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());
106 this->WriteStampFiles();
110 void cmLocalVisualStudio10Generator
111 ::ReadAndStoreExternalGUID(const char* name
,
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(),
123 cmCacheManager::INTERNAL
);