diff options
author | Brad King <brad.king@kitware.com> | 2019-01-29 14:05:44 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-01-29 14:05:51 (GMT) |
commit | fa7077e7411f4f85724deae3427acb29be729567 (patch) | |
tree | 5fff6f43fcc8d2c0efd593df43240fd3e243972d /Source | |
parent | eeb34232fc2b76dc8b9bde25b2ca696d91b51b5a (diff) | |
parent | 0fd742a6ffa637b8ccac3b61b42bd10b2c3a87cc (diff) | |
download | CMake-fa7077e7411f4f85724deae3427acb29be729567.zip CMake-fa7077e7411f4f85724deae3427acb29be729567.tar.gz CMake-fa7077e7411f4f85724deae3427acb29be729567.tar.bz2 |
Merge topic 'vs-host-arch'
0fd742a6ff VS: Teach VS 2019 generator to select host tools matching host arch
17cef3806d VS: Add support for explicit 32-bit toolset selection via host=x86
bf774e521b VS: Remove stray semicolons from VS 2019 implementation
142e67eac6 VS: Use internal abstraction for VCTargetsPath host arch
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2870
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 25 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.h | 2 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio12Generator.cxx | 4 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioVersionedGenerator.cxx | 24 |
4 files changed, 45 insertions, 10 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 9a8014c..99e9173 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -607,10 +607,26 @@ cmGlobalVisualStudio10Generator::GetPlatformToolsetVersionString() const const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetHostArchitecture() const { + std::string const& hostArch = + this->GetPlatformToolsetHostArchitectureString(); + if (hostArch.empty()) { + return nullptr; + } + return hostArch.c_str(); +} + +std::string const& +cmGlobalVisualStudio10Generator::GetPlatformToolsetHostArchitectureString() + const +{ if (!this->GeneratorToolsetHostArchitecture.empty()) { - return this->GeneratorToolsetHostArchitecture.c_str(); + return this->GeneratorToolsetHostArchitecture; } - return nullptr; + if (!this->DefaultPlatformToolsetHostArchitecture.empty()) { + return this->DefaultPlatformToolsetHostArchitecture; + } + static std::string const empty; + return empty; } const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetCuda() const @@ -786,10 +802,9 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf) } cmXMLElement(eprj, "Import") .Attribute("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"); - if (!this->GeneratorToolsetHostArchitecture.empty()) { + if (const char* hostArch = this->GetPlatformToolsetHostArchitecture()) { cmXMLElement epg(eprj, "PropertyGroup"); - cmXMLElement(epg, "PreferredToolArchitecture") - .Content(this->GeneratorToolsetHostArchitecture); + cmXMLElement(epg, "PreferredToolArchitecture").Content(hostArch); } { cmXMLElement epg(eprj, "PropertyGroup"); diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 7c8918a..f496357 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -58,6 +58,7 @@ public: /** The toolset host architecture name (e.g. x64 for 64-bit host tools). */ const char* GetPlatformToolsetHostArchitecture() const; + std::string const& GetPlatformToolsetHostArchitectureString() const; /** The cuda toolset version. */ const char* GetPlatformToolsetCuda() const; @@ -152,6 +153,7 @@ protected: std::string GeneratorToolsetHostArchitecture; std::string GeneratorToolsetCuda; std::string DefaultPlatformToolset; + std::string DefaultPlatformToolsetHostArchitecture; std::string WindowsTargetPlatformVersion; std::string SystemName; std::string SystemVersion; diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 8b50684..d9702c9 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -126,8 +126,8 @@ bool cmGlobalVisualStudio12Generator::MatchesGeneratorName( bool cmGlobalVisualStudio12Generator::ProcessGeneratorToolsetField( std::string const& key, std::string const& value) { - if (key == "host" && value == "x64") { - this->GeneratorToolsetHostArchitecture = "x64"; + if (key == "host" && (value == "x64" || value == "x86")) { + this->GeneratorToolsetHostArchitecture = value; return true; } return this->cmGlobalVisualStudio11Generator::ProcessGeneratorToolsetField( diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index a83cc78..bc6b453 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -10,11 +10,14 @@ #include "cmake.h" #if defined(_M_ARM64) -# define HOST_PLATFORM_NAME "ARM64"; +# define HOST_PLATFORM_NAME "ARM64" +# define HOST_TOOLS_ARCH "" #elif defined(_M_ARM) -# define HOST_PLATFORM_NAME "ARM"; +# define HOST_PLATFORM_NAME "ARM" +# define HOST_TOOLS_ARCH "" #elif defined(_M_IA64) -# define HOST_PLATFORM_NAME "Itanium"; +# define HOST_PLATFORM_NAME "Itanium" +# define HOST_TOOLS_ARCH "" #else # include "cmsys/SystemInformation.hxx" #endif @@ -33,6 +36,20 @@ static std::string VSHostPlatformName() #endif } +static std::string VSHostArchitecture() +{ +#ifdef HOST_TOOLS_ARCH + return HOST_TOOLS_ARCH; +#else + cmsys::SystemInformation info; + if (info.Is64Bits()) { + return "x64"; + } else { + return "x86"; + } +#endif +} + static unsigned int VSVersionToMajor( cmGlobalVisualStudioGenerator::VSVersion v) { @@ -262,6 +279,7 @@ cmGlobalVisualStudioVersionedGenerator::cmGlobalVisualStudioVersionedGenerator( this->DefaultLinkFlagTableName = VSVersionToToolset(this->Version); if (this->Version >= cmGlobalVisualStudioGenerator::VS16) { this->DefaultPlatformName = VSHostPlatformName(); + this->DefaultPlatformToolsetHostArchitecture = VSHostArchitecture(); } } |