From ec402a05101c13157b66b0c2acb309ed0380f555 Mon Sep 17 00:00:00 2001 From: Zephyron Date: Mon, 17 Mar 2025 12:26:35 +1000 Subject: [PATCH] feat(build): Add host system detection for Android cross-compilation - Modify CMakeLists.txt to detect whether the host system is Windows or Linux - Set VCPKG_HOST_TRIPLET dynamically to either "x64-windows" or "x64-linux" based on CMAKE_HOST_SYSTEM_NAME - Previously, the host triplet was hardcoded to "x64-windows", which prevented proper building on Linux hosts Signed-off-by: Zephyron --- CMakeLists.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0996d6d64..e1dbfbd63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,13 +169,23 @@ if (CITRON_USE_BUNDLED_VCPKG) if (CMAKE_ANDROID_ARCH_ABI STREQUAL "arm64-v8a") set(VCPKG_TARGET_TRIPLET "arm64-android") - set(VCPKG_HOST_TRIPLET "x64-windows") + # Detect host system (Windows or Linux) + if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + set(VCPKG_HOST_TRIPLET "x64-windows") + else() + set(VCPKG_HOST_TRIPLET "x64-linux") + endif() # this is to avoid CMake using the host pkg-config to find the host # libraries when building for Android targets set(PKG_CONFIG_EXECUTABLE "aarch64-none-linux-android-pkg-config" CACHE FILEPATH "" FORCE) elseif (CMAKE_ANDROID_ARCH_ABI STREQUAL "x86_64") set(VCPKG_TARGET_TRIPLET "x64-android") - set(VCPKG_HOST_TRIPLET "x64-windows") + # Detect host system (Windows or Linux) + if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + set(VCPKG_HOST_TRIPLET "x64-windows") + else() + set(VCPKG_HOST_TRIPLET "x64-linux") + endif() set(PKG_CONFIG_EXECUTABLE "x86_64-none-linux-android-pkg-config" CACHE FILEPATH "" FORCE) else() message(FATAL_ERROR "Unsupported Android architecture ${CMAKE_ANDROID_ARCH_ABI}")