Skip to content

Commit

Permalink
CMake: Fix building ARM64 on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
spycrab committed Feb 12, 2020
1 parent a9dc4ac commit 213a9ad
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 5 deletions.
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Binaries)

if (WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/Binary)

if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
string(APPEND CMAKE_RUNTIME_OUTPUT_DIRECTORY /ARM64)
endif()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
Expand Down Expand Up @@ -200,9 +205,7 @@ elseif(_ARCH_64 AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
add_definitions(-D_M_X86_64=1)
check_and_add_flag(HAVE_SSE2 -msse2)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(_M_ARM 1)
set(_M_ARM_64 1)
add_definitions(-D_M_ARM=1)
add_definitions(-D_M_ARM_64=1)
# CRC instruction set is used in the CRC32 hash function
check_and_add_flag(HAVE_ARCH_ARMV8 -march=armv8-a+crc)
Expand Down Expand Up @@ -456,7 +459,7 @@ if(ENABLE_EGL)
endif()

if(ENCODE_FRAMEDUMPS)
if(WIN32)
if(WIN32 AND _M_X86_64)
set(FFMPEG_DIR Externals/ffmpeg)
endif()
find_package(FFmpeg COMPONENTS avcodec avformat avutil swscale)
Expand Down
46 changes: 46 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,52 @@
"value": "${workspaceRoot}\\Externals\\Qt\\Qt5.14.1\\msvc2019_64\\lib\\cmake\\Qt5"
}
]
},
{
"name": "Release (arm64)",
"configurationType": "Release",
"generator": "Ninja",
"inheritEnvironments": [ "msvc_arm64_x64" ],
"buildCommandArgs": "",
"buildRoot": "${workspaceRoot}\\Build\\${name}",
"cmakeCommandArgs": "",
"variables": [
{
"name": "Qt5_DIR",
"value": "${workspaceRoot}\\Externals\\Qt\\Qt5.14.1\\msvc2019_arm64\\lib\\cmake\\Qt5"
},
{
"name": "CMAKE_SYSTEM_NAME",
"value": "Windows"
},
{
"name": "CMAKE_SYSTEM_PROCESSOR",
"value": "aarch64"
}
]
},
{
"name": "Debug (arm64)",
"configurationType": "Debug",
"generator": "Ninja",
"inheritEnvironments": [ "msvc_arm64_x64" ],
"buildCommandArgs": "",
"buildRoot": "${workspaceRoot}\\Build\\${name}",
"cmakeCommandArgs": "",
"variables": [
{
"name": "Qt5_DIR",
"value": "${workspaceRoot}\\Externals\\Qt\\Qt5.14.1\\msvc2019_arm64\\lib\\cmake\\Qt5"
},
{
"name": "CMAKE_SYSTEM_NAME",
"value": "Windows"
},
{
"name": "CMAKE_SYSTEM_PROCESSOR",
"value": "aarch64"
}
]
}
]
}
4 changes: 4 additions & 0 deletions Source/Core/Common/Arm64Emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include "Common/CommonTypes.h"
#include "Common/MathUtil.h"

#ifdef _WIN32
#include <Windows.h>
#endif

namespace Arm64Gen
{
namespace
Expand Down
4 changes: 3 additions & 1 deletion Source/Core/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@ elseif(WIN32)
PRIVATE
kernel32.lib
shlwapi.lib
opengl32.lib
winmm.lib
)
if (_M_X86_64)
target_link_libraries(common PRIVATE opengl32.lib)
endif()
endif()

if(ANDROID)
Expand Down
6 changes: 5 additions & 1 deletion Source/Core/Common/Hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
#include "Common/CommonFuncs.h"
#include "Common/Intrinsics.h"

#if defined(_M_ARM_64) && !defined(_MSC_VER)
#ifdef _M_ARM_64
#ifdef _MSC_VER
#include <intrin.h>
#else
#include <arm_acle.h>
#endif
#endif

namespace Common
{
Expand Down
8 changes: 8 additions & 0 deletions Source/Core/DolphinQt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,14 @@ PRIVATE
imgui
)

if (WIN32)
target_link_libraries(dolphin-emu
PRIVATE
gdi32.lib
shell32.lib
)
endif()

if(WIN32)
target_sources(dolphin-emu PRIVATE DolphinQt.manifest DolphinQt.rc)

Expand Down

0 comments on commit 213a9ad

Please sign in to comment.