From dd70bab7e51dfdf7a93225ae3f3c8292621cb35c Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Mon, 31 Jul 2023 11:30:38 +0800 Subject: [PATCH 2/5] Detect PowerPC and ARM correctly (#6790) --- cmake/modules/DetectMachine.cmake | 34 +++++++++++++++++++++++++++---- src/lmmsconfig.h.in | 4 ++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git cmake/modules/DetectMachine.cmake cmake/modules/DetectMachine.cmake index c764b5507..a7acba89f 100644 --- cmake/modules/DetectMachine.cmake +++ cmake/modules/DetectMachine.cmake @@ -26,21 +26,47 @@ IF(WIN32) SET(IS_X86 TRUE) ENDIF(WIN64) ELSE(WIN32) + # Detect target architecture based on compiler target triple EXEC_PROGRAM( ${CMAKE_C_COMPILER} ARGS "-dumpmachine ${CMAKE_C_FLAGS}" OUTPUT_VARIABLE Machine ) MESSAGE("Machine: ${Machine}") STRING(REGEX MATCH "i.86" IS_X86 "${Machine}") STRING(REGEX MATCH "86_64|amd64" IS_X86_64 "${Machine}") + IF(Machine MATCHES "arm|aarch64") + IF(Machine MATCHES "arm64|aarch64") + SET(IS_ARM64 TRUE) + ELSE() + SET(IS_ARM32 TRUE) + ENDIF() + ELSEIF(Machine MATCHES "ppc|powerpc") + IF(Machine MATCHES "ppc64|powerpc64") + SET(IS_PPC64 TRUE) + ELSE() + SET(IS_PPC32 TRUE) + ENDIF() + ENDIF() ENDIF(WIN32) IF(IS_X86) - MESSAGE("-- Target host is 32 bit") + MESSAGE("-- Target host is 32 bit, Intel") SET(LMMS_HOST_X86 TRUE) ELSEIF(IS_X86_64) - MESSAGE("-- Target host is 64 bit") + MESSAGE("-- Target host is 64 bit, Intel") SET(LMMS_HOST_X86_64 TRUE) -ELSE(IS_X86) +ELSEIF(IS_ARM32) + MESSAGE("-- Target host is 32 bit, ARM") + SET(LMMS_HOST_ARM32 TRUE) +ELSEIF(IS_ARM64) + MESSAGE("-- Target host is 64 bit, ARM") + SET(LMMS_HOST_ARM64 TRUE) +ELSEIF(IS_PPC32) + MESSAGE("-- Target host is 32 bit, PPC") + SET(LMMS_HOST_PPC32 TRUE) +ELSEIF(IS_PPC64) + MESSAGE("-- Target host is 64 bit, PPC") + SET(LMMS_HOST_PPC64 TRUE) +ELSE() MESSAGE("Can't identify target host. Assuming 32 bit platform.") -ENDIF(IS_X86) +ENDIF() IF(CMAKE_INSTALL_LIBDIR) SET(LIB_DIR "${CMAKE_INSTALL_LIBDIR}") diff --git src/lmmsconfig.h.in src/lmmsconfig.h.in index 7e37be8bd..8cd7320e5 100644 --- src/lmmsconfig.h.in +++ src/lmmsconfig.h.in @@ -8,6 +8,10 @@ #cmakedefine LMMS_HOST_X86 #cmakedefine LMMS_HOST_X86_64 +#cmakedefine LMMS_HOST_ARM32 +#cmakedefine LMMS_HOST_ARM64 +#cmakedefine LMMS_HOST_PPC32 +#cmakedefine LMMS_HOST_PPC64 #cmakedefine LMMS_HAVE_ALSA #cmakedefine LMMS_HAVE_FLUIDSYNTH