-
Hello, I'm trying to use a custom triplet that defines {
"version": 6,
"configurePresets": [
{
"name": "target-arm64-android",
"hidden": true,
"cacheVariables": {
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/toolchains/android.cmake",
"VCPKG_TARGET_TRIPLET": "arm64-android-aspire",
"VCPKG_INSTALL_OPTIONS": "--allow-unsupported;--debug-env",
"VCPKG_KEEP_ENV_VARS": "ANDROID_HOME;ANDROID_NDK_HOME",
"ANDROID_STL": "c++_shared",
"ANDROID_SDK_ROOT": "$env{ANDROID_HOME}",
"ANDROID_PLATFORM": "34",
"ANDROID_ABI": "arm64-v8a"
}
}
]
} Triplet: set(VCPKG_TARGET_ARCHITECTURE arm64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Android)
set(VCPKG_MAKE_BUILD_TRIPLET "--host=aarch64-linux-android")
set(VCPKG_CMAKE_CONFIGURE_OPTIONS -DANDROID_ABI=arm64-v8a)
set(VCPKG_BUILD_TYPE release)
# Only use Qt as shared libraries.
if(${PORT} MATCHES "qt")
set(VCPKG_LIBRARY_LINKAGE dynamic)
endif()
message(STATUS "ANDROID_HOME: $ENV{ANDROID_HOME}")
# Qt requires that the ANDROID_SDK_ROOT is defined when compiling.
set(ANDROID_SDK_ROOT "$ENV{ANDROID_HOME}")
set(ANDROID_PLATFORM 34) The preset in combination with the triplet enables me to cross-compile Qt libraries using arm64 android on Linux or Windows. The line, The actual command that vcpkg runs with cmake looks something like the following (you can see where VCPKG_KEEP_ENV_VARS attempts to be defined): d:\dev\aspire/vcpkg/downloads/tools/cmake-3.29.2-windows/cmake-3.29.2-windows-i386/bin/cmake -DVCPKG_HOST_TRIPLET=x64-windows-aspire -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=D:/dev/aspire/vcpkg/scripts/toolchains/android.cmake -DVCPKG_TARGET_TRIPLET=arm64-android-aspire -DVCPKG_INSTALL_OPTIONS="--allow-unsupported;--debug-env" -DVCPKG_KEEP_ENV_VARS="ANDROID_HOME;ANDROID_NDK_HOME" -DVCPKG_ENV_PASSTHROUGH="ANDROID_HOME;ANDROID_NDK_HOME" -DANDROID_STL=c++_shared -DANDROID_SDK_ROOT=C:/Qt/android/sdk -DANDROID_PLATFORM=34 -DANDROID_ABI=arm64-v8a -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=cl -DCMAKE_C_COMPILER=cl -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_TOOLCHAIN_FILE=D:/dev/aspire/vcpkg/scripts/buildsystems/vcpkg.cmake -SD:/dev/aspire -BD:/dev/aspire/build I'm wondering if I'm missing something? I can access the environment variables from my own cmake files but I can't seem to access them from the triplet. Any thoughts or suggestions for me to try? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
If it helps others in the future. While I don't know why this worked on Linux. The official vcpkg documentation states Therefore, the solution is to use the {
"version": 6,
"configurePresets": [
{
"name": "target-arm64-android",
"hidden": true,
"cacheVariables": {
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/toolchains/android.cmake",
"VCPKG_TARGET_TRIPLET": "arm64-android-aspire",
"VCPKG_INSTALL_OPTIONS": "--allow-unsupported;--debug-env",
"ANDROID_STL": "c++_shared",
"ANDROID_SDK_ROOT": "$env{ANDROID_HOME}",
"ANDROID_PLATFORM": "34",
"ANDROID_ABI": "arm64-v8a"
},
"environment": {
"VCPKG_KEEP_ENV_VARS": "ANDROID_HOME;ANDROID_NDK_HOME"
}
}
]
} |
Beta Was this translation helpful? Give feedback.
-
It doesn't. It has no effect on Linux.
There are triplet variables |
Beta Was this translation helpful? Give feedback.
If it helps others in the future. While I don't know why this worked on Linux. The official vcpkg documentation states
VCPKG_KEEP_ENV_VARS
is to be defined as an environment variable.Therefore, the solution is to use the
environment
key to define the values instead of thecacheVariables
.