https://bugs.gentoo.org/925072 https://github.com/OSGeo/gdal/pull/12771 https://github.com/OSGeo/gdal/commit/68a6868877f3dc661f1e843b0bfc290a4b9ec3ed From 68a6868877f3dc661f1e843b0bfc290a4b9ec3ed Mon Sep 17 00:00:00 2001 From: Alfred Wingate Date: Tue, 22 Jul 2025 00:41:59 +0300 Subject: [PATCH] CMake: fix checks for CMAKE_SYSTEM_PROCESSOR on non Windows platforms Linux and macOS match (x86|AMD64) due to a partial match on x86_64. On Windows the valid values are AMD64/IA64/x86/ARM64 For Linux and macOS the output from uname -m is used instead. macOS and Linux x86 -> i386/i486/i586/i686 (i386 and i486 irrelevent for SIMD) macOS and Linux amd64 -> x86_64 macOS and Linux arm -> armv[567] macos arm64 -> arm64 Linux arm64 -> aarch64 https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_PROCESSOR.html https://cmake.org/cmake/help/latest/variable/CMAKE_HOST_SYSTEM_PROCESSOR.html A better defined variable in the future could be CMAKE_CXX_COMPILER_ARCHITECTURE_ID, but values for Apple and UNIX platforms are new for the unreleased cmake-4.1. https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ARCHITECTURE_ID.html Bug: https://bugs.gentoo.org/925072 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,7 @@ endif() include(Ccache) # -if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(x86|AMD64)") +if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(i586|i686|x86|AMD64)") check_compiler_machine_option(flag SSE) if (NOT ${flag} STREQUAL "") set(HAVE_SSE_AT_COMPILE_TIME 1) --- a/cmake/helpers/CheckCompilerMachineOption.cmake +++ b/cmake/helpers/CheckCompilerMachineOption.cmake @@ -31,7 +31,7 @@ function(check_compiler_machine_option outvar feature) endmacro() set(_FLAGS) - if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(x86|AMD64)") + if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(i586|i686|x86|AMD64)") if(MSVC AND (${feature} MATCHES "SSE")) # SSE2 and SSE are default on set(_FLAGS " ") @@ -100,7 +100,7 @@ function(check_compiler_machine_option outvar feature) endif() endif() endif() - elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(ARM|aarch64)") + elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(arm|ARM|aarch64)") if(MSVC) # TODO implement me elseif(CMAKE_CXX_COMPILER MATCHES "/(icpc|icc)$") # ICC (on Linux)