On 07/08/2014 08:46 AM, Tim Jenks wrote:
> I would also be interested in any information regarding nsight tegra 
> solution generation using cmake.
> 
> Did anything come of this thread?

We ended up working with NVIDIA directly and have produced a
draft of support for Nsight Tegra with Visual Studio.  It is
still a work in progress but I've attached the current draft
patch series (they apply on master as of 487b6ccd, and perhaps
more recent versions too).  Limitations of the current draft
are documented in patch 0004.

With these patches and NVIDIA Nsight Tegra Visual Studio
Edition installed, new generator variants are available:

 Visual Studio 12 2013 Tegra-Android
 Visual Studio 11 2012 Tegra-Android
 Visual Studio 10 2010 Tegra-Android

A non-default Android NDK toolchain may be selected at the
command-line, e.g.

 cmake -G "Visual Studio 12 2013 Tegra-Android" -T clang-3.4 ...

or using a CMAKE_TOOLCHAIN_FILE that sets CMAKE_GENERATOR_TOOLSET.

Feedback is welcome.

Thanks,
-Brad

>From 8d18af8606007cce32aa16b57becb51f8c1fa8be Mon Sep 17 00:00:00 2001
Message-Id: <8d18af8606007cce32aa16b57becb51f8c1fa8be.1402422416.git.brad.k...@kitware.com>
From: Brad King <brad.k...@kitware.com>
Date: Tue, 10 Jun 2014 10:13:00 -0400
Subject: [PATCH 1/4] VS: Make MS-tool-specific options conditional

Make blocks adding MS-tool-specific options conditional on a
new "MSTools" boolean member of cmVisualStudio10TargetGenerator.
Hard-code the member to true for now to preserve existing behavior.
---
 Source/cmVisualStudio10TargetGenerator.cxx | 200 +++++++++++++++++------------
 Source/cmVisualStudio10TargetGenerator.h   |   1 +
 2 files changed, 122 insertions(+), 79 deletions(-)

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index acf3930..aa6d00d 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -34,38 +34,50 @@
 
 cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetClFlagTable() const
 {
-  cmLocalVisualStudioGenerator::VSVersion
-    v = this->LocalGenerator->GetVersion();
-  if(v >= cmLocalVisualStudioGenerator::VS12)
-    { return cmVS12CLFlagTable; }
-  else if(v == cmLocalVisualStudioGenerator::VS11)
-    { return cmVS11CLFlagTable; }
-  else
-    { return cmVS10CLFlagTable; }
+  if(this->MSTools)
+    {
+    cmLocalVisualStudioGenerator::VSVersion
+      v = this->LocalGenerator->GetVersion();
+    if(v >= cmLocalVisualStudioGenerator::VS12)
+      { return cmVS12CLFlagTable; }
+    else if(v == cmLocalVisualStudioGenerator::VS11)
+      { return cmVS11CLFlagTable; }
+    else
+      { return cmVS10CLFlagTable; }
+    }
+  return 0;
 }
 
 cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLibFlagTable() const
 {
-  cmLocalVisualStudioGenerator::VSVersion
-    v = this->LocalGenerator->GetVersion();
-  if(v >= cmLocalVisualStudioGenerator::VS12)
-    { return cmVS12LibFlagTable; }
-  else if(v == cmLocalVisualStudioGenerator::VS11)
-    { return cmVS11LibFlagTable; }
-  else
-    { return cmVS10LibFlagTable; }
+  if(this->MSTools)
+    {
+    cmLocalVisualStudioGenerator::VSVersion
+      v = this->LocalGenerator->GetVersion();
+    if(v >= cmLocalVisualStudioGenerator::VS12)
+      { return cmVS12LibFlagTable; }
+    else if(v == cmLocalVisualStudioGenerator::VS11)
+      { return cmVS11LibFlagTable; }
+    else
+      { return cmVS10LibFlagTable; }
+    }
+  return 0;
 }
 
 cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLinkFlagTable() const
 {
-  cmLocalVisualStudioGenerator::VSVersion
-    v = this->LocalGenerator->GetVersion();
-  if(v >= cmLocalVisualStudioGenerator::VS12)
-    { return cmVS12LinkFlagTable; }
-  else if(v == cmLocalVisualStudioGenerator::VS11)
-    { return cmVS11LinkFlagTable; }
-  else
-    { return cmVS10LinkFlagTable; }
+  if(this->MSTools)
+    {
+    cmLocalVisualStudioGenerator::VSVersion
+      v = this->LocalGenerator->GetVersion();
+    if(v >= cmLocalVisualStudioGenerator::VS12)
+      { return cmVS12LinkFlagTable; }
+    else if(v == cmLocalVisualStudioGenerator::VS11)
+      { return cmVS11LinkFlagTable; }
+    else
+      { return cmVS10LinkFlagTable; }
+    }
+  return 0;
 }
 
 static std::string cmVS10EscapeXML(std::string arg)
@@ -115,6 +127,7 @@ 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->BuildFileStream = 0;
 }
 
@@ -501,7 +514,10 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
     configType += "</ConfigurationType>\n";
     this->WriteString(configType.c_str(), 2);
 
-    this->WriteMSToolConfigurationValues(*i);
+    if(this->MSTools)
+      {
+      this->WriteMSToolConfigurationValues(*i);
+      }
 
     this->WriteString("</PropertyGroup>\n", 1);
     }
@@ -1416,17 +1432,23 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
 
   // Get preprocessor definitions for this directory.
   std::string defineFlags = this->Target->GetMakefile()->GetDefineFlags();
-  clOptions.FixExceptionHandlingDefault();
-  clOptions.AddFlag("PrecompiledHeader", "NotUsing");
-  std::string asmLocation = configName + "/";
-  clOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
+  if(this->MSTools)
+    {
+    clOptions.FixExceptionHandlingDefault();
+    clOptions.AddFlag("PrecompiledHeader", "NotUsing");
+    std::string asmLocation = configName + "/";
+    clOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
+    }
   clOptions.Parse(flags.c_str());
   clOptions.Parse(defineFlags.c_str());
   std::vector<std::string> targetDefines;
   this->Target->GetCompileDefinitions(targetDefines, configName.c_str());
   clOptions.AddDefines(targetDefines);
-  clOptions.SetVerboseMakefile(
-    this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
+  if(this->MSTools)
+    {
+    clOptions.SetVerboseMakefile(
+      this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
+    }
 
   // Add a definition for the configuration name.
   std::string configDefine = "CMAKE_INTDIR=\"";
@@ -1455,24 +1477,27 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
   clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, "      ",
                                           "\n", "CXX");
 
-  this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
-
-  // If not in debug mode, write the DebugInformationFormat field
-  // without value so PDBs don't get generated uselessly.
-  if(!clOptions.IsDebug())
+  if(this->MSTools)
     {
-    this->WriteString("<DebugInformationFormat>"
-                      "</DebugInformationFormat>\n", 3);
-    }
+    this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
 
-  // Specify the compiler program database file if configured.
-  std::string pdb = this->Target->GetCompilePDBPath(configName.c_str());
-  if(!pdb.empty())
-    {
-    this->ConvertToWindowsSlash(pdb);
-    this->WriteString("<ProgramDataBaseFileName>", 3);
-    *this->BuildFileStream << cmVS10EscapeXML(pdb)
-                           << "</ProgramDataBaseFileName>\n";
+    // If not in debug mode, write the DebugInformationFormat field
+    // without value so PDBs don't get generated uselessly.
+    if(!clOptions.IsDebug())
+      {
+      this->WriteString("<DebugInformationFormat>"
+                        "</DebugInformationFormat>\n", 3);
+      }
+
+    // Specify the compiler program database file if configured.
+    std::string pdb = this->Target->GetCompilePDBPath(configName.c_str());
+    if(!pdb.empty())
+      {
+      this->ConvertToWindowsSlash(pdb);
+      this->WriteString("<ProgramDataBaseFileName>", 3);
+      *this->BuildFileStream << cmVS10EscapeXML(pdb)
+                             << "</ProgramDataBaseFileName>\n";
+      }
     }
 
   this->WriteString("</ClCompile>\n", 2);
@@ -1499,6 +1524,10 @@ void cmVisualStudio10TargetGenerator::
 WriteRCOptions(std::string const& configName,
                std::vector<std::string> const & includes)
 {
+  if(!this->MSTools)
+    {
+    return;
+    }
   this->WriteString("<ResourceCompile>\n", 2);
   Options& clOptions = *(this->ClOptions[configName]);
   clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, "      ",
@@ -1679,45 +1708,53 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
                                   config.c_str());
     }
 
-  linkOptions.AddFlag("Version", "");
-
-  if ( this->Target->GetPropertyAsBool("WIN32_EXECUTABLE") )
-    {
-    linkOptions.AddFlag("SubSystem", "Windows");
-    }
-  else
+  if(this->MSTools)
     {
-    linkOptions.AddFlag("SubSystem", "Console");
-    }
+    linkOptions.AddFlag("Version", "");
 
-  if(const char* stackVal =
-     this->Makefile->GetDefinition("CMAKE_"+linkLanguage+"_STACK_SIZE"))
-    {
-    linkOptions.AddFlag("StackReserveSize", stackVal);
-    }
+    if ( this->Target->GetPropertyAsBool("WIN32_EXECUTABLE") )
+      {
+      linkOptions.AddFlag("SubSystem", "Windows");
+      }
+    else
+      {
+      linkOptions.AddFlag("SubSystem", "Console");
+      }
 
-  if(linkOptions.IsDebug() || flags.find("/debug") != flags.npos)
-    {
-    linkOptions.AddFlag("GenerateDebugInformation", "true");
-    }
-  else
-    {
-    linkOptions.AddFlag("GenerateDebugInformation", "false");
+    if(const char* stackVal =
+       this->Makefile->GetDefinition("CMAKE_"+linkLanguage+"_STACK_SIZE"))
+      {
+      linkOptions.AddFlag("StackReserveSize", stackVal);
+      }
+
+    if(linkOptions.IsDebug() || flags.find("/debug") != flags.npos)
+      {
+      linkOptions.AddFlag("GenerateDebugInformation", "true");
+      }
+    else
+      {
+      linkOptions.AddFlag("GenerateDebugInformation", "false");
+      }
+    std::string pdb = this->Target->GetPDBDirectory(config.c_str());
+    pdb += "/";
+    pdb += targetNamePDB;
+    std::string imLib = this->Target->GetDirectory(config.c_str(), true);
+    imLib += "/";
+    imLib += targetNameImport;
+
+    linkOptions.AddFlag("ImportLibrary", imLib.c_str());
+    linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str());
     }
-  std::string pdb = this->Target->GetPDBDirectory(config.c_str());
-  pdb += "/";
-  pdb += targetNamePDB;
-  std::string imLib = this->Target->GetDirectory(config.c_str(), true);
-  imLib += "/";
-  imLib += targetNameImport;
 
-  linkOptions.AddFlag("ImportLibrary", imLib.c_str());
-  linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str());
   linkOptions.Parse(flags.c_str());
-  std::string def = this->GeneratorTarget->GetModuleDefinitionFile("");
-  if(!def.empty())
+
+  if(this->MSTools)
     {
-    linkOptions.AddFlag("ModuleDefinitionFile", def.c_str());
+    std::string def = this->GeneratorTarget->GetModuleDefinitionFile("");
+    if(!def.empty())
+      {
+      linkOptions.AddFlag("ModuleDefinitionFile", def.c_str());
+      }
     }
 
   this->LinkOptions[config] = pOptions.release();
@@ -1782,6 +1819,11 @@ void cmVisualStudio10TargetGenerator::
 WriteMidlOptions(std::string const& /*config*/,
                  std::vector<std::string> const & includes)
 {
+  if(!this->MSTools)
+    {
+    return;
+    }
+
   // This processes *any* of the .idl files specified in the project's file
   // list (and passed as the item metadata %(Filename) expressing the rule
   // input filename) into output files at the per-config *build* dir
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 8f2faca..85926d8 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -116,6 +116,7 @@ private:
   std::string Platform;
   std::string GUID;
   std::string Name;
+  bool MSTools;
   cmGlobalVisualStudio10Generator* GlobalGenerator;
   cmGeneratedFileStream* BuildFileStream;
   cmLocalVisualStudio7Generator* LocalGenerator;
-- 
2.0.0

>From 719745d10df8362099df962d5b41a09354dc97bc Mon Sep 17 00:00:00 2001
Message-Id: <719745d10df8362099df962d5b41a09354dc97bc.1402422416.git.brad.k...@kitware.com>
In-Reply-To: <8d18af8606007cce32aa16b57becb51f8c1fa8be.1402422416.git.brad.k...@kitware.com>
References: <8d18af8606007cce32aa16b57becb51f8c1fa8be.1402422416.git.brad.k...@kitware.com>
From: Brad King <brad.k...@kitware.com>
Date: Tue, 10 Jun 2014 11:26:09 -0400
Subject: [PATCH 2/4] VS: Add "Tegra-Android" platform variant of VS >= 10
 generators

Add a variant to generate project files for the NVIDIA Nsight Tegra
Visual Studio Edition.  Enable the variant only when Nsight Tegra
is installed on the host system.

When this generator is used, make the installed version available
in a CMAKE_VS_NsightTegra_VERSION variable.  If a toolchain file
is not used, default to cross-compiling to Android.
---
 Help/manual/cmake-variables.7.rst              |  1 +
 Help/variable/CMAKE_VS_NsightTegra_VERSION.rst |  6 ++++
 Modules/CMakeDetermineSystem.cmake             |  6 ++++
 Source/cmGlobalVisualStudio10Generator.cxx     | 39 ++++++++++++++++++++++++++
 Source/cmGlobalVisualStudio10Generator.h       |  6 ++++
 Source/cmGlobalVisualStudio11Generator.cxx     | 17 +++++++++++
 Source/cmGlobalVisualStudio12Generator.cxx     | 18 ++++++++++++
 7 files changed, 93 insertions(+)
 create mode 100644 Help/variable/CMAKE_VS_NsightTegra_VERSION.rst

diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index df434c5..b16940c 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -73,6 +73,7 @@ Variables that Provide Information
    /variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION
    /variable/CMAKE_VS_MSBUILD_COMMAND
    /variable/CMAKE_VS_MSDEV_COMMAND
+   /variable/CMAKE_VS_NsightTegra_VERSION
    /variable/CMAKE_VS_PLATFORM_TOOLSET
    /variable/CMAKE_XCODE_PLATFORM_TOOLSET
    /variable/PROJECT_BINARY_DIR
diff --git a/Help/variable/CMAKE_VS_NsightTegra_VERSION.rst b/Help/variable/CMAKE_VS_NsightTegra_VERSION.rst
new file mode 100644
index 0000000..595dabb
--- /dev/null
+++ b/Help/variable/CMAKE_VS_NsightTegra_VERSION.rst
@@ -0,0 +1,6 @@
+CMAKE_VS_NsightTegra_VERSION
+----------------------------
+
+When using a Visual Studio generator with the ``Tegra-Android``
+platform, this variable contains the version number of the
+installed NVIDIA Nsight Tegra Visual Studio Edition.
diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake
index 1c0941a..47cf76b 100644
--- a/Modules/CMakeDetermineSystem.cmake
+++ b/Modules/CMakeDetermineSystem.cmake
@@ -121,6 +121,12 @@ elseif(CMAKE_VS_WINCE_VERSION)
   set(CMAKE_SYSTEM_PROCESSOR "${MSVC_C_ARCHITECTURE_ID}")
   set(CMAKE_CROSSCOMPILING TRUE)
   set(PRESET_CMAKE_SYSTEM_NAME TRUE)
+elseif(CMAKE_VS_NsightTegra_VERSION)
+  set(CMAKE_SYSTEM_NAME      "Android")
+  set(CMAKE_SYSTEM_VERSION   "")
+  set(CMAKE_SYSTEM_PROCESSOR "")
+  set(CMAKE_CROSSCOMPILING TRUE)
+  set(PRESET_CMAKE_SYSTEM_NAME TRUE)
 else()
   set(CMAKE_SYSTEM_NAME      "${CMAKE_HOST_SYSTEM_NAME}")
   set(CMAKE_SYSTEM_VERSION   "${CMAKE_HOST_SYSTEM_VERSION}")
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index a6d1c31..35ac2e8 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -65,6 +65,18 @@ public:
       return new cmGlobalVisualStudio10Generator(
         genName, "Itanium", "CMAKE_FORCE_IA64");
       }
+
+    std::string v =
+      cmGlobalVisualStudio10Generator::GetInstalledNsightTegraVersion();
+    if(!v.empty() && strcmp(p, "Tegra-Android") == 0)
+      {
+      cmGlobalVisualStudio10Generator* ret =
+        new cmGlobalVisualStudio10Generator(genName, "Tegra-Android", "");
+      ret->NsightTegraVersion = v;
+      ret->DefaultPlatformToolset = "Default";
+      return ret;
+      }
+
     return 0;
     }
 
@@ -79,6 +91,12 @@ public:
     names.push_back(vs10generatorName);
     names.push_back(vs10generatorName + std::string(" IA64"));
     names.push_back(vs10generatorName + std::string(" Win64"));
+
+    if(!cmGlobalVisualStudio10Generator
+       ::GetInstalledNsightTegraVersion().empty())
+      {
+      names.push_back(vs10generatorName + std::string(" Tegra-Android"));
+      }
     }
 };
 
@@ -131,6 +149,11 @@ void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf)
 {
   cmGlobalVisualStudio8Generator::AddPlatformDefinitions(mf);
   this->AddVSPlatformToolsetDefinition(mf);
+  if(!this->NsightTegraVersion.empty())
+    {
+    mf->AddDefinition("CMAKE_VS_NsightTegra_VERSION",
+                      this->NsightTegraVersion.c_str());
+    }
 }
 
 //----------------------------------------------------------------------------
@@ -502,3 +525,19 @@ bool cmGlobalVisualStudio10Generator::UseFolderProperty()
 {
   return IsExpressEdition() ? false : cmGlobalGenerator::UseFolderProperty();
 }
+
+//----------------------------------------------------------------------------
+bool cmGlobalVisualStudio10Generator::IsNsightTegra() const
+{
+  return !this->NsightTegraVersion.empty();
+}
+
+//----------------------------------------------------------------------------
+std::string cmGlobalVisualStudio10Generator::GetInstalledNsightTegraVersion()
+{
+  std::string version;
+  cmSystemTools::ReadRegistryValue(
+    "HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Nsight Tegra;"
+    "Version", version, cmSystemTools::KeyWOW64_32);
+  return version;
+}
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index b4dcc7e..aa32d6f 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -65,6 +65,9 @@ public:
   /** Is the Microsoft Assembler enabled?  */
   bool IsMasmEnabled() const { return this->MasmEnabled; }
 
+  /** Generating for Nsight Tegra VS plugin?  */
+  bool IsNsightTegra() const;
+
   /** The toolset name for the target platform.  */
   const char* GetPlatformToolset() const;
 
@@ -94,6 +97,8 @@ public:
 
   virtual void FindMakeProgram(cmMakefile*);
 
+  static std::string GetInstalledNsightTegraVersion();
+
 protected:
   virtual const char* GetIDEVersion() { return "10.0"; }
 
@@ -101,6 +106,7 @@ protected:
 
   std::string GeneratorToolset;
   std::string DefaultPlatformToolset;
+  std::string NsightTegraVersion;
   bool ExpressEdition;
   bool MasmEnabled;
 
diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx
index fa134fc..b4677eb 100644
--- a/Source/cmGlobalVisualStudio11Generator.cxx
+++ b/Source/cmGlobalVisualStudio11Generator.cxx
@@ -61,6 +61,17 @@ public:
         genName, "ARM", "");
       }
 
+    std::string v =
+      cmGlobalVisualStudio11Generator::GetInstalledNsightTegraVersion();
+    if(!v.empty() && strcmp(p, "Tegra-Android") == 0)
+      {
+      cmGlobalVisualStudio11Generator* ret =
+        new cmGlobalVisualStudio11Generator(genName, "Tegra-Android", "");
+      ret->NsightTegraVersion = v;
+      ret->DefaultPlatformToolset = "Default";
+      return ret;
+      }
+
     std::set<std::string> installedSDKs =
       cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs();
 
@@ -87,6 +98,12 @@ public:
     names.push_back(vs11generatorName + std::string(" ARM"));
     names.push_back(vs11generatorName + std::string(" Win64"));
 
+    if(!cmGlobalVisualStudio11Generator
+       ::GetInstalledNsightTegraVersion().empty())
+      {
+      names.push_back(vs11generatorName + std::string(" Tegra-Android"));
+      }
+
     std::set<std::string> installedSDKs =
       cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs();
     for(std::set<std::string>::const_iterator i =
diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx
index 698624d..d0b304a 100644
--- a/Source/cmGlobalVisualStudio12Generator.cxx
+++ b/Source/cmGlobalVisualStudio12Generator.cxx
@@ -60,6 +60,18 @@ public:
       return new cmGlobalVisualStudio12Generator(
         genName, "ARM", "");
       }
+
+    std::string v =
+      cmGlobalVisualStudio12Generator::GetInstalledNsightTegraVersion();
+    if(!v.empty() && strcmp(p, "Tegra-Android") == 0)
+      {
+      cmGlobalVisualStudio12Generator* ret =
+        new cmGlobalVisualStudio12Generator(genName, "Tegra-Android", "");
+      ret->NsightTegraVersion = v;
+      ret->DefaultPlatformToolset = "Default";
+      return ret;
+      }
+
     return 0;
     }
 
@@ -74,6 +86,12 @@ public:
     names.push_back(vs12generatorName);
     names.push_back(vs12generatorName + std::string(" ARM"));
     names.push_back(vs12generatorName + std::string(" Win64"));
+
+    if(!cmGlobalVisualStudio12Generator
+       ::GetInstalledNsightTegraVersion().empty())
+      {
+      names.push_back(vs12generatorName + std::string(" Tegra-Android"));
+      }
     }
 };
 
-- 
2.0.0

>From 9ba1f28f317dba2914ce0a8b8d60a68db669d47a Mon Sep 17 00:00:00 2001
Message-Id: <9ba1f28f317dba2914ce0a8b8d60a68db669d47a.1402422416.git.brad.k...@kitware.com>
In-Reply-To: <8d18af8606007cce32aa16b57becb51f8c1fa8be.1402422416.git.brad.k...@kitware.com>
References: <8d18af8606007cce32aa16b57becb51f8c1fa8be.1402422416.git.brad.k...@kitware.com>
From: Brad King <brad.k...@kitware.com>
Date: Tue, 10 Jun 2014 11:30:28 -0400
Subject: [PATCH 3/4] VS: Detect compiler id of Nsight Tegra-Android toolchains

Teach CMakeDetermineCompilerId to recognize the Tegra-Android platform
and generate a test project for Nsight Tegra tools.  Locate the full
path to CMAKE_<LANG>_COMPILER by computing it within the test project
build environment.

Also teach CMakeFindBinUtils that this variant of the Visual Studio
generator uses UNIX-like instead of MS-like archiving and linking tools.
---
 Modules/CMakeDetermineCompilerId.cmake       | 22 +++++++++--
 Modules/CMakeFindBinUtils.cmake              |  3 +-
 Modules/CompilerId/VS-NsightTegra.vcxproj.in | 56 ++++++++++++++++++++++++++++
 3 files changed, 76 insertions(+), 5 deletions(-)
 create mode 100644 Modules/CompilerId/VS-NsightTegra.vcxproj.in

diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 025d296..16a601a 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -142,7 +142,17 @@ Id flags: ${testflags}
     set(id_platform ${CMAKE_VS_PLATFORM_NAME})
     set(id_lang "${lang}")
     set(id_cl cl.exe)
-    if(lang STREQUAL Fortran)
+    if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
+      set(v NsightTegra)
+      set(ext vcxproj)
+      if(lang STREQUAL CXX)
+        set(id_gcc g++)
+        set(id_clang clang++)
+      else()
+        set(id_gcc gcc)
+        set(id_clang clang)
+      endif()
+    elseif(lang STREQUAL Fortran)
       set(v Intel)
       set(ext vfproj)
       set(id_cl ifort.exe)
@@ -161,9 +171,13 @@ Id flags: ${testflags}
       set(id_platform ia64)
     endif()
     if(CMAKE_VS_PLATFORM_TOOLSET)
-      set(id_toolset "<PlatformToolset>${CMAKE_VS_PLATFORM_TOOLSET}</PlatformToolset>")
-      if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "Intel")
-        set(id_cl icl.exe)
+      if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
+        set(id_toolset "<NdkToolchainVersion>${CMAKE_VS_PLATFORM_TOOLSET}</NdkToolchainVersion>")
+      else()
+        set(id_toolset "<PlatformToolset>${CMAKE_VS_PLATFORM_TOOLSET}</PlatformToolset>")
+        if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "Intel")
+          set(id_cl icl.exe)
+        endif()
       endif()
     else()
       set(id_toolset "")
diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake
index 829b6ff..32205c6 100644
--- a/Modules/CMakeFindBinUtils.cmake
+++ b/Modules/CMakeFindBinUtils.cmake
@@ -35,7 +35,8 @@ if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC"
    OR "${CMAKE_Fortran_SIMULATE_ID}" STREQUAL "MSVC"
    OR "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC"
    OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC"
-   OR "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
+   OR ("${CMAKE_GENERATOR}" MATCHES "Visual Studio"
+       AND NOT CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android"))
 
   find_program(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
 
diff --git a/Modules/CompilerId/VS-NsightTegra.vcxproj.in b/Modules/CompilerId/VS-NsightTegra.vcxproj.in
new file mode 100644
index 0000000..b7389eb
--- /dev/null
+++ b/Modules/CompilerId/VS-NsightTegra.vcxproj.in
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003";>
+  <PropertyGroup Label="NsightTegraProject">
+    <NsightTegraProjectRevisionNumber>6</NsightTegraProjectRevisionNumber>
+  </PropertyGroup>
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|@id_platform@">
+      <Configuration>Debug</Configuration>
+      <Platform>@id_platform@</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{CAE07175-D007-4FC3-BFE8-47B392814159}</ProjectGuid>
+    <RootNamespace>CompilerId@id_lang@</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    @id_toolset@
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <PropertyGroup>
+    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'">.\</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'">$(Configuration)\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'">false</LinkIncremental>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@id_platform@'">
+    <ClCompile>
+      <PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+    </Link>
+    <PostBuildEvent>
+      <Command>
+if "$(ToolchainName)"=="gcc" (
+  for %%i in ($(ToolchainPrebuiltRoot)\bin\*@id_gcc@.exe) do (
+    @echo CMAKE_@id_lang@_COMPILER=%%i
+    goto :done
+    )
+)
+if "$(ToolchainName)"=="clang" (
+  for %%i in ($(ToolchainPrebuiltRoot)\bin\*@id_clang@.exe) do (
+    @echo CMAKE_@id_lang@_COMPILER=%%i
+    goto :done
+  )
+)
+:done
+</Command>
+    </PostBuildEvent>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="@id_src@" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+</Project>
-- 
2.0.0

>From 520c62ce26d4e15d53afaf3b80d968a258289b9e Mon Sep 17 00:00:00 2001
Message-Id: <520c62ce26d4e15d53afaf3b80d968a258289b9e.1402422416.git.brad.k...@kitware.com>
In-Reply-To: <8d18af8606007cce32aa16b57becb51f8c1fa8be.1402422416.git.brad.k...@kitware.com>
References: <8d18af8606007cce32aa16b57becb51f8c1fa8be.1402422416.git.brad.k...@kitware.com>
From: Brad King <brad.k...@kitware.com>
Date: Tue, 10 Jun 2014 11:33:19 -0400
Subject: [PATCH 4/4] 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).
---
 Source/cmVisualStudio10TargetGenerator.cxx | 53 ++++++++++++++++++++++++++++--
 Source/cmVisualStudio10TargetGenerator.h   |  2 ++
 2 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index aa6d00d..f400341 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -127,7 +127,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->BuildFileStream = 0;
 }
 
@@ -246,6 +247,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);
@@ -501,10 +511,26 @@ 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:
-        configType += "Utility";
+        if(this->NsightTegra)
+          {
+          // Tegra-Android platform does not understand "Utility".
+          configType += "StaticLibrary";
+          }
+        else
+          {
+          configType += "Utility";
+          }
         break;
       case cmTarget::GLOBAL_TARGET:
       case cmTarget::UNKNOWN_LIBRARY:
@@ -518,6 +544,10 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
       {
       this->WriteMSToolConfigurationValues(*i);
       }
+    else if(this->NsightTegra)
+      {
+      this->WriteNsightTegraConfigurationValues(*i);
+      }
 
     this->WriteString("</PropertyGroup>\n", 1);
     }
@@ -575,6 +605,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();
@@ -1745,6 +1788,10 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
     linkOptions.AddFlag("ImportLibrary", imLib.c_str());
     linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str());
     }
+  else if(this->NsightTegra)
+    {
+    linkOptions.AddFlag("SoName", targetNameSO.c_str());
+    }
 
   linkOptions.Parse(flags.c_str());
 
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 85926d8..db64abf 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -57,6 +57,7 @@ private:
   void WriteProjectConfigurations();
   void WriteProjectConfigurationValues();
   void WriteMSToolConfigurationValues(std::string const& config);
+  void WriteNsightTegraConfigurationValues(std::string const& config);
   void WriteSource(const char* tool, cmSourceFile const* sf,
                    const char* end = 0);
   void WriteSources(const char* tool,
@@ -117,6 +118,7 @@ private:
   std::string GUID;
   std::string Name;
   bool MSTools;
+  bool NsightTegra;
   cmGlobalVisualStudio10Generator* GlobalGenerator;
   cmGeneratedFileStream* BuildFileStream;
   cmLocalVisualStudio7Generator* LocalGenerator;
-- 
2.0.0

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to