diff options
author | Brad King <brad.king@kitware.com> | 2022-05-20 13:11:09 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-05-20 13:11:15 (GMT) |
commit | 88ed9355f51d29d3aec9c6197217e7bf6c1c4bbb (patch) | |
tree | d2b95ebf9b9d750522a394b16d828475860e2245 | |
parent | 92c7c2c39ac4d1547f325e6e71421024020a352c (diff) | |
parent | af6928ce92783c1583f8f9ae25e50c2991ebd0c0 (diff) | |
download | CMake-88ed9355f51d29d3aec9c6197217e7bf6c1c4bbb.zip CMake-88ed9355f51d29d3aec9c6197217e7bf6c1c4bbb.tar.gz CMake-88ed9355f51d29d3aec9c6197217e7bf6c1c4bbb.tar.bz2 |
Merge topic 'win_arm64_native_toolchain'
af6928ce92 VS: ARM64 as default toolset architecture for ARM64 host
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7264
4 files changed, 22 insertions, 11 deletions
diff --git a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst index 84d7212..5c13bb7 100644 --- a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst +++ b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst @@ -9,4 +9,4 @@ The :ref:`Visual Studio Generators` for VS 2013 and above support using either the 32-bit or 64-bit host toolchains by specifying a ``host=x86`` or ``host=x64`` value in the :variable:`CMAKE_GENERATOR_TOOLSET` option. CMake provides the selected toolchain architecture preference in this -variable (``x86``, ``x64``, or empty). +variable (``x86``, ``x64``, ``ARM64`` or empty). diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index 12ffa5b..600ee0a 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -138,7 +138,8 @@ bool cmGlobalVisualStudio12Generator::MatchesGeneratorName( bool cmGlobalVisualStudio12Generator::ProcessGeneratorToolsetField( std::string const& key, std::string const& value) { - if (key == "host" && (value == "x64" || value == "x86")) { + if (key == "host" && + (value == "x64" || value == "x86" || value == "ARM64")) { this->GeneratorToolsetHostArchitecture = value; return true; } diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index bc38335..1c05d36 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -27,16 +27,17 @@ #if defined(_M_ARM64) # define HOST_PLATFORM_NAME "ARM64" -# define HOST_TOOLS_ARCH "" +# define HOST_TOOLS_ARCH(v) \ + (v >= cmGlobalVisualStudioGenerator::VSVersion::VS17) ? "ARM64" : "" #elif defined(_M_ARM) # define HOST_PLATFORM_NAME "ARM" -# define HOST_TOOLS_ARCH "" +# define HOST_TOOLS_ARCH(v) "" #elif defined(_M_IA64) # define HOST_PLATFORM_NAME "Itanium" -# define HOST_TOOLS_ARCH "" +# define HOST_TOOLS_ARCH(v) "" #elif defined(_WIN64) # define HOST_PLATFORM_NAME "x64" -# define HOST_TOOLS_ARCH "x64" +# define HOST_TOOLS_ARCH(v) "x64" #else static bool VSIsWow64() { @@ -58,10 +59,12 @@ static std::string VSHostPlatformName() #endif } -static std::string VSHostArchitecture() +static std::string VSHostArchitecture( + cmGlobalVisualStudioGenerator::VSVersion v) { + static_cast<void>(v); #ifdef HOST_TOOLS_ARCH - return HOST_TOOLS_ARCH; + return HOST_TOOLS_ARCH(v); #else if (VSIsWow64()) { return "x64"; @@ -433,7 +436,8 @@ cmGlobalVisualStudioVersionedGenerator::cmGlobalVisualStudioVersionedGenerator( this->DefaultLinkFlagTableName = VSVersionToToolset(this->Version); if (this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS16) { this->DefaultPlatformName = VSHostPlatformName(); - this->DefaultPlatformToolsetHostArchitecture = VSHostArchitecture(); + this->DefaultPlatformToolsetHostArchitecture = + VSHostArchitecture(this->Version); } if (this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS17) { // FIXME: Search for an existing framework? Under '%ProgramFiles(x86)%', diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake index 5ea02a5..9d5d0b5 100644 --- a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake @@ -6,8 +6,14 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio 1[67]") cmake_host_system_information(RESULT is_64_bit QUERY IS_64BIT) if(is_64_bit) if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "ARM64") - if(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "") - message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not empty as expected.") + if(CMAKE_GENERATOR STREQUAL "Visual Studio 17 2022") + if(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "ARM64") + message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not 'ARM64' as expected.") + endif() + else() + if(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "") + message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not empty as expected.") + endif() endif() elseif(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "x64") message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not 'x64' as expected.") |