Fix architecture detection for non-Debian distros

Replace dpkg --print-architecture (Debian-specific) with a portable
cmake-based approach using CMAKE_SYSTEM_PROCESSOR mapped to Debian
architecture names (x86_64→amd64, aarch64→arm64, armv7l→armhf, i686→i386).
This commit is contained in:
FoolHen
2026-06-08 12:28:10 +02:00
parent fb6986c16d
commit 03b8f52fa9
2 changed files with 39 additions and 11 deletions
+15 -3
View File
@@ -5,7 +5,20 @@ project(pipedal
HOMEPAGE_URL "https://rerdavies.github.io/pipedal"
)
execute_process( COMMAND dpkg --print-architecture COMMAND tr -d '\n' OUTPUT_VARIABLE DEBIAN_ARCHITECTURE )
# Determine Debian-compatible architecture name (portable across distros)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
set(DEBIAN_ARCHITECTURE "amd64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set(DEBIAN_ARCHITECTURE "arm64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "armv7l")
set(DEBIAN_ARCHITECTURE "armhf")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i386|i686")
set(DEBIAN_ARCHITECTURE "i386")
else()
execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE UNAME_M)
message(FATAL_ERROR "Cannot determine Debian architecture from CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR} (uname -m: ${UNAME_M})")
endif()
message(STATUS "DEBIAN_ARCHITECTURE=${DEBIAN_ARCHITECTURE}")
set (DISPLAY_VERSION "PiPedal v2.0.105-Release")
set (PACKAGE_ARCHITECTURE ${DEBIAN_ARCHITECTURE})
@@ -24,8 +37,7 @@ set(CPACK_SOURCE_IGNORE_FILES
"*.a;sqlite3.h;$(CPACK_SOURCE_IGNORE_FILES)"
)
set (PIPEDAL_EXCLUDE_TESTS false)
option(PIPEDAL_EXCLUDE_TESTS "Exclude test targets from default build" OFF)
include(CTest)
enable_testing()