diff options
author | Brad King <brad.king@kitware.com> | 2014-09-30 12:46:27 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-09-30 12:46:27 (GMT) |
commit | 34d035e70e3ef3f79212bd8c5b5d36250090d856 (patch) | |
tree | b53d2983bb643e26cc2872e174c09292b6c5ca5c /Source | |
parent | 026c4a5d1b3ac3297b7a205d779cfcff6f74a67a (diff) | |
parent | df84281d68a715658ce0068c0869dd80831cd4a7 (diff) | |
download | CMake-34d035e70e3ef3f79212bd8c5b5d36250090d856.zip CMake-34d035e70e3ef3f79212bd8c5b5d36250090d856.tar.gz CMake-34d035e70e3ef3f79212bd8c5b5d36250090d856.tar.bz2 |
Merge topic 'vs-nsight-tegra-generator'
df84281d Help: Add notes for topic 'vs-nsight-tegra-generator'
69e198dc VS: Generate Nsight Tegra project revision number
5365c9ac VS: Map Nsight Tegra file types in .vcxproj files
178f56a5 VS: Fix Tegra-Android platform linking of libraries by name
7115702f Tests: Add test for VS Nsight Tegra generator support
a6289499 VS: Generate ANDROID_GUI executables as app packages
c12e4699 Add 'ANDROID_API' target property to set Android Target API
9a4df52a Add 'ANDROID_GUI' target property to mark Android applications
16569abf cmTarget: Track internally whether platform is Android
ef0fd4f0 VS: Teach vcxproj generation about the Tegra-Android platform
d09b60f5 VS: Detect compiler id of Nsight Tegra-Android toolchains
2f071466 VS: Teach VS >= 10 to recognize CMAKE_SYSTEM_NAME 'Android'
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 47 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.h | 7 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 23 | ||||
-rw-r--r-- | Source/cmTarget.h | 1 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 155 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.h | 4 |
6 files changed, 232 insertions, 5 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index e947c54..d70d2af 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,25 @@ bool cmGlobalVisualStudio10Generator::UseFolderProperty() { return IsExpressEdition() ? false : cmGlobalGenerator::UseFolderProperty(); } + +//---------------------------------------------------------------------------- +bool cmGlobalVisualStudio10Generator::IsNsightTegra() const +{ + return !this->NsightTegraVersion.empty(); +} + +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio10Generator::GetNsightTegraVersion() const +{ + return this->NsightTegraVersion; +} + +//---------------------------------------------------------------------------- +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..3af7b51 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -59,6 +59,10 @@ public: /** Is the installed VS an Express edition? */ bool IsExpressEdition() const { return this->ExpressEdition; } + /** Generating for Nsight Tegra VS plugin? */ + bool IsNsightTegra() const; + std::string GetNsightTegraVersion() const; + /** The toolset name for the target platform. */ const char* GetPlatformToolset() const; @@ -106,6 +110,8 @@ public: virtual void FindMakeProgram(cmMakefile*); + static std::string GetInstalledNsightTegraVersion(); + protected: virtual void Generate(); virtual bool InitializeSystem(cmMakefile* mf); @@ -124,6 +130,7 @@ protected: std::string DefaultPlatformToolset; std::string SystemName; std::string SystemVersion; + std::string NsightTegraVersion; bool SystemIsWindowsCE; bool SystemIsWindowsPhone; bool SystemIsWindowsStore; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f4714a9..b476a27 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,12 +313,18 @@ 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"); // 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"); @@ -440,6 +447,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) { @@ -3493,7 +3504,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; } @@ -3517,7 +3531,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; } 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; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index a8357a7..26fc317 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -180,7 +180,16 @@ 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(); + 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; this->IsMissingFiles = false; @@ -312,6 +321,30 @@ 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); + if(this->NsightTegraVersion[0] >= 2) + { + // Nsight Tegra 2.0 uses project revision 8. + this->WriteString("<NsightTegraProjectRevisionNumber>" + "8" + "</NsightTegraProjectRevisionNumber>\n", 2); + // Tell newer versions to upgrade silently when loading. + this->WriteString("<NsightTegraUpgradeOnceWithoutPrompt>" + "true" + "</NsightTegraUpgradeOnceWithoutPrompt>\n", 2); + } + else + { + // Require Nsight Tegra 1.6 for JCompile support. + this->WriteString("<NsightTegraProjectRevisionNumber>" + "7" + "</NsightTegraProjectRevisionNumber>\n", 2); + } + this->WriteString("</PropertyGroup>\n", 1); + } + this->WriteProjectConfigurations(); this->WriteString("<PropertyGroup Label=\"Globals\">\n", 1); this->WriteString("<ProjectGUID>", 2); @@ -605,11 +638,28 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() configType += "StaticLibrary"; break; case cmTarget::EXECUTABLE: - configType += "Application"; + if(this->NsightTegra && + !this->Target->GetPropertyAsBool("ANDROID_GUI")) + { + // 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 +672,10 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() { this->WriteMSToolConfigurationValues(*i); } + else if(this->NsightTegra) + { + this->WriteNsightTegraConfigurationValues(*i); + } this->WriteString("</PropertyGroup>\n", 1); } @@ -683,6 +737,25 @@ 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); + if(const char* api = this->Target->GetProperty("ANDROID_API")) + { + this->WriteString("<AndroidTargetAPI>", 2); + (*this->BuildFileStream ) << + "android-" << cmVS10EscapeXML(api) << "</AndroidTargetAPI>\n"; + } +} + void cmVisualStudio10TargetGenerator::WriteCustomCommands() { this->SourcesVisited.clear(); @@ -1150,6 +1223,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() || @@ -1974,6 +2069,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<cmSourceFile const*> extraSources; + this->GeneratorTarget->GetExtraSources(extraSources, ""); + for(std::vector<cmSourceFile const*>::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("<AntBuild>\n", 2); + this->WriteString("<AntBuildPath>", 3); + this->ConvertToWindowsSlash(antBuildPath); + (*this->BuildFileStream) << + cmVS10EscapeXML(antBuildPath) << "</AntBuildPath>\n"; + } + + { + std::string manifest_xml = rootDir + "/AndroidManifest.xml"; + this->ConvertToWindowsSlash(manifest_xml); + this->WriteString("<AndroidManifestLocation>", 3); + (*this->BuildFileStream) << + cmVS10EscapeXML(manifest_xml) << "</AndroidManifestLocation>\n"; + } + + this->WriteString("</AntBuild>\n", 2); +} + //---------------------------------------------------------------------------- bool cmVisualStudio10TargetGenerator::ComputeLinkOptions() { @@ -2198,6 +2337,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()); @@ -2347,6 +2490,12 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() this->WriteLinkOptions(*i); // output lib flags <Lib></Lib> this->WriteLibOptions(*i); + if(this->NsightTegra && + this->Target->GetType() == cmTarget::EXECUTABLE && + this->Target->GetPropertyAsBool("ANDROID_GUI")) + { + this->WriteAntBuildOptions(*i); + } this->WriteString("</ItemDefinitionGroup>\n", 1); } } diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index d6db18a..a02dfa8 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, @@ -96,6 +97,7 @@ private: void WriteLinkOptions(std::string const& config); void WriteMidlOptions(std::string const& config, std::vector<std::string> const & includes); + void WriteAntBuildOptions(std::string const& config); void OutputLinkIncremental(std::string const& configName); void WriteCustomRule(cmSourceFile const* source, cmCustomCommand const & command); @@ -139,6 +141,8 @@ private: std::string GUID; std::string Name; bool MSTools; + bool NsightTegra; + int NsightTegraVersion[4]; bool TargetCompileAsWinRT; cmGlobalVisualStudio10Generator* GlobalGenerator; cmGeneratedFileStream* BuildFileStream; |