VS: Teach vcxproj generation about the Tegra-Android platform

Complete the basic implementation of the VS Tegra-Android generators
by replacing parts of vcxproj files that are specific to MS tools
with settings defined for the NVIDIA Nsight Tegra tools.

Current limitations include:

* We have no "flag table" so flags will be passed in the additional
  options fields instead of mapped to the vcxproj elements defined
  by Nsight Tegra msbuild platform definition files.

* We have no interface to set the AndroidArch, AndroidStlType, or
  AndroidTargetAPI fields so defaults will be used.

* The Nsight Tegra msbuild platform definition files do not provide
  a working "Utility" target type so for add_custom_target we need
  to use a "StaticLibrary" target type and leave out ClCompile rules.

* There is also no target type for plain command-line executables
  so for add_executable we need to use a "DynamicLibrary" target.
  Full application bundles will likely require new CMake target
  properties (like WIN32_EXECUTABLE for Windows GUI executables).
This commit is contained in:
Brad King 2014-06-10 11:33:19 -04:00
parent d09b60f563
commit ef0fd4f0ce
2 changed files with 52 additions and 3 deletions

View File

@ -180,7 +180,8 @@ cmVisualStudio10TargetGenerator(cmTarget* target,
this->GlobalGenerator->CreateGUID(this->Name.c_str());
this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str());
this->Platform = gg->GetPlatformName();
this->MSTools = true;
this->NsightTegra = gg->IsNsightTegra();
this->MSTools = !this->NsightTegra;
this->TargetCompileAsWinRT = false;
this->BuildFileStream = 0;
this->IsMissingFiles = false;
@ -312,6 +313,15 @@ void cmVisualStudio10TargetGenerator::Generate()
"xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n");
this->WriteString(project_defaults.c_str(),0);
if(this->NsightTegra)
{
this->WriteString("<PropertyGroup Label=\"NsightTegraProject\">\n", 1);
this->WriteString("<NsightTegraProjectRevisionNumber>"
"6"
"</NsightTegraProjectRevisionNumber>\n", 2);
this->WriteString("</PropertyGroup>\n", 1);
}
this->WriteProjectConfigurations();
this->WriteString("<PropertyGroup Label=\"Globals\">\n", 1);
this->WriteString("<ProjectGUID>", 2);
@ -605,11 +615,27 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
configType += "StaticLibrary";
break;
case cmTarget::EXECUTABLE:
configType += "Application";
if(this->NsightTegra)
{
// Android executables are .so too.
configType += "DynamicLibrary";
}
else
{
configType += "Application";
}
break;
case cmTarget::UTILITY:
case cmTarget::GLOBAL_TARGET:
configType += "Utility";
if(this->NsightTegra)
{
// Tegra-Android platform does not understand "Utility".
configType += "StaticLibrary";
}
else
{
configType += "Utility";
}
break;
case cmTarget::UNKNOWN_LIBRARY:
case cmTarget::INTERFACE_LIBRARY:
@ -622,6 +648,10 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
{
this->WriteMSToolConfigurationValues(*i);
}
else if(this->NsightTegra)
{
this->WriteNsightTegraConfigurationValues(*i);
}
this->WriteString("</PropertyGroup>\n", 1);
}
@ -683,6 +713,19 @@ void cmVisualStudio10TargetGenerator
}
}
//----------------------------------------------------------------------------
void cmVisualStudio10TargetGenerator
::WriteNsightTegraConfigurationValues(std::string const&)
{
cmGlobalVisualStudio10Generator* gg =
static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
const char* toolset = gg->GetPlatformToolset();
std::string ntv = "<NdkToolchainVersion>";
ntv += toolset? toolset : "Default";
ntv += "</NdkToolchainVersion>\n";
this->WriteString(ntv.c_str(), 2);
}
void cmVisualStudio10TargetGenerator::WriteCustomCommands()
{
this->SourcesVisited.clear();
@ -2188,6 +2231,10 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries", "ole32.lib");
}
}
else if(this->NsightTegra)
{
linkOptions.AddFlag("SoName", targetNameSO.c_str());
}
linkOptions.Parse(flags.c_str());

View File

@ -59,6 +59,7 @@ private:
void WriteMSToolConfigurationValues(std::string const& config);
void WriteHeaderSource(cmSourceFile const* sf);
void WriteExtraSource(cmSourceFile const* sf);
void WriteNsightTegraConfigurationValues(std::string const& config);
void WriteSource(std::string const& tool, cmSourceFile const* sf,
const char* end = 0);
void WriteSources(std::string const& tool,
@ -139,6 +140,7 @@ private:
std::string GUID;
std::string Name;
bool MSTools;
bool NsightTegra;
bool TargetCompileAsWinRT;
cmGlobalVisualStudio10Generator* GlobalGenerator;
cmGeneratedFileStream* BuildFileStream;