diff options
author | Brad King <brad.king@kitware.com> | 2013-11-13 14:27:51 -0500 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-11-18 08:26:24 -0500 |
commit | 5f5c92b9a2c2f9c780c08e23231b93af71f175bd (patch) | |
tree | d9c078f01baba2b21b8aacff0679921d6cf533b0 | |
parent | 4ac75fdfe6e7a91f3beea037d13b1f4c8c8b80ed (diff) | |
download | cmake-5f5c92b9a2c2f9c780c08e23231b93af71f175bd.tar.gz |
VS: Add internal APIs to find MSBuild, devenv/VCExpress, and msdev
Teach the VS generators to compute the locations of these tools directly
from registry entries. Add internal APIs to get the locations on demand.
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 45 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.h | 7 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio6Generator.cxx | 28 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio6Generator.h | 4 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.cxx | 28 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.h | 5 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio8Generator.cxx | 20 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio8Generator.h | 2 |
8 files changed, 139 insertions, 0 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 7be10b16bf..d4d67d06f9 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -98,6 +98,7 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\10.0\\Setup\\VC;" "ProductDir", vc10Express, cmSystemTools::KeyWOW64_32); this->MasmEnabled = false; + this->MSBuildCommandInitialized = false; } //---------------------------------------------------------------------------- @@ -255,7 +256,51 @@ std::string cmGlobalVisualStudio10Generator::GetUserMacrosRegKeyBase() return "Software\\Microsoft\\VisualStudio\\10.0\\vsmacros"; } +//---------------------------------------------------------------------------- +std::string const& cmGlobalVisualStudio10Generator::GetMSBuildCommand() +{ + if(!this->MSBuildCommandInitialized) + { + this->MSBuildCommandInitialized = true; + this->MSBuildCommand = this->FindMSBuildCommand(); + } + return this->MSBuildCommand; +} + +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio10Generator::FindMSBuildCommand() +{ + std::string msbuild; + std::string mskey = + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\"; + mskey += this->GetToolsVersion(); + mskey += ";MSBuildToolsPath"; + if(cmSystemTools::ReadRegistryValue(mskey.c_str(), msbuild, + cmSystemTools::KeyWOW64_32)) + { + cmSystemTools::ConvertToUnixSlashes(msbuild); + msbuild += "/"; + } + msbuild += "MSBuild.exe"; + return msbuild; +} +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio10Generator::FindDevEnvCommand() +{ + if(this->ExpressEdition) + { + // Visual Studio Express >= 10 do not have "devenv.com" or + // "VCExpress.exe" that we can use to build reliably. + // Tell the caller it needs to use MSBuild instead. + return ""; + } + // Skip over the cmGlobalVisualStudio8Generator implementation because + // we expect a real devenv and do not want to look for VCExpress. + return this->cmGlobalVisualStudio71Generator::FindDevEnvCommand(); +} + +//---------------------------------------------------------------------------- void cmGlobalVisualStudio10Generator::GenerateBuildCommand( std::vector<std::string>& makeCommand, const char* makeProgram, diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index f358e5eba0..ad0aa6d1be 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -94,6 +94,8 @@ public: protected: virtual const char* GetIDEVersion() { return "10.0"; } + std::string const& GetMSBuildCommand(); + std::string PlatformToolset; bool ExpressEdition; bool MasmEnabled; @@ -111,5 +113,10 @@ private: std::string SourceRel; }; LongestSourcePath LongestSource; + + std::string MSBuildCommand; + bool MSBuildCommandInitialized; + virtual std::string FindMSBuildCommand(); + virtual std::string FindDevEnvCommand(); }; #endif diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 612e50fd6c..51f38c2754 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -33,6 +33,7 @@ std::string GetVS6TargetName(const std::string& targetName) cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator() { this->FindMakeProgramFile = "CMakeVS6FindMake.cmake"; + this->MSDevCommandInitialized = false; } void cmGlobalVisualStudio6Generator @@ -77,6 +78,33 @@ void cmGlobalVisualStudio6Generator::GenerateConfigurations(cmMakefile* mf) } } +//---------------------------------------------------------------------------- +std::string const& cmGlobalVisualStudio6Generator::GetMSDevCommand() +{ + if(!this->MSDevCommandInitialized) + { + this->MSDevCommandInitialized = true; + this->MSDevCommand = this->FindMSDevCommand(); + } + return this->MSDevCommand; +} + +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio6Generator::FindMSDevCommand() +{ + std::string vscmd; + std::string vskey = this->GetRegistryBase() + "\\Setup;VsCommonDir"; + if(cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd, + cmSystemTools::KeyWOW64_32)) + { + cmSystemTools::ConvertToUnixSlashes(vscmd); + vscmd += "/MSDev98/Bin/"; + } + vscmd += "msdev.exe"; + return vscmd; +} + +//---------------------------------------------------------------------------- void cmGlobalVisualStudio6Generator::GenerateBuildCommand( std::vector<std::string>& makeCommand, diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 1ffa1309a7..24f46b3904 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -102,6 +102,10 @@ private: const std::set<cmStdString>& dependencies); void WriteDSWFooter(std::ostream& fout); virtual std::string WriteUtilityDepend(cmTarget* target); + std::string MSDevCommand; + bool MSDevCommandInitialized; + std::string const& GetMSDevCommand(); + std::string FindMSDevCommand(); }; #endif diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 04563f3ea6..2602f8397a 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -22,6 +22,7 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( { this->FindMakeProgramFile = "CMakeVS7FindMake.cmake"; this->IntelProjectVersion = 0; + this->DevEnvCommandInitialized = false; if (!platformName) { @@ -110,6 +111,33 @@ void cmGlobalVisualStudio7Generator } +//---------------------------------------------------------------------------- +std::string const& cmGlobalVisualStudio7Generator::GetDevEnvCommand() +{ + if(!this->DevEnvCommandInitialized) + { + this->DevEnvCommandInitialized = true; + this->DevEnvCommand = this->FindDevEnvCommand(); + } + return this->DevEnvCommand; +} + +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio7Generator::FindDevEnvCommand() +{ + std::string vscmd; + std::string vskey = this->GetRegistryBase() + ";InstallDir"; + if(cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd, + cmSystemTools::KeyWOW64_32)) + { + cmSystemTools::ConvertToUnixSlashes(vscmd); + vscmd += "/"; + } + vscmd += "devenv.com"; + return vscmd; +} + +//---------------------------------------------------------------------------- void cmGlobalVisualStudio7Generator::GenerateBuildCommand( std::vector<std::string>& makeCommand, const char* makeProgram, diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index a6c2581d42..d272fa083d 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -110,6 +110,9 @@ public: protected: virtual const char* GetIDEVersion() { return "7.0"; } + std::string const& GetDevEnvCommand(); + virtual std::string FindDevEnvCommand(); + static cmIDEFlagTable const* GetExtraFlagTableVS7(); virtual void OutputSLNFile(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); @@ -168,6 +171,8 @@ protected: private: char* IntelProjectVersion; + std::string DevEnvCommand; + bool DevEnvCommandInitialized; }; #define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK" diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index b9bc1ae69a..949dd1bbe9 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -105,6 +105,26 @@ cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator( } //---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio8Generator::FindDevEnvCommand() +{ + // First look for VCExpress. + std::string vsxcmd; + std::string vsxkey = + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\"; + vsxkey += this->GetIDEVersion(); + vsxkey += ";InstallDir"; + if(cmSystemTools::ReadRegistryValue(vsxkey.c_str(), vsxcmd, + cmSystemTools::KeyWOW64_32)) + { + cmSystemTools::ConvertToUnixSlashes(vsxcmd); + vsxcmd += "/VCExpress.exe"; + return vsxcmd; + } + // Now look for devenv. + return this->cmGlobalVisualStudio71Generator::FindDevEnvCommand(); +} + +//---------------------------------------------------------------------------- ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator() { diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 2376f8a85c..ad01a24b31 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -69,6 +69,8 @@ public: protected: virtual const char* GetIDEVersion() { return "8.0"; } + virtual std::string FindDevEnvCommand(); + virtual bool VSLinksDependencies() const { return false; } bool AddCheckTarget(); |