From 2f071466ebd4e3a416a523ac5f17c84543ff8b3c Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 18 Jul 2014 11:12:11 -0400 Subject: VS: Teach VS >= 10 to recognize CMAKE_SYSTEM_NAME 'Android' When CMAKE_SYSTEM_NAME is 'Android', check for an installation of 'NVIDIA Nsight Tegra Visual Studio Edition' and generate .vcxproj files for the "Tegra-Android" platform. Also make the installed version available in a CMAKE_VS_NsightTegra_VERSION variable. --- Help/manual/cmake-variables.7.rst | 1 + Help/variable/CMAKE_VS_NsightTegra_VERSION.rst | 7 +++++ Source/cmGlobalVisualStudio10Generator.cxx | 41 ++++++++++++++++++++++++++ Source/cmGlobalVisualStudio10Generator.h | 6 ++++ 4 files changed, 55 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 b00c16e..097eba3 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -74,6 +74,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_NAME /variable/CMAKE_VS_PLATFORM_TOOLSET /variable/CMAKE_XCODE_PLATFORM_TOOLSET diff --git a/Help/variable/CMAKE_VS_NsightTegra_VERSION.rst b/Help/variable/CMAKE_VS_NsightTegra_VERSION.rst new file mode 100644 index 0000000..386c3a9 --- /dev/null +++ b/Help/variable/CMAKE_VS_NsightTegra_VERSION.rst @@ -0,0 +1,7 @@ +CMAKE_VS_NsightTegra_VERSION +---------------------------- + +When using a Visual Studio generator with the +:variable:`CMAKE_SYSTEM_NAME` variable set to ``Android``, +this variable contains the version number of the +installed NVIDIA Nsight Tegra Visual Studio Edition. diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index e947c54..21d1f34 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -198,6 +198,31 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf) return false; } } + else if(this->SystemName == "Android") + { + if(this->DefaultPlatformName != "Win32") + { + cmOStringStream e; + e << "CMAKE_SYSTEM_NAME is 'Android' but CMAKE_GENERATOR " + << "specifies a platform too: '" << this->GetName() << "'"; + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + return false; + } + std::string v = this->GetInstalledNsightTegraVersion(); + if(v.empty()) + { + mf->IssueMessage(cmake::FATAL_ERROR, + "CMAKE_SYSTEM_NAME is 'Android' but " + "'NVIDIA Nsight Tegra Visual Studio Edition' " + "is not installed."); + return false; + } + this->DefaultPlatformName = "Tegra-Android"; + this->DefaultPlatformToolset = "Default"; + this->NsightTegraVersion = v; + mf->AddDefinition("CMAKE_VS_NsightTegra_VERSION", v.c_str()); + } + return true; } @@ -587,3 +612,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 c02d204..1df98e3 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -59,6 +59,9 @@ public: /** Is the installed VS an Express edition? */ bool IsExpressEdition() const { return this->ExpressEdition; } + /** Generating for Nsight Tegra VS plugin? */ + bool IsNsightTegra() const; + /** The toolset name for the target platform. */ const char* GetPlatformToolset() const; @@ -106,6 +109,8 @@ public: virtual void FindMakeProgram(cmMakefile*); + static std::string GetInstalledNsightTegraVersion(); + protected: virtual void Generate(); virtual bool InitializeSystem(cmMakefile* mf); @@ -124,6 +129,7 @@ protected: std::string DefaultPlatformToolset; std::string SystemName; std::string SystemVersion; + std::string NsightTegraVersion; bool SystemIsWindowsCE; bool SystemIsWindowsPhone; bool SystemIsWindowsStore; -- cgit v0.12 From d09b60f563902bd2197d88a3e83b119c09e62428 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 10 Jun 2014 11:30:28 -0400 Subject: 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__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 e00f22a..a7b5760 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 "${CMAKE_VS_PLATFORM_TOOLSET}") - if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "Intel") - set(id_cl icl.exe) + if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android") + set(id_toolset "${CMAKE_VS_PLATFORM_TOOLSET}") + else() + set(id_toolset "${CMAKE_VS_PLATFORM_TOOLSET}") + 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 dda28bd..e0ba131 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 @@ + + + + 6 + + + + Debug + @id_platform@ + + + + {CAE07175-D007-4FC3-BFE8-47B392814159} + CompilerId@id_lang@ + + + + StaticLibrary + @id_toolset@ + + + + <_ProjectFileVersion>10.0.30319.1 + .\ + $(Configuration)\ + false + + + + %(PreprocessorDefinitions) + + + + + +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 + + + + + + + + -- cgit v0.12 From ef0fd4f0ced850edd049bb05b527c3bd234f441f Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 10 Jun 2014 11:33:19 -0400 Subject: 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 a13cbd2..15d0980 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -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("\n", 1); + this->WriteString("" + "6" + "\n", 2); + this->WriteString("\n", 1); + } + this->WriteProjectConfigurations(); this->WriteString("\n", 1); this->WriteString("", 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("\n", 1); } @@ -683,6 +713,19 @@ void cmVisualStudio10TargetGenerator } } +//---------------------------------------------------------------------------- +void cmVisualStudio10TargetGenerator +::WriteNsightTegraConfigurationValues(std::string const&) +{ + cmGlobalVisualStudio10Generator* gg = + static_cast(this->GlobalGenerator); + const char* toolset = gg->GetPlatformToolset(); + std::string ntv = ""; + ntv += toolset? toolset : "Default"; + ntv += "\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()); diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index d6db18a..8887d14 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -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; -- cgit v0.12 From 16569abfa83ce231b1270282f03aae0b4542c42d Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 24 Jul 2014 15:03:04 -0400 Subject: cmTarget: Track internally whether platform is Android Add an IsAndroid member to save whether CMAKE_SYSTEM_NAME is "Android". --- Source/cmTarget.cxx | 6 ++++++ Source/cmTarget.h | 1 + 2 files changed, 7 insertions(+) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index acae0b3..80c0020 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -257,6 +257,7 @@ cmTarget::cmTarget() #endif this->HaveInstallRule = false; this->DLLPlatform = false; + this->IsAndroid = false; this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; @@ -312,6 +313,11 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW")); + // Check whether we are targeting an Android platform. + this->IsAndroid = + strcmp(this->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME"), + "Android") == 0; + // Check whether we are targeting an Apple platform. this->IsApple = this->Makefile->IsOn("APPLE"); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 333e2ae..a3ecca0 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -755,6 +755,7 @@ private: mutable cmPropertyMap Properties; LinkLibraryVectorType OriginalLinkLibraries; bool DLLPlatform; + bool IsAndroid; bool IsApple; bool IsImportedTarget; mutable bool DebugIncludesDone; -- cgit v0.12 From 9a4df52aa1f6736c2eceebd109240441bc3a4d6e Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 24 Jul 2014 14:49:56 -0400 Subject: Add 'ANDROID_GUI' target property to mark Android applications Also add a 'CMAKE_ANDROID_GUI' variable to set the property default so a project can easily make all executables Android applications. An Android application executable file has the same extension as a shared library (.so). --- Help/manual/cmake-properties.7.rst | 1 + Help/manual/cmake-variables.7.rst | 1 + Help/prop_tgt/ANDROID_GUI.rst | 9 +++++++++ Help/variable/CMAKE_ANDROID_GUI.rst | 5 +++++ Source/cmTarget.cxx | 16 ++++++++++++++-- 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 Help/prop_tgt/ANDROID_GUI.rst create mode 100644 Help/variable/CMAKE_ANDROID_GUI.rst diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index d28229a..d17ea15 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -79,6 +79,7 @@ Properties on Targets :maxdepth: 1 /prop_tgt/ALIASED_TARGET + /prop_tgt/ANDROID_GUI /prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG /prop_tgt/ARCHIVE_OUTPUT_DIRECTORY /prop_tgt/ARCHIVE_OUTPUT_NAME_CONFIG diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 097eba3..8017b43 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -204,6 +204,7 @@ Variables that Control the Build .. toctree:: :maxdepth: 1 + /variable/CMAKE_ANDROID_GUI /variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY /variable/CMAKE_AUTOMOC_MOC_OPTIONS /variable/CMAKE_AUTOMOC diff --git a/Help/prop_tgt/ANDROID_GUI.rst b/Help/prop_tgt/ANDROID_GUI.rst new file mode 100644 index 0000000..90d2428 --- /dev/null +++ b/Help/prop_tgt/ANDROID_GUI.rst @@ -0,0 +1,9 @@ +ANDROID_GUI +----------- + +Build an executable as an application package on Android. + +When this property is set to true the executable when built for Android +will be created as an application package. This property is initialized +by the value of the :variable:`CMAKE_ANDROID_GUI` variable if it is set +when a target is created. diff --git a/Help/variable/CMAKE_ANDROID_GUI.rst b/Help/variable/CMAKE_ANDROID_GUI.rst new file mode 100644 index 0000000..1755375 --- /dev/null +++ b/Help/variable/CMAKE_ANDROID_GUI.rst @@ -0,0 +1,5 @@ +CMAKE_ANDROID_GUI +----------------- + +Default value for the :prop_tgt:`ANDROID_GUI` target property of +executables. See that target property for additional information. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 80c0020..1e2f75c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -446,6 +446,10 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("VISIBILITY_INLINES_HIDDEN", 0); } + if(this->TargetTypeValue == cmTarget::EXECUTABLE) + { + this->SetPropertyDefault("ANDROID_GUI", 0); + } if(this->TargetTypeValue == cmTarget::SHARED_LIBRARY || this->TargetTypeValue == cmTarget::MODULE_LIBRARY) { @@ -3504,7 +3508,10 @@ const char* cmTarget::GetSuffixVariableInternal(bool implib) const case cmTarget::EXECUTABLE: return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX" - : "CMAKE_EXECUTABLE_SUFFIX"); + // Android GUI application packages store the native + // binary as a shared library. + : (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI")? + "CMAKE_SHARED_LIBRARY_SUFFIX" : "CMAKE_EXECUTABLE_SUFFIX")); default: break; } @@ -3528,7 +3535,12 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) const ? "CMAKE_IMPORT_LIBRARY_PREFIX" : "CMAKE_SHARED_MODULE_PREFIX"); case cmTarget::EXECUTABLE: - return (implib? "CMAKE_IMPORT_LIBRARY_PREFIX" : ""); + return (implib + ? "CMAKE_IMPORT_LIBRARY_PREFIX" + // Android GUI application packages store the native + // binary as a shared library. + : (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI")? + "CMAKE_SHARED_LIBRARY_PREFIX" : "")); default: break; } -- cgit v0.12 From c12e46991e02c2ea59864512d2c1fb7c2b4b0f9d Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 2 Sep 2014 13:53:26 -0400 Subject: Add 'ANDROID_API' target property to set Android Target API Also add a 'CMAKE_ANDROID_API' variable to set the property default. --- Help/manual/cmake-properties.7.rst | 1 + Help/manual/cmake-variables.7.rst | 1 + Help/prop_tgt/ANDROID_API.rst | 7 +++++++ Help/variable/CMAKE_ANDROID_API.rst | 5 +++++ Source/cmTarget.cxx | 1 + Source/cmVisualStudio10TargetGenerator.cxx | 6 ++++++ 6 files changed, 21 insertions(+) create mode 100644 Help/prop_tgt/ANDROID_API.rst create mode 100644 Help/variable/CMAKE_ANDROID_API.rst diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index d17ea15..38bcd04 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -79,6 +79,7 @@ Properties on Targets :maxdepth: 1 /prop_tgt/ALIASED_TARGET + /prop_tgt/ANDROID_API /prop_tgt/ANDROID_GUI /prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG /prop_tgt/ARCHIVE_OUTPUT_DIRECTORY diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 8017b43..3f92ec5 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -204,6 +204,7 @@ Variables that Control the Build .. toctree:: :maxdepth: 1 + /variable/CMAKE_ANDROID_API /variable/CMAKE_ANDROID_GUI /variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY /variable/CMAKE_AUTOMOC_MOC_OPTIONS diff --git a/Help/prop_tgt/ANDROID_API.rst b/Help/prop_tgt/ANDROID_API.rst new file mode 100644 index 0000000..714ad58 --- /dev/null +++ b/Help/prop_tgt/ANDROID_API.rst @@ -0,0 +1,7 @@ +ANDROID_API +----------- + +Set the Android Target API version (e.g. ``15``). The version number +must be a positive decimal integer. This property is initialized by +the value of the :variable:`CMAKE_ANDROID_API` variable if it is set +when a target is created. diff --git a/Help/variable/CMAKE_ANDROID_API.rst b/Help/variable/CMAKE_ANDROID_API.rst new file mode 100644 index 0000000..c8264e0 --- /dev/null +++ b/Help/variable/CMAKE_ANDROID_API.rst @@ -0,0 +1,5 @@ +CMAKE_ANDROID_API +----------------- + +Default value for the :prop_tgt:`ANDROID_API` target property. +See that target property for additional information. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1e2f75c..85bf087 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -324,6 +324,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) // Setup default property values. if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) { + this->SetPropertyDefault("ANDROID_API", 0); this->SetPropertyDefault("INSTALL_NAME_DIR", 0); this->SetPropertyDefault("INSTALL_RPATH", ""); this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF"); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 15d0980..bfabb21 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -724,6 +724,12 @@ void cmVisualStudio10TargetGenerator ntv += toolset? toolset : "Default"; ntv += "\n"; this->WriteString(ntv.c_str(), 2); + if(const char* api = this->Target->GetProperty("ANDROID_API")) + { + this->WriteString("", 2); + (*this->BuildFileStream ) << + "android-" << cmVS10EscapeXML(api) << "\n"; + } } void cmVisualStudio10TargetGenerator::WriteCustomCommands() -- cgit v0.12 From a62894998f59d87e092a664ea50e33ff8dbb180c Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 2 Sep 2014 14:33:17 -0400 Subject: VS: Generate ANDROID_GUI executables as app packages When an executable is marked with ANDROID_GUI, generate an AntBuild step in the .vcxproj file and point it at the directory found to contain AndroidManifest.xml. Assume it also contains build.xml. --- Source/cmVisualStudio10TargetGenerator.cxx | 53 +++++++++++++++++++++++++++++- Source/cmVisualStudio10TargetGenerator.h | 1 + 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index bfabb21..b0c84e3 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -615,7 +615,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() configType += "StaticLibrary"; break; case cmTarget::EXECUTABLE: - if(this->NsightTegra) + if(this->NsightTegra && + !this->Target->GetPropertyAsBool("ANDROID_GUI")) { // Android executables are .so too. configType += "DynamicLibrary"; @@ -2019,6 +2020,50 @@ cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config) } } + +//---------------------------------------------------------------------------- +void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( + std::string const&) +{ + // Look through the sources for AndroidManifest.xml and use + // its location as the root source directory. + std::string rootDir = this->Makefile->GetCurrentDirectory(); + { + std::vector extraSources; + this->GeneratorTarget->GetExtraSources(extraSources, ""); + for(std::vector::const_iterator si = + extraSources.begin(); si != extraSources.end(); ++si) + { + if("androidmanifest.xml" == cmSystemTools::LowerCase( + (*si)->GetLocation().GetName())) + { + rootDir = (*si)->GetLocation().GetDirectory(); + break; + } + } + } + + // Tell MSBuild to launch Ant. + { + std::string antBuildPath = rootDir; + this->WriteString("\n", 2); + this->WriteString("", 3); + this->ConvertToWindowsSlash(antBuildPath); + (*this->BuildFileStream) << + cmVS10EscapeXML(antBuildPath) << "\n"; + } + + { + std::string manifest_xml = rootDir + "/AndroidManifest.xml"; + this->ConvertToWindowsSlash(manifest_xml); + this->WriteString("", 3); + (*this->BuildFileStream) << + cmVS10EscapeXML(manifest_xml) << "\n"; + } + + this->WriteString("\n", 2); +} + //---------------------------------------------------------------------------- bool cmVisualStudio10TargetGenerator::ComputeLinkOptions() { @@ -2390,6 +2435,12 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() this->WriteLinkOptions(*i); // output lib flags this->WriteLibOptions(*i); + if(this->NsightTegra && + this->Target->GetType() == cmTarget::EXECUTABLE && + this->Target->GetPropertyAsBool("ANDROID_GUI")) + { + this->WriteAntBuildOptions(*i); + } this->WriteString("\n", 1); } } diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 8887d14..36155f9 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -97,6 +97,7 @@ private: void WriteLinkOptions(std::string const& config); void WriteMidlOptions(std::string const& config, std::vector const & includes); + void WriteAntBuildOptions(std::string const& config); void OutputLinkIncremental(std::string const& configName); void WriteCustomRule(cmSourceFile const* source, cmCustomCommand const & command); -- cgit v0.12 From 7115702f1b116fcf9b82ab197bab7426db10c610 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 16 Sep 2014 09:48:38 -0400 Subject: Tests: Add test for VS Nsight Tegra generator support Create a VSNsightTegra test based on the "two-libs" example from the Android NDK. Add it whenever testing on a machine with VS 11 or 12 and the NVIDIA Nsight Tegra Visual Studio Edition installed. Exclude it when there is a space in the path to the source or build tree because the tools do not seem to support it. --- Tests/CMakeLists.txt | 28 ++++++++++++- Tests/VSNsightTegra/AndroidManifest.xml | 16 ++++++++ Tests/VSNsightTegra/CMakeLists.txt | 38 ++++++++++++++++++ Tests/VSNsightTegra/build.xml | 4 ++ Tests/VSNsightTegra/jni/first.c | 22 +++++++++++ Tests/VSNsightTegra/jni/first.h | 22 +++++++++++ Tests/VSNsightTegra/jni/second.c | 27 +++++++++++++ Tests/VSNsightTegra/res/values/strings.xml | 4 ++ .../src/com/example/twolibs/TwoLibs.java | 46 ++++++++++++++++++++++ 9 files changed, 206 insertions(+), 1 deletion(-) create mode 100644 Tests/VSNsightTegra/AndroidManifest.xml create mode 100644 Tests/VSNsightTegra/CMakeLists.txt create mode 100644 Tests/VSNsightTegra/build.xml create mode 100644 Tests/VSNsightTegra/jni/first.c create mode 100644 Tests/VSNsightTegra/jni/first.h create mode 100644 Tests/VSNsightTegra/jni/second.c create mode 100644 Tests/VSNsightTegra/res/values/strings.xml create mode 100644 Tests/VSNsightTegra/src/com/example/twolibs/TwoLibs.java diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 2b70f56..acb6b86 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1781,13 +1781,15 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release endif() if(WIN32) + set(reg_vs10 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]") set(reg_vs11 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;InstallDir]") set(reg_vs12 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\12.0;InstallDir]") set(reg_ws80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]") set(reg_ws81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.1;InstallationFolder]") set(reg_wp80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.0;InstallationFolder]") set(reg_wp81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.1;InstallationFolder]") - foreach(reg vs11 vs12 ws80 ws81 wp80 wp81) + set(reg_tegra "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Nsight Tegra;sdkRoot]") + foreach(reg vs10 vs11 vs12 ws80 ws81 wp80 wp81 tegra) get_filename_component(r "${reg_${reg}}" ABSOLUTE) if(IS_DIRECTORY "${r}") set(${reg} 1) @@ -1833,6 +1835,30 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release endif() endif() + if(tegra AND NOT "${CMake_SOURCE_DIR};${CMake_BINARY_DIR}" MATCHES " ") + macro(add_test_VSNsightTegra name generator) + add_test(NAME VSNsightTegra.${name} COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VSNsightTegra" + "${CMake_BINARY_DIR}/Tests/VSNsightTegra/${name}" + --build-generator "${generator}" + --build-project VSNsightTegra + --build-config $ + --build-options -DCMAKE_SYSTEM_NAME=Android + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSNsightTegra/${name}") + endmacro() + if(vs10) + add_test_VSNsightTegra(vs10 "Visual Studio 10 2010") + endif() + if(vs11) + add_test_VSNsightTegra(vs11 "Visual Studio 11 2012") + endif() + if(vs12) + add_test_VSNsightTegra(vs12 "Visual Studio 12 2013") + endif() + endif() + if (APPLE) if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(BundleTestInstallDir diff --git a/Tests/VSNsightTegra/AndroidManifest.xml b/Tests/VSNsightTegra/AndroidManifest.xml new file mode 100644 index 0000000..951e8f3 --- /dev/null +++ b/Tests/VSNsightTegra/AndroidManifest.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/Tests/VSNsightTegra/CMakeLists.txt b/Tests/VSNsightTegra/CMakeLists.txt new file mode 100644 index 0000000..e011cac --- /dev/null +++ b/Tests/VSNsightTegra/CMakeLists.txt @@ -0,0 +1,38 @@ +cmake_minimum_required(VERSION 3.0) +project(VSNsightTegra C CXX) + +set(CMAKE_ANDROID_API 15) +set(CMAKE_ANDROID_GUI 1) + +set(FIRST_C_FILES + jni/first.c + jni/first.h + ) + +source_group(jni FILES ${FIRST_C_FILES}) +add_library(twolib-first ${FIRST_C_FILES}) + +set(SECOND_C_FILES + jni/second.c + ) +set(SECOND_JAVA_FILES + src/com/example/twolibs/TwoLibs.java + ) +set(SECOND_RES_FILES + res/values/strings.xml + ) +set(SECOND_ANDROID_FILES + AndroidManifest.xml + ) + +source_group(jni FILES ${SECOND_C_FILES}) +source_group(res\\values FILES ${SECOND_RES_FILES}) +source_group(src\\com\\example\\twolibs FILES ${SECOND_JAVA_FILES}) +add_executable(twolib-second + ${SECOND_C_FILES} + ${SECOND_JAVA_FILES} + ${SECOND_RES_FILES} + ${SECOND_ANDROID_FILES} + ) +target_include_directories(twolib-second PUBLIC jni) +target_link_libraries(twolib-second twolib-first) diff --git a/Tests/VSNsightTegra/build.xml b/Tests/VSNsightTegra/build.xml new file mode 100644 index 0000000..17a2cc0 --- /dev/null +++ b/Tests/VSNsightTegra/build.xml @@ -0,0 +1,4 @@ + + + + diff --git a/Tests/VSNsightTegra/jni/first.c b/Tests/VSNsightTegra/jni/first.c new file mode 100644 index 0000000..f09e376 --- /dev/null +++ b/Tests/VSNsightTegra/jni/first.c @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#include "first.h" + +int first(int x, int y) +{ + return x + y; +} diff --git a/Tests/VSNsightTegra/jni/first.h b/Tests/VSNsightTegra/jni/first.h new file mode 100644 index 0000000..d893480 --- /dev/null +++ b/Tests/VSNsightTegra/jni/first.h @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef FIRST_H +#define FIRST_H + +extern int first(int x, int y); + +#endif /* FIRST_H */ diff --git a/Tests/VSNsightTegra/jni/second.c b/Tests/VSNsightTegra/jni/second.c new file mode 100644 index 0000000..4631848 --- /dev/null +++ b/Tests/VSNsightTegra/jni/second.c @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#include "first.h" +#include + +jint +Java_com_example_twolibs_TwoLibs_add( JNIEnv* env, + jobject this, + jint x, + jint y ) +{ + return first(x, y); +} diff --git a/Tests/VSNsightTegra/res/values/strings.xml b/Tests/VSNsightTegra/res/values/strings.xml new file mode 100644 index 0000000..858cdb4 --- /dev/null +++ b/Tests/VSNsightTegra/res/values/strings.xml @@ -0,0 +1,4 @@ + + + TwoLibs + diff --git a/Tests/VSNsightTegra/src/com/example/twolibs/TwoLibs.java b/Tests/VSNsightTegra/src/com/example/twolibs/TwoLibs.java new file mode 100644 index 0000000..ef9da01 --- /dev/null +++ b/Tests/VSNsightTegra/src/com/example/twolibs/TwoLibs.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.twolibs; + +import android.app.Activity; +import android.widget.TextView; +import android.os.Bundle; + +public class TwoLibs extends Activity +{ + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + + TextView tv = new TextView(this); + int x = 1000; + int y = 42; + + // here, we dynamically load the library at runtime + // before calling the native method. + // + System.loadLibrary("twolib-second"); + + int z = add(x, y); + + tv.setText( "The sum of " + x + " and " + y + " is " + z ); + setContentView(tv); + } + + public native int add(int x, int y); +} -- cgit v0.12 From 178f56a57996651a4f8c2a20271f1e2c999279d2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 19 Sep 2014 10:11:36 -0400 Subject: VS: Fix Tegra-Android platform linking of libraries by name Nsight Tegra Visual Studio Edition handles prefixing of library names with '-l' automatically, so teach the generator not to do so. Reported-by: Mourad Boufarguine --- Modules/Platform/Android.cmake | 6 ++++++ Tests/VSNsightTegra/CMakeLists.txt | 1 + 2 files changed, 7 insertions(+) diff --git a/Modules/Platform/Android.cmake b/Modules/Platform/Android.cmake index e6d4fcf..1bdad04 100644 --- a/Modules/Platform/Android.cmake +++ b/Modules/Platform/Android.cmake @@ -7,3 +7,9 @@ set(CMAKE_PLATFORM_NO_VERSIONED_SONAME 1) # Android reportedly ignores RPATH, and we cannot predict the install # location anyway. set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") + +# Nsight Tegra Visual Studio Edition takes care of +# prefixing library names with '-l'. +if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android") + set(CMAKE_LINK_LIBRARY_FLAG "") +endif() diff --git a/Tests/VSNsightTegra/CMakeLists.txt b/Tests/VSNsightTegra/CMakeLists.txt index e011cac..570733b 100644 --- a/Tests/VSNsightTegra/CMakeLists.txt +++ b/Tests/VSNsightTegra/CMakeLists.txt @@ -36,3 +36,4 @@ add_executable(twolib-second ) target_include_directories(twolib-second PUBLIC jni) target_link_libraries(twolib-second twolib-first) +target_link_libraries(twolib-second m) # test linking to library by name -- cgit v0.12 From 5365c9ac377ab6f579a1af32c4bfbec798417efb Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 24 Sep 2014 14:27:18 -0400 Subject: VS: Map Nsight Tegra file types in .vcxproj files Map ".java" to JCompile, ".asm" and ".s" to ClCompile, and a few Android-specific source file names to AndroidBuild. This allows Nsight Tegra 1.6 and above to check up-to-dateness of such sources. Bump NsightTegraProjectRevisionNumber to 7 to allow these fields. --- Source/cmVisualStudio10TargetGenerator.cxx | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index b0c84e3..b42bf90 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -317,7 +317,7 @@ void cmVisualStudio10TargetGenerator::Generate() { this->WriteString("\n", 1); this->WriteString("" - "6" + "7" "\n", 2); this->WriteString("\n", 1); } @@ -1200,6 +1200,28 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf) { tool = "XML"; } + if(this->NsightTegra) + { + // Nsight Tegra needs specific file types to check up-to-dateness. + std::string name = + cmSystemTools::LowerCase(sf->GetLocation().GetName()); + if(name == "androidmanifest.xml" || + name == "build.xml" || + name == "proguard.cfg" || + name == "proguard-project.txt" || + ext == "properties") + { + tool = "AndroidBuild"; + } + else if(ext == "java") + { + tool = "JCompile"; + } + else if(ext == "asm" || ext == "s") + { + tool = "ClCompile"; + } + } std::string deployContent; if(this->GlobalGenerator->TargetsWindowsPhone() || -- cgit v0.12 From 69e198dc3fd0e0d16a7b4fe5bcda4c6e1e77ea2f Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 26 Sep 2014 14:57:30 -0400 Subject: VS: Generate Nsight Tegra project revision number Nsight Tegra 2.0 will be revision '8'. Generate this revision number and add a NsightTegraUpgradeOnceWithoutPrompt element to tell newer versions not to prompt when upgrading the generated project file. --- Source/cmGlobalVisualStudio10Generator.cxx | 6 ++++++ Source/cmGlobalVisualStudio10Generator.h | 1 + Source/cmVisualStudio10TargetGenerator.cxx | 29 ++++++++++++++++++++++++++--- Source/cmVisualStudio10TargetGenerator.h | 1 + 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 21d1f34..d70d2af 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -620,6 +620,12 @@ bool cmGlobalVisualStudio10Generator::IsNsightTegra() const } //---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio10Generator::GetNsightTegraVersion() const +{ + return this->NsightTegraVersion; +} + +//---------------------------------------------------------------------------- std::string cmGlobalVisualStudio10Generator::GetInstalledNsightTegraVersion() { std::string version; diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 1df98e3..3af7b51 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -61,6 +61,7 @@ public: /** Generating for Nsight Tegra VS plugin? */ bool IsNsightTegra() const; + std::string GetNsightTegraVersion() const; /** The toolset name for the target platform. */ const char* GetPlatformToolset() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index b42bf90..8ac12df 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -181,6 +181,14 @@ cmVisualStudio10TargetGenerator(cmTarget* target, this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str()); this->Platform = gg->GetPlatformName(); this->NsightTegra = gg->IsNsightTegra(); + for(int i = + sscanf(gg->GetNsightTegraVersion().c_str(), "%u.%u.%u.%u", + &this->NsightTegraVersion[0], &this->NsightTegraVersion[1], + &this->NsightTegraVersion[2], &this->NsightTegraVersion[3]); + i < 4; ++i) + { + this->NsightTegraVersion[i] = 0; + } this->MSTools = !this->NsightTegra; this->TargetCompileAsWinRT = false; this->BuildFileStream = 0; @@ -316,9 +324,24 @@ void cmVisualStudio10TargetGenerator::Generate() if(this->NsightTegra) { this->WriteString("\n", 1); - this->WriteString("" - "7" - "\n", 2); + if(this->NsightTegraVersion[0] >= 2) + { + // Nsight Tegra 2.0 uses project revision 8. + this->WriteString("" + "8" + "\n", 2); + // Tell newer versions to upgrade silently when loading. + this->WriteString("" + "true" + "\n", 2); + } + else + { + // Require Nsight Tegra 1.6 for JCompile support. + this->WriteString("" + "7" + "\n", 2); + } this->WriteString("\n", 1); } diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 36155f9..a02dfa8 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -142,6 +142,7 @@ private: std::string Name; bool MSTools; bool NsightTegra; + int NsightTegraVersion[4]; bool TargetCompileAsWinRT; cmGlobalVisualStudio10Generator* GlobalGenerator; cmGeneratedFileStream* BuildFileStream; -- cgit v0.12 From df84281d68a715658ce0068c0869dd80831cd4a7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 22 Sep 2014 09:14:13 -0400 Subject: Help: Add notes for topic 'vs-nsight-tegra-generator' --- Help/release/dev/vs-nsight-tegra-generator.rst | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Help/release/dev/vs-nsight-tegra-generator.rst diff --git a/Help/release/dev/vs-nsight-tegra-generator.rst b/Help/release/dev/vs-nsight-tegra-generator.rst new file mode 100644 index 0000000..92f4236 --- /dev/null +++ b/Help/release/dev/vs-nsight-tegra-generator.rst @@ -0,0 +1,8 @@ +vs-nsight-tegra-generator +------------------------- + +* Generators for Visual Studio 10 (2010) and above learned to generate + projects for NVIDIA Nsight Tegra Visual Studio Edition. One may set + the :variable:`CMAKE_SYSTEM_NAME` variable to ``Android`` on the + :manual:`cmake(1)` command-line or in a :variable:`CMAKE_TOOLCHAIN_FILE` + to activate this platform. -- cgit v0.12