Skip to content

Commit 213a9ad

Browse files
committed
CMake: Fix building ARM64 on Windows
1 parent a9dc4ac commit 213a9ad

File tree

6 files changed

+72
-5
lines changed

6 files changed

+72
-5
lines changed

CMakeLists.txt

+6-3
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Binaries)
112112

113113
if (WIN32)
114114
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/Binary)
115+
116+
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
117+
string(APPEND CMAKE_RUNTIME_OUTPUT_DIRECTORY /ARM64)
118+
endif()
119+
115120
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
116121
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
117122
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
@@ -200,9 +205,7 @@ elseif(_ARCH_64 AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
200205
add_definitions(-D_M_X86_64=1)
201206
check_and_add_flag(HAVE_SSE2 -msse2)
202207
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
203-
set(_M_ARM 1)
204208
set(_M_ARM_64 1)
205-
add_definitions(-D_M_ARM=1)
206209
add_definitions(-D_M_ARM_64=1)
207210
# CRC instruction set is used in the CRC32 hash function
208211
check_and_add_flag(HAVE_ARCH_ARMV8 -march=armv8-a+crc)
@@ -456,7 +459,7 @@ if(ENABLE_EGL)
456459
endif()
457460

458461
if(ENCODE_FRAMEDUMPS)
459-
if(WIN32)
462+
if(WIN32 AND _M_X86_64)
460463
set(FFMPEG_DIR Externals/ffmpeg)
461464
endif()
462465
find_package(FFmpeg COMPONENTS avcodec avformat avutil swscale)

CMakeSettings.json

+46
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,52 @@
2929
"value": "${workspaceRoot}\\Externals\\Qt\\Qt5.14.1\\msvc2019_64\\lib\\cmake\\Qt5"
3030
}
3131
]
32+
},
33+
{
34+
"name": "Release (arm64)",
35+
"configurationType": "Release",
36+
"generator": "Ninja",
37+
"inheritEnvironments": [ "msvc_arm64_x64" ],
38+
"buildCommandArgs": "",
39+
"buildRoot": "${workspaceRoot}\\Build\\${name}",
40+
"cmakeCommandArgs": "",
41+
"variables": [
42+
{
43+
"name": "Qt5_DIR",
44+
"value": "${workspaceRoot}\\Externals\\Qt\\Qt5.14.1\\msvc2019_arm64\\lib\\cmake\\Qt5"
45+
},
46+
{
47+
"name": "CMAKE_SYSTEM_NAME",
48+
"value": "Windows"
49+
},
50+
{
51+
"name": "CMAKE_SYSTEM_PROCESSOR",
52+
"value": "aarch64"
53+
}
54+
]
55+
},
56+
{
57+
"name": "Debug (arm64)",
58+
"configurationType": "Debug",
59+
"generator": "Ninja",
60+
"inheritEnvironments": [ "msvc_arm64_x64" ],
61+
"buildCommandArgs": "",
62+
"buildRoot": "${workspaceRoot}\\Build\\${name}",
63+
"cmakeCommandArgs": "",
64+
"variables": [
65+
{
66+
"name": "Qt5_DIR",
67+
"value": "${workspaceRoot}\\Externals\\Qt\\Qt5.14.1\\msvc2019_arm64\\lib\\cmake\\Qt5"
68+
},
69+
{
70+
"name": "CMAKE_SYSTEM_NAME",
71+
"value": "Windows"
72+
},
73+
{
74+
"name": "CMAKE_SYSTEM_PROCESSOR",
75+
"value": "aarch64"
76+
}
77+
]
3278
}
3379
]
3480
}

Source/Core/Common/Arm64Emitter.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#include "Common/CommonTypes.h"
1616
#include "Common/MathUtil.h"
1717

18+
#ifdef _WIN32
19+
#include <Windows.h>
20+
#endif
21+
1822
namespace Arm64Gen
1923
{
2024
namespace

Source/Core/Common/CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,11 @@ elseif(WIN32)
156156
PRIVATE
157157
kernel32.lib
158158
shlwapi.lib
159-
opengl32.lib
160159
winmm.lib
161160
)
161+
if (_M_X86_64)
162+
target_link_libraries(common PRIVATE opengl32.lib)
163+
endif()
162164
endif()
163165

164166
if(ANDROID)

Source/Core/Common/Hash.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
#include "Common/CommonFuncs.h"
1212
#include "Common/Intrinsics.h"
1313

14-
#if defined(_M_ARM_64) && !defined(_MSC_VER)
14+
#ifdef _M_ARM_64
15+
#ifdef _MSC_VER
16+
#include <intrin.h>
17+
#else
1518
#include <arm_acle.h>
1619
#endif
20+
#endif
1721

1822
namespace Common
1923
{

Source/Core/DolphinQt/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ PRIVATE
296296
imgui
297297
)
298298

299+
if (WIN32)
300+
target_link_libraries(dolphin-emu
301+
PRIVATE
302+
gdi32.lib
303+
shell32.lib
304+
)
305+
endif()
306+
299307
if(WIN32)
300308
target_sources(dolphin-emu PRIVATE DolphinQt.manifest DolphinQt.rc)
301309

0 commit comments

Comments
 (0)