Skip to content

Commit e2630eb

Browse files
committed
Improve support for MSVC ARM64
1 parent 260e551 commit e2630eb

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

CMakeLists.txt

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,26 @@ if (UNICORN_LOGGING)
117117
add_compile_options(-DUNICORN_LOGGING)
118118
endif()
119119

120-
# Some distributions on some rare architecures don't auto link atomic for us and
120+
# Some distributions on some rare architectures don't auto link atomic for us and
121121
# we do this manually by adding flags.
122122
set(ATOMIC_LINKAGE_FIX FALSE)
123123
if(MSVC)
124-
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
125-
set(MSVC_FLAG -D__x86_64__)
126-
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
127-
set(MSVC_FLAG -D__i386__)
128-
else()
129-
message(FATAL_ERROR "Neither WIN64 or WIN32!")
124+
include(CheckSymbolExists)
125+
set(CMAKE_REQUIRED_QUIET YES)
126+
check_symbol_exists("_M_X64" "" MSVC_ARCH_X64)
127+
check_symbol_exists("_M_IX86" "" MSVC_ARCH_X86)
128+
check_symbol_exists("_M_ARM64" "" MSVC_ARCH_ARM64)
129+
unset(CMAKE_REQUIRED_QUIET)
130+
131+
if(MSVC_ARCH_X64)
132+
set(MSVC_FLAG -D__x86_64__)
133+
set(UNICORN_TARGET_ARCH "i386")
134+
elseif(MSVC_ARCH_X86)
135+
set(MSVC_FLAG -D__i386__)
136+
set(UNICORN_TARGET_ARCH "i386")
137+
elseif(MSVC_ARCH_ARM64)
138+
set(MSVC_FLAG -D__aarch64__)
139+
set(UNICORN_TARGET_ARCH "aarch64")
130140
endif()
131141

132142
add_compile_options(
@@ -135,7 +145,7 @@ if(MSVC)
135145
-D_CRT_SECURE_NO_WARNINGS
136146
-DWIN32_LEAN_AND_MEAN
137147
${MSVC_FLAG}
138-
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/tcg/i386
148+
/I${CMAKE_CURRENT_SOURCE_DIR}/qemu/tcg/${UNICORN_TARGET_ARCH}
139149
)
140150

141151
# Disable some warnings
@@ -1214,7 +1224,7 @@ if(MSVC)
12141224
qemu/util/oslib-win32.c
12151225
qemu/util/qemu-thread-win32.c
12161226
)
1217-
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
1227+
if(MSVC_ARCH_X64)
12181228
if(MSVC_VERSION LESS 1600 AND MSVC_IDE)
12191229
add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/build/setjmp-wrapper-win32.dir/setjmp-wrapper-win32.obj"
12201230
COMMAND ml64 /c /nologo /Fo"${CMAKE_CURRENT_SOURCE_DIR}/build/setjmp-wrapper-win32.dir/setjmp-wrapper-win32.obj" /W3 /errorReport:prompt /Ta"${CMAKE_CURRENT_SOURCE_DIR}/qemu/util/setjmp-wrapper-win32.asm"

0 commit comments

Comments
 (0)