From 3f55ea9fced60759f885d3e945db3a9b485c4eca Mon Sep 17 00:00:00 2001 From: fwcd <30873659+fwcd@users.noreply.github.com> Date: Fri, 19 Apr 2024 21:11:15 +0200 Subject: [PATCH] [linux] Fix compiler in native ARM host builds (#38113) #35084 introduced a regression for native ARM Linux builds where the toolchain would mistakenly try to reference a cross-compiler (e.g. `aarch64-linux-gnu-gcc`) despite building natively because vcpkg spells the architecture differently from what the system reports (`arm64` vs. `aarch64`). This fixes the issue by checking whether the `CMAKE_HOST_SYSTEM_PROCESSOR` matches the target (in CMake's spelling of the architecture). --------- Co-authored-by: Kai Pastor --- scripts/toolchains/linux.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/toolchains/linux.cmake b/scripts/toolchains/linux.cmake index f22c710768..4b92cb09fe 100644 --- a/scripts/toolchains/linux.cmake +++ b/scripts/toolchains/linux.cmake @@ -13,7 +13,8 @@ elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") string(APPEND VCPKG_LINKER_FLAGS " -m32") elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm") set(CMAKE_SYSTEM_PROCESSOR armv7l CACHE STRING "") - if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") + if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND NOT CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "armv7l") + if(NOT DEFINED CMAKE_CXX_COMPILER) set(CMAKE_CXX_COMPILER "arm-linux-gnueabihf-g++") endif() @@ -30,7 +31,8 @@ elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm") endif() elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") set(CMAKE_SYSTEM_PROCESSOR aarch64 CACHE STRING "") - if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") + if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND NOT CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "aarch64") + if(NOT DEFINED CMAKE_CXX_COMPILER) set(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++") endif()