diff --git a/CMakeLists.txt b/CMakeLists.txt index bde16bb813..f29c3bdf20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,34 +103,45 @@ list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake/Modules") # and is used in DLL names (jagamex86.dll, jagamex86.dylib, jagamei386.so). if(WIN32) set(X86 ON) - if(CMAKE_SIZEOF_VOID_P MATCHES "8") - set(Architecture "x86_64") - set(WIN64 TRUE) + get_filename_component(ParentDir ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) + # VCPKG default dir is this repository's sibling directory 'vcpkg'. + set(VcpkgDir "${ParentDir}/vcpkg" CACHE INTERNAL "") + if(DEFINED CMAKE_GENERATOR_PLATFORM AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "") + set(Architecture "${CMAKE_GENERATOR_PLATFORM}" CACHE INTERNAL "") + string(TOLOWER "${Architecture}" Architecture) + elseif(CMAKE_SIZEOF_VOID_P MATCHES "8") + set(Architecture "x86_64" CACHE INTERNAL "") else() - set(Architecture "x86") + set(Architecture "x86" CACHE INTERNAL "") + endif() + + if(Architecture STREQUAL "x86_64" OR Architecture STREQUAL "arm64") + set(WIN64 TRUE) + elseif(Architecture STREQUAL "x86") set(WIN64 FALSE) endif() else() set(X86 OFF) if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") - set(Architecture "arm") + set(Architecture "arm" CACHE INTERNAL "") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") set(X86 ON) if(APPLE) - set(Architecture "x86") + set(Architecture "x86" CACHE INTERNAL "") else() # e.g. Linux - set(Architecture "i386") + set(Architecture "i386" CACHE INTERNAL "") endif() elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^x86.64$") set(X86 ON) - set(Architecture "x86_64") + set(Architecture "x86_64" CACHE INTERNAL "") elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "powerpc") - set(Architecture "ppc") + set(Architecture "ppc" CACHE INTERNAL "") elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "powerpc64") - set(Architecture "ppc64") + set(Architecture "ppc64" CACHE INTERNAL "") else() - set(Architecture "${CMAKE_SYSTEM_PROCESSOR}") + set(Architecture "${CMAKE_SYSTEM_PROCESSOR}" CACHE INTERNAL "") + string(TOLOWER "${Architecture}" Architecture) endif() endif() diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 2c9e7f509f..9e24d45e20 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -71,18 +71,24 @@ if(BuildSPEngine OR BuildJK2SPEngine) endif() if(UseInternalSDL2) - if(CMAKE_SIZEOF_VOID_P EQUAL 4) + if(Architecture STREQUAL "x86") set(SPEngineLibraries ${SPEngineLibraries} ${OpenJKLibDir}/SDL2/lib/x86/SDL2main.lib ${OpenJKLibDir}/SDL2/lib/x86/SDL2.lib ) - else() + elseif(Architecture STREQUAL "x86_64") set(SPEngineLibraries ${SPEngineLibraries} ${OpenJKLibDir}/SDL2/lib/x64/SDL2main.lib ${OpenJKLibDir}/SDL2/lib/x64/SDL2.lib ) + elseif(Architecture STREQUAL "arm64") + set(SPEngineLibraries + ${SPEngineLibraries} + ${VcpkgDir}/installed/arm64-windows/lib/manual-link/SDL2main.lib + ${VcpkgDir}/installed/arm64-windows/lib/SDL2.lib + ) endif() set(SPEngineIncludeDirectories @@ -387,14 +393,18 @@ if(BuildSPEngine OR BuildJK2SPEngine) if(WIN32) add_executable(${ProjectName} WIN32 ${SPEngineFiles}) if(UseInternalSDL2) - if(CMAKE_SIZEOF_VOID_P EQUAL 4) + if(Architecture STREQUAL "x86") set(SPEngineExtraInstallFiles ${OpenJKLibDir}/SDL2/bin/x86/SDL2.dll ) - else() + elseif(Architecture STREQUAL "x86_64") set(SPEngineExtraInstallFiles ${OpenJKLibDir}/SDL2/bin/x64/SDL2.dll ) + elseif(Architecture STREQUAL "arm64") + set(SPEngineExtraInstallFiles + ${VcpkgDir}/installed/arm64-windows/bin/SDL2.dll + ) endif() endif() else(WIN32) diff --git a/code/qcommon/timing.h b/code/qcommon/timing.h index f608c2722a..8e472d74f0 100644 --- a/code/qcommon/timing.h +++ b/code/qcommon/timing.h @@ -38,7 +38,8 @@ class timing_c void Start() { -#ifdef _WIN32 + +#if defined(_WIN32) && !defined(_M_ARM64) start = __rdtsc(); #else start = 0; @@ -49,7 +50,7 @@ class timing_c { int time; -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_M_ARM64) end = __rdtsc(); #else end = 0; diff --git a/codemp/CMakeLists.txt b/codemp/CMakeLists.txt index c10cabf7ab..c69e3f3c27 100644 --- a/codemp/CMakeLists.txt +++ b/codemp/CMakeLists.txt @@ -377,18 +377,24 @@ if(BuildMPEngine) endif() if(UseInternalSDL2) - if(CMAKE_SIZEOF_VOID_P EQUAL 4) + if(Architecture STREQUAL "x86") set(MPEngineLibraries ${MPEngineLibraries} ${OpenJKLibDir}/SDL2/lib/x86/SDL2main.lib ${OpenJKLibDir}/SDL2/lib/x86/SDL2.lib ) - else() + elseif(Architecture STREQUAL "x86_64") set(MPEngineLibraries ${MPEngineLibraries} ${OpenJKLibDir}/SDL2/lib/x64/SDL2main.lib ${OpenJKLibDir}/SDL2/lib/x64/SDL2.lib ) + elseif(Architecture STREQUAL "arm64") + set(MPEngineLibraries + ${MPEngineLibraries} + ${VcpkgDir}/installed/arm64-windows/lib/manual-link/SDL2main.lib + ${VcpkgDir}/installed/arm64-windows/lib/SDL2.lib + ) endif() set(MPEngineIncludeDirectories @@ -564,14 +570,18 @@ if(BuildMPEngine) if(WIN32) add_executable(${MPEngine} WIN32 ${MPEngineFiles}) if(UseInternalSDL2) - if(CMAKE_SIZEOF_VOID_P EQUAL 4) + if(Architecture STREQUAL "x86") set(MPEngineExtraInstallFiles ${OpenJKLibDir}/SDL2/bin/x86/SDL2.dll ) - else() + elseif(Architecture STREQUAL "x86_64") set(MPEngineExtraInstallFiles ${OpenJKLibDir}/SDL2/bin/x64/SDL2.dll ) + elseif(Architecture STREQUAL "arm64") + set(MPEngineExtraInstallFiles + ${VcpkgDir}/installed/arm64-windows/bin/SDL2.dll + ) endif() endif() else(WIN32) diff --git a/codemp/qcommon/timing.h b/codemp/qcommon/timing.h index 28ef999e94..eab22d94dd 100644 --- a/codemp/qcommon/timing.h +++ b/codemp/qcommon/timing.h @@ -39,7 +39,7 @@ class timing_c void Start() { -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_M_ARM64) start = __rdtsc(); #else start = 0; @@ -50,7 +50,7 @@ class timing_c { int64_t time; -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_M_ARM64) end = __rdtsc(); #else end = 0;