cmake/Source/cmLocalVisualStudio10Generator.cxx

105 lines
2.8 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2009-10-04 10:30:41 +03:00
#include "cmLocalVisualStudio10Generator.h"
2016-07-09 11:21:54 +02:00
2016-10-30 18:24:19 +01:00
#include "cmGeneratorTarget.h"
2016-07-09 11:21:54 +02:00
#include "cmGlobalVisualStudio10Generator.h"
2009-10-04 10:30:41 +03:00
#include "cmMakefile.h"
#include "cmVisualStudio10TargetGenerator.h"
#include "cmXMLParser.h"
2016-10-30 18:24:19 +01:00
2017-07-20 19:35:53 +02:00
#include "cm_expat.h"
2016-07-09 11:21:54 +02:00
2009-10-04 10:30:41 +03:00
class cmVS10XMLParser : public cmXMLParser
{
2016-07-09 11:21:54 +02:00
public:
virtual void EndElement(const std::string& /* name */) {}
2009-10-04 10:30:41 +03:00
virtual void CharacterDataHandler(const char* data, int length)
2016-07-09 11:21:54 +02:00
{
if (this->DoGUID) {
this->GUID.assign(data + 1, length - 2);
this->DoGUID = false;
2009-10-04 10:30:41 +03:00
}
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
virtual void StartElement(const std::string& name, const char**)
2016-07-09 11:21:54 +02:00
{
// once the GUID is found do nothing
if (!this->GUID.empty()) {
return;
}
if ("ProjectGUID" == name || "ProjectGuid" == name) {
this->DoGUID = true;
2009-10-04 10:30:41 +03:00
}
2016-07-09 11:21:54 +02:00
}
2009-10-04 10:30:41 +03:00
int InitializeParser()
2016-07-09 11:21:54 +02:00
{
this->DoGUID = false;
int ret = cmXMLParser::InitializeParser();
if (ret == 0) {
return ret;
2009-10-04 10:30:41 +03:00
}
2016-07-09 11:21:54 +02:00
// 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;
}
2009-10-04 10:30:41 +03:00
std::string GUID;
bool DoGUID;
};
2016-07-09 11:21:54 +02:00
cmLocalVisualStudio10Generator::cmLocalVisualStudio10Generator(
cmGlobalGenerator* gg, cmMakefile* mf)
: cmLocalVisualStudio7Generator(gg, mf)
2009-10-04 10:30:41 +03:00
{
}
cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator()
{
}
void cmLocalVisualStudio10Generator::Generate()
{
2013-03-16 19:13:01 +02:00
2016-03-13 13:35:51 +01:00
std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
2016-07-09 11:21:54 +02:00
for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
l != tgts.end(); ++l) {
2017-04-14 19:02:05 +02:00
if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
2014-08-03 19:52:23 +02:00
continue;
2016-07-09 11:21:54 +02:00
}
if (static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
->TargetIsFortranOnly(*l)) {
2016-03-13 13:35:51 +01:00
this->CreateSingleVCProj((*l)->GetName().c_str(), *l);
2016-07-09 11:21:54 +02:00
} else {
2012-02-18 12:40:36 +02:00
cmVisualStudio10TargetGenerator tg(
2016-03-13 13:35:51 +01:00
*l, static_cast<cmGlobalVisualStudio10Generator*>(
2016-07-09 11:21:54 +02:00
this->GetGlobalGenerator()));
2012-02-18 12:40:36 +02:00
tg.Generate();
2009-10-04 10:30:41 +03:00
}
2016-07-09 11:21:54 +02:00
}
2009-10-04 10:30:41 +03:00
this->WriteStampFiles();
}
2016-07-09 11:21:54 +02:00
void cmLocalVisualStudio10Generator::ReadAndStoreExternalGUID(
const std::string& name, const char* path)
2009-10-04 10:30:41 +03:00
{
cmVS10XMLParser parser;
2013-03-16 19:13:01 +02:00
parser.ParseFile(path);
2012-06-27 20:52:58 +03:00
2015-11-17 17:22:37 +01:00
// if we can not find a GUID then we will generate one later
2016-07-09 11:21:54 +02:00
if (parser.GUID.empty()) {
2012-06-27 20:52:58 +03:00
return;
2016-07-09 11:21:54 +02:00
}
2012-06-27 20:52:58 +03:00
2009-10-04 10:30:41 +03:00
std::string guidStoreName = name;
guidStoreName += "_GUID_CMAKE";
// save the GUID in the cache
2016-07-09 11:21:54 +02:00
this->GlobalGenerator->GetCMakeInstance()->AddCacheEntry(
guidStoreName.c_str(), parser.GUID.c_str(), "Stored GUID",
2017-04-14 19:02:05 +02:00
cmStateEnums::INTERNAL);
2009-10-04 10:30:41 +03:00
}
2011-01-16 11:35:12 +01:00
2011-06-19 15:41:06 +03:00
const char* cmLocalVisualStudio10Generator::ReportErrorLabel() const
2011-01-16 11:35:12 +01:00
{
2011-06-19 15:41:06 +03:00
return ":VCEnd";
2011-01-16 11:35:12 +01:00
}