Redo "cmake: Fix CPU architecture regexes"

Co-authored-by: Clinton Ingram <clinton.ingram@outlook.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 476bbf5..c369d50 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,6 +27,7 @@
 # Revised by Gunther Nikl, 2023
 # Revised by Tyler Kropp, 2023
 # Revised by Timothy Lyanguzov, 2023
+# Revised by Clinton Ingram, 2023
 
 # This code is released under the libpng license.
 # For conditions of distribution and use, see the disclaimer
@@ -119,10 +120,8 @@
 if(PNG_HARDWARE_OPTIMIZATIONS)
 
 # Set definitions and sources for ARM.
-if(TARGET_ARCH MATCHES "^arm" OR
-   TARGET_ARCH MATCHES "^aarch64")
-  if(TARGET_ARCH MATCHES "^arm64" OR
-     TARGET_ARCH MATCHES "^aarch64")
+if(TARGET_ARCH MATCHES "^(ARM|arm|aarch)")
+  if(TARGET_ARCH MATCHES "^(ARM64|arm64|aarch64)")
     set(PNG_ARM_NEON_POSSIBLE_VALUES on off)
     set(PNG_ARM_NEON "on"
         CACHE STRING "Enable ARM NEON optimizations: on|off; on is default")
@@ -155,8 +154,7 @@
 endif()
 
 # Set definitions and sources for PowerPC.
-if(TARGET_ARCH MATCHES "^powerpc*" OR
-   TARGET_ARCH MATCHES "^ppc64*")
+if(TARGET_ARCH MATCHES "^(powerpc|ppc64)")
   set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off)
   set(PNG_POWERPC_VSX "on"
       CACHE STRING "Enable POWERPC VSX optimizations: on|off; on is default")
@@ -178,8 +176,7 @@
 endif()
 
 # Set definitions and sources for Intel.
-if(TARGET_ARCH MATCHES "^i?86" OR
-   TARGET_ARCH MATCHES "^x86_64*")
+if(TARGET_ARCH MATCHES "^(i[3-6]86|x86|AMD64)")
   set(PNG_INTEL_SSE_POSSIBLE_VALUES on off)
   set(PNG_INTEL_SSE "on"
       CACHE STRING "Enable INTEL_SSE optimizations: on|off; on is default")
@@ -201,8 +198,7 @@
 endif()
 
 # Set definitions and sources for MIPS.
-if(TARGET_ARCH MATCHES "mipsel*" OR
-   TARGET_ARCH MATCHES "mips64el*")
+if(TARGET_ARCH MATCHES "^(mipsel|mips64el)")
   set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
   set(PNG_MIPS_MSA "on"
       CACHE STRING "Enable MIPS_MSA optimizations: on|off; on is default")
@@ -226,26 +222,22 @@
 else(PNG_HARDWARE_OPTIMIZATIONS)
 
 # Set definitions and sources for ARM.
-if(TARGET_ARCH MATCHES "^arm" OR
-   TARGET_ARCH MATCHES "^aarch64")
+if(TARGET_ARCH MATCHES "^(ARM|arm|aarch)")
   add_definitions(-DPNG_ARM_NEON_OPT=0)
 endif()
 
 # Set definitions and sources for PowerPC.
-if(TARGET_ARCH MATCHES "^powerpc*" OR
-   TARGET_ARCH MATCHES "^ppc64*")
+if(TARGET_ARCH MATCHES "^(powerpc|ppc64)")
   add_definitions(-DPNG_POWERPC_VSX_OPT=0)
 endif()
 
 # Set definitions and sources for Intel.
-if(TARGET_ARCH MATCHES "^i?86" OR
-   TARGET_ARCH MATCHES "^x86_64*")
+if(TARGET_ARCH MATCHES "^(i[3-6]86|x86|AMD64)")
   add_definitions(-DPNG_INTEL_SSE_OPT=0)
 endif()
 
 # Set definitions and sources for MIPS.
-if(TARGET_ARCH MATCHES "mipsel*" OR
-   TARGET_ARCH MATCHES "mips64el*")
+if(TARGET_ARCH MATCHES "^(mipsel|mips64el)")
   add_definitions(-DPNG_MIPS_MSA_OPT=0)
 endif()