Merge pull request #641 from Ragora/bugfix-arm-detection

Feature: Properly detect ARM32/ARM64 in the CMake build process
This commit is contained in:
Brian Roberts 2021-10-28 18:08:07 -05:00 committed by GitHub
commit 59bebe0bb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 9 deletions

View file

@ -22,10 +22,19 @@
project("Torque3DEngine")
if( CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8 )
set( TORQUE_CPU_X64 ON )
elseif( CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 4 )
set( TORQUE_CPU_X32 ON )
# Detect 32bit and 64bit x86/ARM
if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
if( CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8 )
set( TORQUE_CPU_ARM64 ON )
elseif( CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 4 )
set( TORQUE_CPU_ARM32 ON )
endif()
else()
if( CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8 )
set( TORQUE_CPU_X64 ON )
elseif( CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 4 )
set( TORQUE_CPU_X32 ON )
endif()
endif()
if(NOT TORQUE_TEMPLATE)

View file

@ -24,13 +24,17 @@ project(lpng)
# addDef(PNG_NO_ASSEMBLER_CODE)
# Issues with Neon at the moment (Arm support)
# https://sourceforge.net/p/libpng/bugs/281/
set(PNG_ARM_NEON off CACHE STRING "")
add_definitions(-DPNG_ARM_NEON_OPT=0)
# Enables NEON for libpng
if ( TORQUE_CPU_ARM32 OR TORQUE_CPU_ARM64 )
set(PNG_INTEL_NEON on CACHE STRING "")
add_definitions(-DPNG_ARM_NEON_OPT=1)
addPath("${libDir}/lpng/arm")
else()
set(PNG_ARM_NEON off CACHE STRING "")
add_definitions(-DPNG_ARM_NEON_OPT=0)
endif()
# Enables SSE for libpng - also takes care of compiler warnings.
# If we don't want SSE, we should set it to off/0.
if ( TORQUE_CPU_X32 OR TORQUE_CPU_X64 )
set(PNG_INTEL_SSE on CACHE STRING "")
add_definitions(-DPNG_INTEL_SSE_OPT=1)