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.
This commit is contained in:
Johannes Schauer Marin Rodrigues 2023-07-23 13:59:07 +02:00
parent 50032affcf
commit dafa5014a4
No known key found for this signature in database
GPG Key ID: F2CBA5C78FBD83E1

View File

@ -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)