Fix wrong CMake compiler detection of arm-linux on aarch64

[skip ci]

Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
This commit is contained in:
Vasyl Gello 2023-11-08 08:21:17 +02:00
parent 1ba11fc3ef
commit cb9a1b4bef
3 changed files with 26 additions and 22 deletions

View File

@ -1,5 +1,7 @@
#!/bin/bash
set -e -o pipefail
ANDROID_ABI=$1
# Build RustDesk dependencies for Android using vcpkg.json

View File

@ -165,6 +165,16 @@ else()
message(FATAL_ERROR "libvpx does not support architecture ${VCPKG_TARGET_ARCHITECTURE}")
endif()
vcpkg_cmake_get_vars(cmake_vars_file)
include("${cmake_vars_file}")
# Set environment variables for configure
set(ENV{CC} ${VCPKG_DETECTED_CMAKE_C_COMPILER})
set(ENV{CXX} ${VCPKG_DETECTED_CMAKE_CXX_COMPILER})
set(ENV{AR} ${VCPKG_DETECTED_CMAKE_AR})
set(ENV{LD} ${VCPKG_DETECTED_CMAKE_LINKER})
set(ENV{RANLIB} ${VCPKG_DETECTED_CMAKE_RANLIB})
if(VCPKG_TARGET_IS_MINGW)
if(LIBVPX_TARGET_ARCH STREQUAL "x86")
set(LIBVPX_TARGET "x86-win32-gcc")
@ -173,21 +183,12 @@ else()
endif()
elseif(VCPKG_TARGET_IS_LINUX)
set(LIBVPX_TARGET "${LIBVPX_TARGET_ARCH}-linux-gcc")
include($ENV{VCPKG_ROOT}/buildtrees/detect_compiler/${VCPKG_TARGET_ARCHITECTURE}-linux-rel/CMakeFiles/${CMAKE_VERSION}/CMakeCCompiler.cmake)
set(ENV{CROSS} "${CMAKE_LIBRARY_ARCHITECTURE}-")
elseif(VCPKG_TARGET_IS_ANDROID)
set(LIBVPX_TARGET "${LIBVPX_TARGET_ARCH}-android-gcc")
set(ANDROID_API 21)
# From ndk android.toolchsin.cmake
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux)
set(ANDROID_HOST_TAG linux-x86_64)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
set(ANDROID_HOST_TAG darwin-x86_64)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
set(ANDROID_HOST_TAG windows-x86_64)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL arm AND NOT VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL arm)
message(STATUS "Cross-building for arm-linux with arm-linux-gnueabihf")
set(ENV{CROSS} "arm-linux-gnueabihf-")
endif()
set(ANDROID_TOOLCHAIN_ROOT
"$ENV{ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/${ANDROID_HOST_TAG}")
elseif(VCPKG_TARGET_IS_ANDROID)
set(LIBVPX_TARGET "generic-gnu")
# Settings
if(VCPKG_TARGET_ARCHITECTURE STREQUAL x86)
set(ANDROID_TARGET_TRIPLET i686-linux-android)
@ -200,16 +201,13 @@ else()
set(OPTIONS "${OPTIONS} --enable-thumb --disable-neon")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL arm64)
set(ANDROID_TARGET_TRIPLET aarch64-linux-android)
set(OPTIONS "${OPTIONS} --enable-thumb --disable-neon")
set(OPTIONS "${OPTIONS} --enable-thumb")
endif()
# Set environment variables for configure
set(ENV{CC} "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TARGET_TRIPLET}${ANDROID_API}-clang")
set(ENV{CXX} "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TARGET_TRIPLET}${ANDROID_API}-clang++")
set(ENV{AR} "${ANDROID_TOOLCHAIN_ROOT}/bin/llvm-ar")
set(ENV{AS} "${CMAKE_C_COMPILER}")
set(ENV{LD} "${ANDROID_TOOLCHAIN_ROOT}/bin/ld")
set(ENV{RANLIB} "${ANDROID_TOOLCHAIN_ROOT}/bin/llvm-ranlib")
set(ENV{STRIP} "${ANDROID_TOOLCHAIN_ROOT}/bin/llvm-strip")
set(ENV{AS} ${VCPKG_DETECTED_CMAKE_C_COMPILER})
set(ENV{LDFLAGS} "${LDFLAGS} --target=${VCPKG_DETECTED_CMAKE_C_COMPILER_TARGET}")
# Set clang target
set(OPTIONS "${OPTIONS} --extra-cflags=--target=${VCPKG_DETECTED_CMAKE_C_COMPILER_TARGET} --extra-cxxflags=--target=${VCPKG_DETECTED_CMAKE_CXX_COMPILER_TARGET}")
elseif(VCPKG_TARGET_IS_OSX)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(LIBVPX_TARGET "arm64-darwin20-gcc")

View File

@ -9,6 +9,10 @@
"name": "vcpkg-msbuild",
"host": true,
"platform": "windows"
},
{
"name": "vcpkg-cmake-get-vars",
"host": true
}
],
"features": {