diff --git a/scripts/cmake/vcpkg_configure_make.cmake b/scripts/cmake/vcpkg_configure_make.cmake index aa054222c7dedc..e3a54b453f2139 100644 --- a/scripts/cmake/vcpkg_configure_make.cmake +++ b/scripts/cmake/vcpkg_configure_make.cmake @@ -116,6 +116,8 @@ macro(z_vcpkg_determine_autotools_host_cpu out_var) endif() if(host_arch MATCHES "(amd|AMD)64") set(${out_var} x86_64) + elseif(host_arch MATCHES "(x|X)86_64") + set(${out_var} x86_64) elseif(host_arch MATCHES "(x|X)86") set(${out_var} i686) elseif(host_arch MATCHES "^(ARM|arm)64$") @@ -316,7 +318,7 @@ function(vcpkg_configure_make) # Only for ports using autotools so we can assume that they follow the common conventions for build/target/host if(CMAKE_HOST_WIN32) set(arg_BUILD_TRIPLET "--build=${BUILD_ARCH}-pc-mingw32") # This is required since we are running in a msys - # shell which will be otherwise identified as ${BUILD_ARCH}-pc-msys + # shell which will be otherwise identified as ${BUILD_ARCH}-pc-msys endif() if(NOT TARGET_ARCH MATCHES "${BUILD_ARCH}" OR NOT CMAKE_HOST_WIN32) # we don't need to specify the additional flags if we build nativly, this does not hold when we are not on windows string(APPEND arg_BUILD_TRIPLET " --host=${TARGET_ARCH}-pc-mingw32") # (Host activates crosscompilation; The name given here is just the prefix of the host tools for the target) @@ -465,6 +467,55 @@ function(vcpkg_configure_make) endif() endif() + # Android - cross-compiling support + if(VCPKG_TARGET_IS_ANDROID) + if (VCPKG_DETECTED_CMAKE_CXX_COMPILER_ID MATCHES "^Clang$") + string(REPLACE "-static-libstdc++" "-lc++_static" VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES ${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}) + + if (DEFINED ENV{ANDROID_API_LEVEL}) + set(ANDROID_API_LEVEL $ENV{ANDROID_API_LEVEL} CACHE STRING "") + else() + set(ANDROID_API_LEVEL ${VCPKG_DETECTED_CMAKE_SYSTEM_VERSION} CACHE STRING "") + endif() + + if (arg_DETERMINE_BUILD_TRIPLET OR NOT arg_BUILD_TRIPLET) + if(VCPKG_HOST_IS_WINDOWS) + z_vcpkg_determine_autotools_host_cpu(BUILD_ARCH) # machine you are building on => --build= + z_vcpkg_determine_host_mingw(BUILD_MINGW) + set(arg_BUILD_TRIPLET "--build=${BUILD_ARCH}-pc-${BUILD_MINGW}") # This is required since we are running in a msys + # shell which will be otherwise identified as ${BUILD_ARCH}-pc-msys + elseif(VCPKG_HOST_IS_OSX) + z_vcpkg_determine_autotools_host_arch_mac(BUILD_ARCH) # machine you are building on => --build= + set(arg_BUILD_TRIPLET "--build=${BUILD_ARCH}-apple-darwin${VCPKG_DETECTED_CMAKE_HOST_SYSTEM_VERSION}") + elseif(VCPKG_HOST_IS_LINUX) + z_vcpkg_determine_autotools_host_cpu(BUILD_ARCH) # machine you are building on => --build= + set(arg_BUILD_TRIPLET "--build=${BUILD_ARCH}-pc-linux-gnu") + endif() + + z_vcpkg_determine_autotools_target_cpu(TARGET_ARCH) + if (TARGET_ARCH MATCHES "armv7-a") + string(APPEND arg_BUILD_TRIPLET " --host=arm-linux-androideabi") + else() + string(APPEND arg_BUILD_TRIPLET " --host=${TARGET_ARCH}-linux-android") + endif() + endif() + debug_message("Using make triplet: ${arg_BUILD_TRIPLET}") + + if (TARGET_ARCH MATCHES "armv7-a") + string(APPEND configure_env " CC=armv7a-linux-androideabi${ANDROID_API_LEVEL}-clang") + string(APPEND configure_env " CXX=armv7a-linux-androideabi${ANDROID_API_LEVEL}-clang++") + else() + string(APPEND configure_env " CC=${TARGET_ARCH}-linux-android${ANDROID_API_LEVEL}-clang") + string(APPEND configure_env " CXX=${TARGET_ARCH}-linux-android${ANDROID_API_LEVEL}-clang++") + endif() + + string(APPEND configure_env " AR=llvm-ar") + string(APPEND configure_env " RANLIB=llvm-ranlib") + string(APPEND configure_env " READELF=llvm-readelf") + string(APPEND configure_env " STRIP=llvm-strip") + endif() + endif() + # Cleanup previous build dirs file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" diff --git a/scripts/get_cmake_vars/CMakeLists.txt b/scripts/get_cmake_vars/CMakeLists.txt index b6d5f0e4154d46..175febd4b1a423 100644 --- a/scripts/get_cmake_vars/CMakeLists.txt +++ b/scripts/get_cmake_vars/CMakeLists.txt @@ -8,7 +8,8 @@ list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_CROSSCOMPILING CMAKE_SYSTEM_NAME CMAKE_HOST_SYSTEM_NAME CMAKE_SYSTEM_PROCESSOR - CMAKE_HOST_SYSTEM_PROCESSOR) + CMAKE_HOST_SYSTEM_PROCESSOR + CMAKE_HOST_SYSTEM_VERSION) if(CMAKE_SYSTEM_NAME MATCHES "Darwin") list(APPEND VCPKG_DEFAULT_VARS_TO_CHECK CMAKE_OSX_DEPLOYMENT_TARGET CMAKE_OSX_SYSROOT) diff --git a/scripts/toolchains/android.cmake b/scripts/toolchains/android.cmake index ff04cb72d83ae4..3e89eb76c1dda3 100644 --- a/scripts/toolchains/android.cmake +++ b/scripts/toolchains/android.cmake @@ -1,9 +1,16 @@ set(ANDROID_CPP_FEATURES "rtti exceptions" CACHE STRING "") set(CMAKE_SYSTEM_NAME Android CACHE STRING "") set(ANDROID_TOOLCHAIN clang CACHE STRING "") -set(ANDROID_NATIVE_API_LEVEL ${CMAKE_SYSTEM_VERSION} CACHE STRING "") set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang CACHE STRING "") +if (DEFINED ENV{ANDROID_API_LEVEL}) + set(ANDROID_NATIVE_API_LEVEL $ENV{ANDROID_API_LEVEL} CACHE STRING "") + set(ANDROID_PLATFORM $ENV{ANDROID_API_LEVEL} CACHE STRING "") +else() + set(ANDROID_NATIVE_API_LEVEL ${CMAKE_SYSTEM_VERSION} CACHE STRING "") + set(ANDROID_PLATFORM ${CMAKE_SYSTEM_VERSION} CACHE STRING "") +endif() + if (VCPKG_TARGET_TRIPLET MATCHES "^arm64-android") set(ANDROID_ABI arm64-v8a CACHE STRING "") elseif(VCPKG_TARGET_TRIPLET MATCHES "^armv6-android")