macos-arm64.patch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. Based on https://github.com/vespakoen/libpng to work around until
  2. https://github.com/glennrp/libpng/pull/354 is resolved.
  3. diff --git a/CMakeLists.txt b/CMakeLists.txt
  4. index 4db9bb87d..9099d1edf 100644
  5. --- a/CMakeLists.txt
  6. +++ b/CMakeLists.txt
  7. @@ -82,10 +82,22 @@ option(PNG_HARDWARE_OPTIMIZATIONS "Enable Hardware Optimizations" ON)
  8. set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names")
  9. set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings")
  10. +# CMake currently sets CMAKE_SYSTEM_PROCESSOR to one of x86_64 or arm64 on macOS,
  11. +# based upon the OS architecture, not the target architecture. As such, we need
  12. +# to check CMAKE_OSX_ARCHITECTURES to identify which hardware-specific flags to
  13. +# enable. Note that this will fail if you attempt to build a universal binary in
  14. +# a single cmake invokation.
  15. +if (APPLE AND CMAKE_OSX_ARCHITECTURES)
  16. + set(TARGET_ARCH ${CMAKE_OSX_ARCHITECTURES})
  17. +else()
  18. + set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})
  19. +endif()
  20. +
  21. +
  22. if(PNG_HARDWARE_OPTIMIZATIONS)
  23. # set definitions and sources for arm
  24. -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
  25. - CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
  26. +if(TARGET_ARCH MATCHES "^arm" OR
  27. + TARGET_ARCH MATCHES "^aarch64")
  28. set(PNG_ARM_NEON_POSSIBLE_VALUES check on off)
  29. set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations:
  30. check: (default) use internal checking code;
  31. @@ -114,8 +126,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
  32. endif()
  33. # set definitions and sources for powerpc
  34. -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
  35. - CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*" )
  36. +if(TARGET_ARCH MATCHES "^powerpc*" OR
  37. + TARGET_ARCH MATCHES "^ppc64*" )
  38. set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off)
  39. set(PNG_POWERPC_VSX "on" CACHE STRING "Enable POWERPC VSX optimizations:
  40. off: disable the optimizations.")
  41. @@ -138,8 +150,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
  42. endif()
  43. # set definitions and sources for intel
  44. -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR
  45. - CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*" )
  46. +if(TARGET_ARCH MATCHES "^i?86" OR
  47. + TARGET_ARCH MATCHES "^x86_64*" )
  48. set(PNG_INTEL_SSE_POSSIBLE_VALUES on off)
  49. set(PNG_INTEL_SSE "on" CACHE STRING "Enable INTEL_SSE optimizations:
  50. off: disable the optimizations")
  51. @@ -162,8 +174,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR
  52. endif()
  53. # set definitions and sources for MIPS
  54. -if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR
  55. - CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*" )
  56. +if(TARGET_ARCH MATCHES "mipsel*" OR
  57. + TARGET_ARCH MATCHES "mips64el*" )
  58. set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
  59. set(PNG_MIPS_MSA "on" CACHE STRING "Enable MIPS_MSA optimizations:
  60. off: disable the optimizations")