From dafa5014a4c83ecebc1fe160b104011c7ba8fff9 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Sun, 23 Jul 2023 13:59:07 +0200 Subject: [PATCH] Use CMAKE_SYSTEM_PROCESSOR instead of CMAKE_HOST_SYSTEM_PROCESSOR The former is exactly the same as the latter if compiling natively, which is the output of `uname -m`. But this is the wrong architecture when cross compiling where we do not want the architecture we are compiling on (the build architecture in GNU terminology) but the architecture we are compiling for (the host architecture in GNU terminology). The CMAKE_SYSTEM_PROCESSOR variable is set to the correct host architecture value when cross compiling. With this change, it is possible to cross compile a arm64 executable of box64 on an amd64 machine. Without this change, the "install" target will be omitted, because CMakeLists.txt wrongly uses the build architecture to decide whether the install target should be added or not. Instead it should use the host architecture. --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa2d833a3..3482859d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -746,10 +746,10 @@ else() endif() endif() -string(COMPARE EQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}" "i686" _x86) -string(COMPARE EQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}" "x86_64" _x86_64) -string(COMPARE EQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}" "aarch64" _aarch64) -string(COMPARE EQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}" "riscv64" _riscv64) +string(COMPARE EQUAL "${CMAKE_SYSTEM_PROCESSOR}" "i686" _x86) +string(COMPARE EQUAL "${CMAKE_SYSTEM_PROCESSOR}" "x86_64" _x86_64) +string(COMPARE EQUAL "${CMAKE_SYSTEM_PROCESSOR}" "aarch64" _aarch64) +string(COMPARE EQUAL "${CMAKE_SYSTEM_PROCESSOR}" "riscv64" _riscv64) if(_x86_64 OR _aarch64) add_definitions(-DCONFIG_64BIT)