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 #!/bin/bash
set -e -o pipefail
ANDROID_ABI=$1 ANDROID_ABI=$1
# Build RustDesk dependencies for Android using vcpkg.json # 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}") message(FATAL_ERROR "libvpx does not support architecture ${VCPKG_TARGET_ARCHITECTURE}")
endif() 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(VCPKG_TARGET_IS_MINGW)
if(LIBVPX_TARGET_ARCH STREQUAL "x86") if(LIBVPX_TARGET_ARCH STREQUAL "x86")
set(LIBVPX_TARGET "x86-win32-gcc") set(LIBVPX_TARGET "x86-win32-gcc")
@ -173,21 +183,12 @@ else()
endif() endif()
elseif(VCPKG_TARGET_IS_LINUX) elseif(VCPKG_TARGET_IS_LINUX)
set(LIBVPX_TARGET "${LIBVPX_TARGET_ARCH}-linux-gcc") 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) if(VCPKG_TARGET_ARCHITECTURE STREQUAL arm AND NOT VCPKG_DETECTED_CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL arm)
set(ENV{CROSS} "${CMAKE_LIBRARY_ARCHITECTURE}-") message(STATUS "Cross-building for arm-linux with arm-linux-gnueabihf")
elseif(VCPKG_TARGET_IS_ANDROID) set(ENV{CROSS} "arm-linux-gnueabihf-")
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)
endif() endif()
set(ANDROID_TOOLCHAIN_ROOT elseif(VCPKG_TARGET_IS_ANDROID)
"$ENV{ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/${ANDROID_HOST_TAG}") set(LIBVPX_TARGET "generic-gnu")
# Settings # Settings
if(VCPKG_TARGET_ARCHITECTURE STREQUAL x86) if(VCPKG_TARGET_ARCHITECTURE STREQUAL x86)
set(ANDROID_TARGET_TRIPLET i686-linux-android) set(ANDROID_TARGET_TRIPLET i686-linux-android)
@ -200,16 +201,13 @@ else()
set(OPTIONS "${OPTIONS} --enable-thumb --disable-neon") set(OPTIONS "${OPTIONS} --enable-thumb --disable-neon")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL arm64) elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL arm64)
set(ANDROID_TARGET_TRIPLET aarch64-linux-android) set(ANDROID_TARGET_TRIPLET aarch64-linux-android)
set(OPTIONS "${OPTIONS} --enable-thumb --disable-neon") set(OPTIONS "${OPTIONS} --enable-thumb")
endif() endif()
# Set environment variables for configure # Set environment variables for configure
set(ENV{CC} "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TARGET_TRIPLET}${ANDROID_API}-clang") set(ENV{AS} ${VCPKG_DETECTED_CMAKE_C_COMPILER})
set(ENV{CXX} "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TARGET_TRIPLET}${ANDROID_API}-clang++") set(ENV{LDFLAGS} "${LDFLAGS} --target=${VCPKG_DETECTED_CMAKE_C_COMPILER_TARGET}")
set(ENV{AR} "${ANDROID_TOOLCHAIN_ROOT}/bin/llvm-ar") # Set clang target
set(ENV{AS} "${CMAKE_C_COMPILER}") set(OPTIONS "${OPTIONS} --extra-cflags=--target=${VCPKG_DETECTED_CMAKE_C_COMPILER_TARGET} --extra-cxxflags=--target=${VCPKG_DETECTED_CMAKE_CXX_COMPILER_TARGET}")
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")
elseif(VCPKG_TARGET_IS_OSX) elseif(VCPKG_TARGET_IS_OSX)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(LIBVPX_TARGET "arm64-darwin20-gcc") set(LIBVPX_TARGET "arm64-darwin20-gcc")

View File

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