Attached Files | custom_guid_in_external_prj.patch [^] (13,730 bytes) 2012-04-11 06:25 [Show Content] [Hide Content]From 6be9d333977b9a07c1faf43b7986b5b806d1c081 Mon Sep 17 00:00:00 2001
From: unknown <sokolovskiy@.qarea.net>
Date: Mon, 18 Jul 2011 16:19:55 +0300
Subject: [PATCH] include_external_msproject command reworked
---
Source/cmGlobalVisualStudio71Generator.cxx | 13 +++-
Source/cmGlobalVisualStudio71Generator.h | 4 +-
Source/cmGlobalVisualStudio7Generator.cxx | 25 ++++++--
Source/cmGlobalVisualStudio7Generator.h | 4 +-
Source/cmGlobalVisualStudio8Generator.cxx | 10 ++--
Source/cmGlobalVisualStudio8Generator.h | 3 +-
Source/cmIncludeExternalMSProjectCommand.cxx | 84 ++++++++++++++++++++++++--
7 files changed, 119 insertions(+), 24 deletions(-)
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index adb5f2f..7d17f80 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -241,9 +241,12 @@ void cmGlobalVisualStudio71Generator
::WriteExternalProject(std::ostream& fout,
const char* name,
const char* location,
+ const char* typeGuid,
const std::set<cmStdString>& depends)
{
- fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
+ fout << "Project(\"{"
+ << (typeGuid ? typeGuid : "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942")
+ << "}\") = \""
<< name << "\", \""
<< this->ConvertToSolutionPath(location) << "\", \"{"
<< this->GetGUID(name)
@@ -279,18 +282,20 @@ void cmGlobalVisualStudio71Generator
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio71Generator
::WriteProjectConfigurations(std::ostream& fout, const char* name,
- bool partOfDefaultBuild)
+ bool partOfDefaultBuild, const char* platformMapping)
{
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{
fout << "\t\t{" << guid << "}." << *i
- << ".ActiveCfg = " << *i << "|Win32\n";
+ << ".ActiveCfg = " << *i << "|"
+ << (platformMapping ? platformMapping : "Win32") << std::endl;
if(partOfDefaultBuild)
{
fout << "\t\t{" << guid << "}." << *i
- << ".Build.0 = " << *i << "|Win32\n";
+ << ".Build.0 = " << *i << "|"
+ << (platformMapping ? platformMapping : "Win32") << std::endl;
}
}
}
diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h
index 81c2087..503b708 100644
--- a/Source/cmGlobalVisualStudio71Generator.h
+++ b/Source/cmGlobalVisualStudio71Generator.h
@@ -64,10 +64,12 @@ protected:
const char* name, const char* path, cmTarget &t);
virtual void WriteProjectConfigurations(std::ostream& fout,
const char* name,
- bool partOfDefaultBuild);
+ bool partOfDefaultBuild,
+ const char* platformMapping = NULL);
virtual void WriteExternalProject(std::ostream& fout,
const char* name,
const char* path,
+ const char* typeGuid,
const std::set<cmStdString>& depends);
virtual void WriteSLNFooter(std::ostream& fout);
virtual void WriteSLNHeader(std::ostream& fout);
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 51b8918..fa4197b 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -250,7 +250,8 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
if(expath)
{
this->WriteProjectConfigurations(fout, target->GetName(),
- true);
+ true,
+ target->GetProperty("MSVS_PLATFORM_MAPPING"));
}
else
{
@@ -285,8 +286,12 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
{
std::string project = target->GetName();
std::string location = expath;
- this->WriteExternalProject(fout, project.c_str(),
- location.c_str(), target->GetUtilities());
+
+ this->WriteExternalProject(fout,
+ project.c_str(),
+ location.c_str(),
+ target->GetProperty("MSVS_PROJECT_TYPE"),
+ target->GetUtilities());
written = true;
}
else
@@ -579,18 +584,20 @@ cmGlobalVisualStudio7Generator
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio7Generator
::WriteProjectConfigurations(std::ostream& fout, const char* name,
- bool partOfDefaultBuild)
+ bool partOfDefaultBuild, const char* platformMapping)
{
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{
fout << "\t\t{" << guid << "}." << *i
- << ".ActiveCfg = " << *i << "|Win32\n";
+ << ".ActiveCfg = " << *i << "|"
+ << (platformMapping ? platformMapping : "Win32") << "\n";
if(partOfDefaultBuild)
{
fout << "\t\t{" << guid << "}." << *i
- << ".Build.0 = " << *i << "|Win32\n";
+ << ".Build.0 = " << *i << "|"
+ << (platformMapping ? platformMapping : "Win32") << "\n";
}
}
}
@@ -603,10 +610,14 @@ void cmGlobalVisualStudio7Generator
void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout,
const char* name,
const char* location,
+ const char* typeGuid,
const std::set<cmStdString>&)
{
std::string d = cmSystemTools::ConvertToOutputPath(location);
- fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
+ fout << "Project("
+ << "\"{"
+ << (typeGuid ? typeGuid : "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942")
+ << "}\") = \""
<< name << "\", \""
<< this->ConvertToSolutionPath(location) << "\", \"{"
<< this->GetGUID(name)
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index b6c84e8..cd8742a 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -110,7 +110,8 @@ protected:
const char* name, const char* path, cmTarget &t);
virtual void WriteProjectConfigurations(std::ostream& fout,
const char* name,
- bool partOfDefaultBuild);
+ bool partOfDefaultBuild,
+ const char* platformMapping = NULL);
virtual void WriteSLNFooter(std::ostream& fout);
virtual void WriteSLNHeader(std::ostream& fout);
virtual std::string WriteUtilityDepend(cmTarget* target);
@@ -133,6 +134,7 @@ protected:
virtual void WriteExternalProject(std::ostream& fout,
const char* name,
const char* path,
+ const char* typeGuid,
const std::set<cmStdString>&
dependencies);
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index ef723b7..9715bc3 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -270,20 +270,20 @@ cmGlobalVisualStudio8Generator
void
cmGlobalVisualStudio8Generator
::WriteProjectConfigurations(std::ostream& fout, const char* name,
- bool partOfDefaultBuild)
+ bool partOfDefaultBuild, const char* platformMapping)
{
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{
fout << "\t\t{" << guid << "}." << *i
- << "|" << this->GetPlatformName() << ".ActiveCfg = "
- << *i << "|" << this->GetPlatformName() << "\n";
+ << "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|"
+ << (platformMapping ? platformMapping : this->GetPlatformName()) << "\n";
if(partOfDefaultBuild)
{
fout << "\t\t{" << guid << "}." << *i
- << "|" << this->GetPlatformName() << ".Build.0 = "
- << *i << "|" << this->GetPlatformName() << "\n";
+ << "|" << this->GetPlatformName() << ".Build.0 = " << *i << "|"
+ << (platformMapping ? platformMapping : this->GetPlatformName()) << "\n";
}
}
}
diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h
index e0913ed..7dae429 100644
--- a/Source/cmGlobalVisualStudio8Generator.h
+++ b/Source/cmGlobalVisualStudio8Generator.h
@@ -77,7 +77,8 @@ protected:
virtual void WriteSolutionConfigurations(std::ostream& fout);
virtual void WriteProjectConfigurations(std::ostream& fout,
const char* name,
- bool partOfDefaultBuild);
+ bool partOfDefaultBuild,
+ const char* platformMapping = NULL);
virtual bool ComputeTargetDepends();
virtual void WriteProjectDepends(std::ostream& fout, const char* name,
const char* path, cmTarget &t);
diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx
index a4369a3..cf7a8ff 100644
--- a/Source/cmIncludeExternalMSProjectCommand.cxx
+++ b/Source/cmIncludeExternalMSProjectCommand.cxx
@@ -25,19 +25,93 @@ bool cmIncludeExternalMSProjectCommand
#ifdef _WIN32
if(this->Makefile->GetDefinition("WIN32"))
{
+ std::string location = args[1];
+ cmSystemTools::ConvertToUnixSlashes(location);
+
+ bool gotTypeKeyword = false;
+ bool gotPlatformKeyword = false;
+ bool gotGuidKeyword = false;
+
+ std::string customType;
+ std::string customGuid;
+ std::string platformMapping;
+
+ std::vector<std::string> depends;
+ if (args.size() > 2)
+ {
+ for (unsigned int i=2; i<args.size(); ++i)
+ {
+ if (gotTypeKeyword)
+ {
+ customType = args[i];
+ gotTypeKeyword = false;
+ }
+ else if (gotGuidKeyword)
+ {
+ customGuid = args[i];
+ gotGuidKeyword = false;
+ }
+ else if (gotPlatformKeyword)
+ {
+ platformMapping = args[i];
+ gotPlatformKeyword = false;
+ }
+ else if (args[i] == "TYPE")
+ gotTypeKeyword = true;
+ else if (args[i] == "GUID")
+ gotGuidKeyword = true;
+ else if (args[i] == "PLATFORM")
+ gotPlatformKeyword = true;
+ else
+ depends.push_back(args[i]);
+ }
+ }
+
+ // Hack together a utility target storing enough information
+ // to reproduce the target inclusion.
+ std::string utility_name = args[0];
+
std::string path = args[1];
cmSystemTools::ConvertToUnixSlashes(path);
+ if (!customGuid.empty())
+ {
+ std::string guidStoreName = utility_name + "_GUID_CMAKE";
+ this->Makefile->GetCMakeInstance()->AddCacheEntry(guidStoreName.c_str(),
+ customGuid.c_str(),
+ "Stored GUID",
+ cmCacheManager::INTERNAL);
+ }
+
// Create a target instance for this utility.
cmTarget* target=this->Makefile->AddNewTarget(cmTarget::UTILITY,
- args[0].c_str());
+ utility_name.c_str());
+
+ target->SetProperty("GENERATOR_FILE_NAME", utility_name.c_str());
target->SetProperty("EXTERNAL_MSPROJECT", path.c_str());
- target->SetProperty("EXCLUDE_FROM_ALL","FALSE");
- target->SetProperty("GENERATOR_FILE_NAME", args[0].c_str());
- for (unsigned int i=2; i<args.size(); ++i)
+ target->SetProperty("EXCLUDE_FROM_ALL","FALSE");
+
+ if (!customType.empty())
+ target->SetProperty("MSVS_PROJECT_TYPE",customType.c_str());
+ if (!platformMapping.empty())
+ target->SetProperty("MSVS_PLATFORM_MAPPING",platformMapping.c_str());
+
+ for (std::vector<std::string>::const_iterator it = depends.begin();
+ it != depends.end();
+ ++it)
{
- target->AddUtility(args[i].c_str());
+ target->AddUtility(it->c_str());
}
+/*
+ std::vector<std::string> no_outputs;
+ cmCustomCommandLines commandLines;
+ cmCustomCommandLine commandLine;
+ commandLine.push_back(args[0]);
+ commandLine.push_back(path);
+ commandLines.push_back(commandLine);
+ cmCustomCommand cc(this->Makefile, no_outputs, depends, commandLines, 0, 0);
+ target->GetPostBuildCommands().push_back(cc);
+*/
}
#endif
return true;
--
1.7.0.2.msysgit.0
include_external_msproject.patch [^] (14,530 bytes) 2012-04-13 04:57 [Show Content] [Hide Content]diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index a5feaca..615fcb3 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -241,9 +241,12 @@ void cmGlobalVisualStudio71Generator
::WriteExternalProject(std::ostream& fout,
const char* name,
const char* location,
+ const char* typeGuid,
const std::set<cmStdString>& depends)
{
- fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
+ fout << "Project(\"{"
+ << (typeGuid ? typeGuid : "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942")
+ << "}\") = \""
<< name << "\", \""
<< this->ConvertToSolutionPath(location) << "\", \"{"
<< this->GetGUID(name)
@@ -279,18 +282,20 @@ void cmGlobalVisualStudio71Generator
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio71Generator
::WriteProjectConfigurations(std::ostream& fout, const char* name,
- bool partOfDefaultBuild)
+ bool partOfDefaultBuild, const char* platformMapping)
{
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{
fout << "\t\t{" << guid << "}." << *i
- << ".ActiveCfg = " << *i << "|Win32\n";
+ << ".ActiveCfg = " << *i << "|"
+ << (platformMapping ? platformMapping : "Win32") << std::endl;
if(partOfDefaultBuild)
{
fout << "\t\t{" << guid << "}." << *i
- << ".Build.0 = " << *i << "|Win32\n";
+ << ".Build.0 = " << *i << "|"
+ << (platformMapping ? platformMapping : "Win32") << std::endl;
}
}
}
diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h
index 81c2087..503b708 100644
--- a/Source/cmGlobalVisualStudio71Generator.h
+++ b/Source/cmGlobalVisualStudio71Generator.h
@@ -64,10 +64,12 @@ protected:
const char* name, const char* path, cmTarget &t);
virtual void WriteProjectConfigurations(std::ostream& fout,
const char* name,
- bool partOfDefaultBuild);
+ bool partOfDefaultBuild,
+ const char* platformMapping = NULL);
virtual void WriteExternalProject(std::ostream& fout,
const char* name,
const char* path,
+ const char* typeGuid,
const std::set<cmStdString>& depends);
virtual void WriteSLNFooter(std::ostream& fout);
virtual void WriteSLNHeader(std::ostream& fout);
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index a68e6d8..5d93f25 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -251,7 +251,8 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
if(expath)
{
this->WriteProjectConfigurations(fout, target->GetName(),
- true);
+ true,
+ target->GetProperty("VS_PLATFORM_MAPPING"));
}
else
{
@@ -286,8 +287,12 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
{
std::string project = target->GetName();
std::string location = expath;
- this->WriteExternalProject(fout, project.c_str(),
- location.c_str(), target->GetUtilities());
+
+ this->WriteExternalProject(fout,
+ project.c_str(),
+ location.c_str(),
+ target->GetProperty("VS_PROJECT_TYPE"),
+ target->GetUtilities());
written = true;
}
else
@@ -580,18 +585,20 @@ cmGlobalVisualStudio7Generator
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio7Generator
::WriteProjectConfigurations(std::ostream& fout, const char* name,
- bool partOfDefaultBuild)
+ bool partOfDefaultBuild, const char* platformMapping)
{
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{
fout << "\t\t{" << guid << "}." << *i
- << ".ActiveCfg = " << *i << "|Win32\n";
+ << ".ActiveCfg = " << *i << "|"
+ << (platformMapping ? platformMapping : "Win32") << "\n";
if(partOfDefaultBuild)
{
fout << "\t\t{" << guid << "}." << *i
- << ".Build.0 = " << *i << "|Win32\n";
+ << ".Build.0 = " << *i << "|"
+ << (platformMapping ? platformMapping : "Win32") << "\n";
}
}
}
@@ -604,10 +611,14 @@ void cmGlobalVisualStudio7Generator
void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout,
const char* name,
const char* location,
+ const char* typeGuid,
const std::set<cmStdString>&)
{
std::string d = cmSystemTools::ConvertToOutputPath(location);
- fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
+ fout << "Project("
+ << "\"{"
+ << (typeGuid ? typeGuid : "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942")
+ << "}\") = \""
<< name << "\", \""
<< this->ConvertToSolutionPath(location) << "\", \"{"
<< this->GetGUID(name)
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index c92998e..9b9107d 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -107,7 +107,8 @@ protected:
const char* name, const char* path, cmTarget &t);
virtual void WriteProjectConfigurations(std::ostream& fout,
const char* name,
- bool partOfDefaultBuild);
+ bool partOfDefaultBuild,
+ const char* platformMapping = NULL);
virtual void WriteSLNFooter(std::ostream& fout);
virtual void WriteSLNHeader(std::ostream& fout);
virtual std::string WriteUtilityDepend(cmTarget* target);
@@ -130,6 +131,7 @@ protected:
virtual void WriteExternalProject(std::ostream& fout,
const char* name,
const char* path,
+ const char* typeGuid,
const std::set<cmStdString>&
dependencies);
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index a723109..e907ec3 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -270,20 +270,20 @@ cmGlobalVisualStudio8Generator
void
cmGlobalVisualStudio8Generator
::WriteProjectConfigurations(std::ostream& fout, const char* name,
- bool partOfDefaultBuild)
+ bool partOfDefaultBuild, const char* platformMapping)
{
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{
fout << "\t\t{" << guid << "}." << *i
- << "|" << this->GetPlatformName() << ".ActiveCfg = "
- << *i << "|" << this->GetPlatformName() << "\n";
+ << "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|"
+ << (platformMapping ? platformMapping : this->GetPlatformName()) << "\n";
if(partOfDefaultBuild)
{
fout << "\t\t{" << guid << "}." << *i
- << "|" << this->GetPlatformName() << ".Build.0 = "
- << *i << "|" << this->GetPlatformName() << "\n";
+ << "|" << this->GetPlatformName() << ".Build.0 = " << *i << "|"
+ << (platformMapping ? platformMapping : this->GetPlatformName()) << "\n";
}
}
}
diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h
index e0913ed..7dae429 100644
--- a/Source/cmGlobalVisualStudio8Generator.h
+++ b/Source/cmGlobalVisualStudio8Generator.h
@@ -77,7 +77,8 @@ protected:
virtual void WriteSolutionConfigurations(std::ostream& fout);
virtual void WriteProjectConfigurations(std::ostream& fout,
const char* name,
- bool partOfDefaultBuild);
+ bool partOfDefaultBuild,
+ const char* platformMapping = NULL);
virtual bool ComputeTargetDepends();
virtual void WriteProjectDepends(std::ostream& fout, const char* name,
const char* path, cmTarget &t);
diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx
index a4369a3..4728a42 100644
--- a/Source/cmIncludeExternalMSProjectCommand.cxx
+++ b/Source/cmIncludeExternalMSProjectCommand.cxx
@@ -25,18 +25,84 @@ bool cmIncludeExternalMSProjectCommand
#ifdef _WIN32
if(this->Makefile->GetDefinition("WIN32"))
{
+ enum Doing { DoingNone, DoingType, DoingGuid, DoingPlatform };
+
+ Doing stage = DoingNone;
+
+ std::string customType;
+ std::string customGuid;
+ std::string platformMapping;
+
+ std::vector<std::string> depends;
+ if (args.size() > 2)
+ {
+ for (unsigned int i=2; i<args.size(); ++i)
+ {
+ if (stage != DoingNone)
+ {
+ switch (stage)
+ {
+ case DoingType:
+ customType = args[i];
+ break;
+ case DoingPlatform:
+ platformMapping = args[i];
+ break;
+ case DoingGuid:
+ customGuid = args[i];
+ break;
+ }
+
+ stage = DoingNone;
+ }
+ else
+ {
+ if (args[i] == "TYPE")
+ stage = DoingType;
+ else if (args[i] == "GUID")
+ stage = DoingGuid;
+ else if (args[i] == "PLATFORM")
+ stage = DoingPlatform;
+ else
+ depends.push_back(args[i]);
+ }
+ }
+ }
+
+ // Hack together a utility target storing enough information
+ // to reproduce the target inclusion.
+ std::string utility_name = args[0];
+
std::string path = args[1];
cmSystemTools::ConvertToUnixSlashes(path);
+ if (!customGuid.empty())
+ {
+ std::string guidVariable = utility_name + "_GUID_CMAKE";
+ this->Makefile->GetCMakeInstance()->AddCacheEntry(guidVariable.c_str(),
+ customGuid.c_str(),
+ "Stored GUID",
+ cmCacheManager::INTERNAL);
+ }
+
// Create a target instance for this utility.
cmTarget* target=this->Makefile->AddNewTarget(cmTarget::UTILITY,
- args[0].c_str());
+ utility_name.c_str());
+
+ target->SetProperty("GENERATOR_FILE_NAME", utility_name.c_str());
target->SetProperty("EXTERNAL_MSPROJECT", path.c_str());
- target->SetProperty("EXCLUDE_FROM_ALL","FALSE");
- target->SetProperty("GENERATOR_FILE_NAME", args[0].c_str());
- for (unsigned int i=2; i<args.size(); ++i)
+ target->SetProperty("EXCLUDE_FROM_ALL", "FALSE");
+
+ if (!customType.empty())
+ target->SetProperty("VS_PROJECT_TYPE",customType.c_str());
+ if (!platformMapping.empty())
+ target->SetProperty("VS_PLATFORM_MAPPING",platformMapping.c_str());
+
+ for (std::vector<std::string>::const_iterator it = depends.begin();
+ it != depends.end();
+ ++it)
{
- target->AddUtility(args[i].c_str());
+ target->AddUtility(it->c_str());
}
}
#endif
diff --git a/Source/cmIncludeExternalMSProjectCommand.h b/Source/cmIncludeExternalMSProjectCommand.h
index 911a772..6b6ed68 100644
--- a/Source/cmIncludeExternalMSProjectCommand.h
+++ b/Source/cmIncludeExternalMSProjectCommand.h
@@ -59,11 +59,19 @@ public:
{
return
" include_external_msproject(projectname location\n"
+ " [TYPE projectTypeGUID]\n"
+ " [GUID projectGUID]\n"
+ " [PLATFORM platformName]\n"
" dep1 dep2 ...)\n"
"Includes an external Microsoft project in the generated workspace "
"file. Currently does nothing on UNIX. This will create a "
"target named [projectname]. This can be used in the add_dependencies "
- "command to make things depend on the external project.";
+ "command to make things depend on the external project.\n"
+ "TYPE, GUID and PLATFORM are optional parameters that allow "
+ "to specify the type of project, id (GUID) of the project and "
+ "the name of the target platform. Useful for projects requiring values "
+ "other than the default (e.g. WIX projects). "
+ "NOTE: this feature does not supported by Visual Studio 6 generator.";
}
cmTypeMacro(cmIncludeExternalMSProjectCommand, cmCommand);
diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx
index bf0e997..8f190cf 100644
--- a/Source/cmLocalVisualStudio10Generator.cxx
+++ b/Source/cmLocalVisualStudio10Generator.cxx
@@ -99,6 +99,14 @@ void cmLocalVisualStudio10Generator
{
cmVS10XMLParser parser;
parser.ParseFile(path);
+
+ // if we can not find a GUID then create one
+ if(parser.GUID.empty())
+ {
+ this->GlobalGenerator->CreateGUID(name);
+ return;
+ }
+
std::string guidStoreName = name;
guidStoreName += "_GUID_CMAKE";
// save the GUID in the cache
0001-include_external_msproject-Add-TYPE-GUID-PLATFORM-op.patch [^] (15,414 bytes) 2012-04-16 10:19 [Show Content] [Hide Content]From 59139031a1aa24231b9302aa4cd8ecc4e22fb594 Mon Sep 17 00:00:00 2001
Message-Id: <59139031a1aa24231b9302aa4cd8ecc4e22fb594.1334585965.git.brad.king@kitware.com>
From: Leonid Yurchenko <nocturne@qarea.com>
Date: Mon, 16 Apr 2012 10:07:19 -0400
Subject: [PATCH] include_external_msproject: Add TYPE, GUID, PLATFORM options
(#13120)
These allow one to reference more external VS project file variations.
---
Source/cmGlobalVisualStudio71Generator.cxx | 13 +++--
Source/cmGlobalVisualStudio71Generator.h | 4 +-
Source/cmGlobalVisualStudio7Generator.cxx | 25 +++++++---
Source/cmGlobalVisualStudio7Generator.h | 4 +-
Source/cmGlobalVisualStudio8Generator.cxx | 10 ++--
Source/cmGlobalVisualStudio8Generator.h | 3 +-
Source/cmIncludeExternalMSProjectCommand.cxx | 68 ++++++++++++++++++++++++--
Source/cmIncludeExternalMSProjectCommand.h | 12 ++++-
Source/cmLocalVisualStudio10Generator.cxx | 8 +++
9 files changed, 122 insertions(+), 25 deletions(-)
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index a5feaca..11bccde 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -241,9 +241,12 @@ void cmGlobalVisualStudio71Generator
::WriteExternalProject(std::ostream& fout,
const char* name,
const char* location,
+ const char* typeGuid,
const std::set<cmStdString>& depends)
{
- fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
+ fout << "Project(\"{"
+ << (typeGuid ? typeGuid : "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942")
+ << "}\") = \""
<< name << "\", \""
<< this->ConvertToSolutionPath(location) << "\", \"{"
<< this->GetGUID(name)
@@ -279,18 +282,20 @@ void cmGlobalVisualStudio71Generator
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio71Generator
::WriteProjectConfigurations(std::ostream& fout, const char* name,
- bool partOfDefaultBuild)
+ bool partOfDefaultBuild, const char* platformMapping)
{
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{
fout << "\t\t{" << guid << "}." << *i
- << ".ActiveCfg = " << *i << "|Win32\n";
+ << ".ActiveCfg = " << *i << "|"
+ << (platformMapping ? platformMapping : "Win32") << std::endl;
if(partOfDefaultBuild)
{
fout << "\t\t{" << guid << "}." << *i
- << ".Build.0 = " << *i << "|Win32\n";
+ << ".Build.0 = " << *i << "|"
+ << (platformMapping ? platformMapping : "Win32") << std::endl;
}
}
}
diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h
index 81c2087..503b708 100644
--- a/Source/cmGlobalVisualStudio71Generator.h
+++ b/Source/cmGlobalVisualStudio71Generator.h
@@ -64,10 +64,12 @@ protected:
const char* name, const char* path, cmTarget &t);
virtual void WriteProjectConfigurations(std::ostream& fout,
const char* name,
- bool partOfDefaultBuild);
+ bool partOfDefaultBuild,
+ const char* platformMapping = NULL);
virtual void WriteExternalProject(std::ostream& fout,
const char* name,
const char* path,
+ const char* typeGuid,
const std::set<cmStdString>& depends);
virtual void WriteSLNFooter(std::ostream& fout);
virtual void WriteSLNHeader(std::ostream& fout);
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index a68e6d8..09b200f 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -251,7 +251,8 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
if(expath)
{
this->WriteProjectConfigurations(fout, target->GetName(),
- true);
+ true,
+ target->GetProperty("VS_PLATFORM_MAPPING"));
}
else
{
@@ -286,8 +287,12 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
{
std::string project = target->GetName();
std::string location = expath;
- this->WriteExternalProject(fout, project.c_str(),
- location.c_str(), target->GetUtilities());
+
+ this->WriteExternalProject(fout,
+ project.c_str(),
+ location.c_str(),
+ target->GetProperty("VS_PROJECT_TYPE"),
+ target->GetUtilities());
written = true;
}
else
@@ -580,18 +585,20 @@ cmGlobalVisualStudio7Generator
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio7Generator
::WriteProjectConfigurations(std::ostream& fout, const char* name,
- bool partOfDefaultBuild)
+ bool partOfDefaultBuild, const char* platformMapping)
{
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{
fout << "\t\t{" << guid << "}." << *i
- << ".ActiveCfg = " << *i << "|Win32\n";
+ << ".ActiveCfg = " << *i << "|"
+ << (platformMapping ? platformMapping : "Win32") << "\n";
if(partOfDefaultBuild)
{
fout << "\t\t{" << guid << "}." << *i
- << ".Build.0 = " << *i << "|Win32\n";
+ << ".Build.0 = " << *i << "|"
+ << (platformMapping ? platformMapping : "Win32") << "\n";
}
}
}
@@ -604,10 +611,14 @@ void cmGlobalVisualStudio7Generator
void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout,
const char* name,
const char* location,
+ const char* typeGuid,
const std::set<cmStdString>&)
{
std::string d = cmSystemTools::ConvertToOutputPath(location);
- fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
+ fout << "Project("
+ << "\"{"
+ << (typeGuid ? typeGuid : "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942")
+ << "}\") = \""
<< name << "\", \""
<< this->ConvertToSolutionPath(location) << "\", \"{"
<< this->GetGUID(name)
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index c92998e..9b9107d 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -107,7 +107,8 @@ protected:
const char* name, const char* path, cmTarget &t);
virtual void WriteProjectConfigurations(std::ostream& fout,
const char* name,
- bool partOfDefaultBuild);
+ bool partOfDefaultBuild,
+ const char* platformMapping = NULL);
virtual void WriteSLNFooter(std::ostream& fout);
virtual void WriteSLNHeader(std::ostream& fout);
virtual std::string WriteUtilityDepend(cmTarget* target);
@@ -130,6 +131,7 @@ protected:
virtual void WriteExternalProject(std::ostream& fout,
const char* name,
const char* path,
+ const char* typeGuid,
const std::set<cmStdString>&
dependencies);
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index a723109..72eb48d 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -270,20 +270,20 @@ cmGlobalVisualStudio8Generator
void
cmGlobalVisualStudio8Generator
::WriteProjectConfigurations(std::ostream& fout, const char* name,
- bool partOfDefaultBuild)
+ bool partOfDefaultBuild, const char* platformMapping)
{
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{
fout << "\t\t{" << guid << "}." << *i
- << "|" << this->GetPlatformName() << ".ActiveCfg = "
- << *i << "|" << this->GetPlatformName() << "\n";
+ << "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|"
+ << (platformMapping ? platformMapping : this->GetPlatformName()) << "\n";
if(partOfDefaultBuild)
{
fout << "\t\t{" << guid << "}." << *i
- << "|" << this->GetPlatformName() << ".Build.0 = "
- << *i << "|" << this->GetPlatformName() << "\n";
+ << "|" << this->GetPlatformName() << ".Build.0 = " << *i << "|"
+ << (platformMapping ? platformMapping : this->GetPlatformName()) << "\n";
}
}
}
diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h
index e0913ed..7dae429 100644
--- a/Source/cmGlobalVisualStudio8Generator.h
+++ b/Source/cmGlobalVisualStudio8Generator.h
@@ -77,7 +77,8 @@ protected:
virtual void WriteSolutionConfigurations(std::ostream& fout);
virtual void WriteProjectConfigurations(std::ostream& fout,
const char* name,
- bool partOfDefaultBuild);
+ bool partOfDefaultBuild,
+ const char* platformMapping = NULL);
virtual bool ComputeTargetDepends();
virtual void WriteProjectDepends(std::ostream& fout, const char* name,
const char* path, cmTarget &t);
diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx
index a4369a3..bcec45e 100644
--- a/Source/cmIncludeExternalMSProjectCommand.cxx
+++ b/Source/cmIncludeExternalMSProjectCommand.cxx
@@ -25,18 +25,76 @@ bool cmIncludeExternalMSProjectCommand
#ifdef _WIN32
if(this->Makefile->GetDefinition("WIN32"))
{
+ enum Doing { DoingNone, DoingType, DoingGuid, DoingPlatform };
+
+ Doing doing = DoingNone;
+
+ std::string customType;
+ std::string customGuid;
+ std::string platformMapping;
+
+ std::vector<std::string> depends;
+ for (unsigned int i=2; i<args.size(); ++i)
+ {
+ if (args[i] == "TYPE")
+ {
+ doing = DoingType;
+ }
+ else if (args[i] == "GUID")
+ {
+ doing = DoingGuid;
+ }
+ else if (args[i] == "PLATFORM")
+ {
+ doing = DoingPlatform;
+ }
+ else
+ {
+ switch (doing)
+ {
+ case DoingNone: depends.push_back(args[i]); break;
+ case DoingType: customType = args[i]; break;
+ case DoingGuid: customGuid = args[i]; break;
+ case DoingPlatform: platformMapping = args[i]; break;
+ }
+ doing = DoingNone;
+ }
+ }
+
+ // Hack together a utility target storing enough information
+ // to reproduce the target inclusion.
+ std::string utility_name = args[0];
+
std::string path = args[1];
cmSystemTools::ConvertToUnixSlashes(path);
+ if (!customGuid.empty())
+ {
+ std::string guidVariable = utility_name + "_GUID_CMAKE";
+ this->Makefile->GetCMakeInstance()->AddCacheEntry(guidVariable.c_str(),
+ customGuid.c_str(),
+ "Stored GUID",
+ cmCacheManager::INTERNAL);
+ }
+
// Create a target instance for this utility.
cmTarget* target=this->Makefile->AddNewTarget(cmTarget::UTILITY,
- args[0].c_str());
+ utility_name.c_str());
+
+ target->SetProperty("GENERATOR_FILE_NAME", utility_name.c_str());
target->SetProperty("EXTERNAL_MSPROJECT", path.c_str());
- target->SetProperty("EXCLUDE_FROM_ALL","FALSE");
- target->SetProperty("GENERATOR_FILE_NAME", args[0].c_str());
- for (unsigned int i=2; i<args.size(); ++i)
+ target->SetProperty("EXCLUDE_FROM_ALL", "FALSE");
+
+ if (!customType.empty())
+ target->SetProperty("VS_PROJECT_TYPE",customType.c_str());
+ if (!platformMapping.empty())
+ target->SetProperty("VS_PLATFORM_MAPPING",platformMapping.c_str());
+
+ for (std::vector<std::string>::const_iterator it = depends.begin();
+ it != depends.end();
+ ++it)
{
- target->AddUtility(args[i].c_str());
+ target->AddUtility(it->c_str());
}
}
#endif
diff --git a/Source/cmIncludeExternalMSProjectCommand.h b/Source/cmIncludeExternalMSProjectCommand.h
index 911a772..2b2ed0d 100644
--- a/Source/cmIncludeExternalMSProjectCommand.h
+++ b/Source/cmIncludeExternalMSProjectCommand.h
@@ -59,11 +59,21 @@ public:
{
return
" include_external_msproject(projectname location\n"
+ " [TYPE projectTypeGUID]\n"
+ " [GUID projectGUID]\n"
+ " [PLATFORM platformName]\n"
" dep1 dep2 ...)\n"
"Includes an external Microsoft project in the generated workspace "
"file. Currently does nothing on UNIX. This will create a "
"target named [projectname]. This can be used in the add_dependencies "
- "command to make things depend on the external project.";
+ "command to make things depend on the external project."
+ "\n"
+ "TYPE, GUID and PLATFORM are optional parameters that allow one "
+ "to specify the type of project, id (GUID) of the project and "
+ "the name of the target platform. "
+ "This is useful for projects requiring values other than the default "
+ "(e.g. WIX projects). "
+ "These options are not supported by the Visual Studio 6 generator.";
}
cmTypeMacro(cmIncludeExternalMSProjectCommand, cmCommand);
diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx
index bf0e997..ace7adf 100644
--- a/Source/cmLocalVisualStudio10Generator.cxx
+++ b/Source/cmLocalVisualStudio10Generator.cxx
@@ -99,6 +99,14 @@ void cmLocalVisualStudio10Generator
{
cmVS10XMLParser parser;
parser.ParseFile(path);
+
+ // if we can not find a GUID then create one
+ if(parser.GUID.empty())
+ {
+ this->GlobalGenerator->CreateGUID(name);
+ return;
+ }
+
std::string guidStoreName = name;
guidStoreName += "_GUID_CMAKE";
// save the GUID in the cache
--
1.7.8.3
include_external_msproject-test.zip [^] (3,259 bytes) 2012-04-18 09:55
include_external_msproject-test_v2.zip [^] (3,324 bytes) 2012-04-19 07:52 |