mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
VS: ARM64 as default toolset architecture for ARM64 host
Visual Studio 2022 17 Preview introduced a native ARM64 toolchain.
This commit is contained in:
@@ -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).
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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)%',
|
||||
|
@@ -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.")
|
||||
|
Reference in New Issue
Block a user