Skip to content
Open
33 changes: 22 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
18 changes: 14 additions & 4 deletions code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +89 to +90
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love having vendored versions for everything except arm64-windows.
I think my preference would be vendored versions for all, with optional sourcing from (system) package manager. I also don't love how much bloat and churn that entails. Maybe arm64-windows is a special-enough case to push for vcpkg.

This isn't a blocker, just provoking discussion so we can form a stance here intentionally.

)
endif()

set(SPEngineIncludeDirectories
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions code/qcommon/timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class timing_c

void Start()
{
#ifdef _WIN32

#if defined(_WIN32) && !defined(_M_ARM64)
start = __rdtsc();
#else
start = 0;
Expand All @@ -49,7 +50,7 @@ class timing_c
{
int time;

#ifdef _WIN32
#if defined(_WIN32) && !defined(_M_ARM64)
end = __rdtsc();
#else
end = 0;
Expand Down
18 changes: 14 additions & 4 deletions codemp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions codemp/qcommon/timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class timing_c

void Start()
{
#ifdef _WIN32
#if defined(_WIN32) && !defined(_M_ARM64)
start = __rdtsc();
#else
start = 0;
Expand All @@ -50,7 +50,7 @@ class timing_c
{
int64_t time;

#ifdef _WIN32
#if defined(_WIN32) && !defined(_M_ARM64)
end = __rdtsc();
#else
end = 0;
Expand Down