Commit 89e62e7f authored by moyo1997's avatar moyo1997
Browse files

MSVC: Add support for targeting ARM64EC

parent b30243d9
Pipeline #210058 waiting for manual action with stages
in 9 minutes and 39 seconds
......@@ -116,6 +116,9 @@
# if defined(_M_IA64)
# define ARCHITECTURE_ID "IA64"
# elif defined(_M_ARM64EC)
# define ARCHITECTURE_ID "ARM64EC"
# elif defined(_M_X64) || defined(_M_AMD64)
# define ARCHITECTURE_ID "x64"
......
......@@ -154,7 +154,9 @@ set(CMAKE_BUILD_TYPE_INIT Debug)
# Compute an architecture family from the architecture id.
foreach(lang C CXX)
set(_MSVC_${lang}_ARCHITECTURE_FAMILY "${MSVC_${lang}_ARCHITECTURE_ID}")
if(_MSVC_${lang}_ARCHITECTURE_FAMILY MATCHES "^ARM64")
if(_MSVC_${lang}_ARCHITECTURE_FAMILY MATCHES "^ARM64EC")
set(_MSVC_${lang}_ARCHITECTURE_FAMILY "ARM64EC")
elseif(_MSVC_${lang}_ARCHITECTURE_FAMILY MATCHES "^ARM64")
set(_MSVC_${lang}_ARCHITECTURE_FAMILY "ARM64")
elseif(_MSVC_${lang}_ARCHITECTURE_FAMILY MATCHES "^ARM")
set(_MSVC_${lang}_ARCHITECTURE_FAMILY "ARM")
......@@ -224,7 +226,9 @@ elseif(WINDOWS_PHONE OR WINDOWS_STORE)
endif()
else()
set(_PLATFORM_DEFINES "/DWIN32")
if(_MSVC_${lang}_ARCHITECTURE_FAMILY MATCHES "^ARM64EC")
set(_PLATFORM_DEFINES "${_PLATFORM_DEFINES} /D_AMD64_ /DAMD64 /D_ARM64EC_ /DARM64EC /D_ARM64EC_WORKAROUND_")
endif()
if(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM" OR _MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM")
set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib")
elseif(MSVC_VERSION GREATER 1310)
......@@ -261,6 +265,8 @@ if(MSVC_C_ARCHITECTURE_ID)
set(_MACHINE_ARCH_FLAG "/machine:THUMB")
elseif(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM64")
set(_MACHINE_ARCH_FLAG "/machine:ARM64")
elseif(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM64EC")
set(_MACHINE_ARCH_FLAG "/machine:ARM64EC")
elseif(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM")
set(_MACHINE_ARCH_FLAG "/machine:ARM")
else()
......@@ -271,6 +277,8 @@ elseif(MSVC_CXX_ARCHITECTURE_ID)
set(_MACHINE_ARCH_FLAG "/machine:THUMB")
elseif(_MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM64")
set(_MACHINE_ARCH_FLAG "/machine:ARM64")
elseif(_MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM64EC")
set(_MACHINE_ARCH_FLAG "/machine:ARM64EC")
elseif(_MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM")
set(_MACHINE_ARCH_FLAG "/machine:ARM")
else()
......@@ -305,7 +313,11 @@ foreach(t EXE SHARED MODULE)
string(APPEND CMAKE_${t}_LINKER_FLAGS_RELEASE_INIT " /INCREMENTAL:NO")
endforeach()
string(APPEND CMAKE_STATIC_LINKER_FLAGS_INIT " ${_MACHINE_ARCH_FLAG}")
if((_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM64EC") OR (_MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM64EC"))
string(APPEND CMAKE_STATIC_LINKER_FLAGS_INIT " /machine:ARM64X")
else()
string(APPEND CMAKE_STATIC_LINKER_FLAGS_INIT " ${_MACHINE_ARCH_FLAG}")
endif()
unset(_MACHINE_ARCH_FLAG)
cmake_policy(GET CMP0091 __WINDOWS_MSVC_CMP0091)
......
......@@ -200,6 +200,7 @@ public:
platforms.emplace_back("Win32");
platforms.emplace_back("ARM");
platforms.emplace_back("ARM64");
platforms.emplace_back("ARM64EC");
return platforms;
}
......
......@@ -350,6 +350,13 @@
"value": "MachineARM64",
"flags": []
},
{
"name": "TargetMachine",
"switch": "MACHINE:ARM64EC",
"comment": "MachineARM64EC",
"value": "MachineARM64EC",
"flags": []
},
{
"name": "TargetMachine",
"switch": "MACHINE:EBC",
......
......@@ -41,6 +41,13 @@
"value": "MachineARM64",
"flags": []
},
{
"name": "TargetMachine",
"switch": "MACHINE:ARM64X",
"comment": "MachineARM64X",
"value": "MachineARM64X",
"flags": []
},
{
"name": "TargetMachine",
"switch": "MACHINE:EBC",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment