Android插件将使用哪个cmake? [英] which cmake will Android plugin use?
问题描述
在Android Studio 3.3中,我使用了本机(C ++)库,该库是我用CMake构建的. Android插件(3.2.1版)将根据externalNativeBuild
的配置选择内置"或外部" cmake,如
With Android Studio 3.3 I use native (C++) library, which I built with CMake. The Android plugin (v. 3.2.1) will choose the 'builtin' or 'external' cmake, depending on the configuration of externalNativeBuild
, as documented at developer.android.com.
我想添加一个额外的自定义任务(安装),该任务应使用与Android插件相同的 cmake 版本.但是即使使用内置" cmake,也不清楚路径是什么.我可以找到android.sdkDirectory
,但是即使今天我也有sdk\cmake\3.6.4111459
和sdk\cmake\3.10.2.4988404
,由于某些奇怪的原因,我的一些项目选择了 3.6 ,而其他项目则使用了 3.10 强>.这与Android Studio的官方发行说明相矛盾,该发行说明"Gradle默认仍使用3.6.0版本" ,但是……
I want to add an extra custom task (install) that should use the same cmake version as the Android Plugin. But even with the 'builtin' cmake, it's not clear what the path is. I can find android.sdkDirectory
, but even there I have today sdk\cmake\3.6.4111459
and sdk\cmake\3.10.2.4988404
, and for some strange reason, some of my projects choose 3.6, while others use 3.10. This contradicts the official the release notes for Android Studio that "Gradle still uses version 3.6.0 by default", but well…
如何在不重新实现Android插件晦涩的逻辑的情况下决定使用哪个?
How can I decide which to use, without reimplementing the Android Plugin's obscure logic?
一种可能有用的解决方法,解析生成的文件.externalNativeBuild/cmake/debug/armeabi-v7a/cmake_build_command.txt
的第一行:
One workaround that may help, parse the first line of the generated file .externalNativeBuild/cmake/debug/armeabi-v7a/cmake_build_command.txt
:
Executable : C:\local\Android\sdk\cmake\3.10.2.4988404\bin\cmake.exe
这仍然需要一些调整,因为更高版本的构建工具将使用.cxx
而不是.externalNativeBuild
;构建变体名称可能也不同.
This still needs some adjustments, because the later versions of build tools will use .cxx
instead of .externalNativeBuild
; the build variant names may be different too.
推荐答案
Android Studio将在sdk\cmake
下获取最新CMake版本,但是您可以通过
Android Studio will pick up the latest CMake version under sdk\cmake
, but you can configure your particular version from
externalNativeBuild {
cmake {
...
version "cmake-version"
}
}
并在local.properties
cmake.dir="path-to-cmake"
或者,您可以选择不要从SDK Manager升级CMake (只需删除sdk\cmake\<version to delete>
文件夹就可以了),这样您就可以坚持使用您项目适合的CMake版本.
Or, you can choose NOT to upgrade your CMake from SDK Manager (just to delete the sdk\cmake\<version to delete>
folder will be fine) so that you can stick to the CMake version your project is comfortable with.
这篇关于Android插件将使用哪个cmake?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!