Gradle:如何自动安装CMAKE

发布于 2025-01-24 19:57:19 字数 625 浏览 5 评论 0原文

我正在使用cmake构建的Android Native项目。 在我的build.gradle我指定:

if(project.hasProperty("native")) {
        externalNativeBuild {
            cmake {
                path file('jni/CMakeLists.txt')
                version '3.18.1+'
            }

        }
    }

我想从自动化构建服务器上的命令行调用externalNativeBuild任务。 但是,我会遇到此错误:

CMake '3.18.1' or higher was not found in SDK, PATH, or by cmake.dir property.

当我在Android Studio通常下载并安装cmake时,但它不是从命令行发生的。 有没有办法从命令行进行操作?

I am working on an Android native project which builds using CMake.
In my build.gradle I specify :

if(project.hasProperty("native")) {
        externalNativeBuild {
            cmake {
                path file('jni/CMakeLists.txt')
                version '3.18.1+'
            }

        }
    }

I want to invoke externalNativeBuild task from command-line only on an automated build server.
However I am getting this error:

CMake '3.18.1' or higher was not found in SDK, PATH, or by cmake.dir property.

When I build it inside Android Studio normally, It downloads and install CMake but it is not happening from command-line.
Is there a way to do it from command-line?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

在你怀里撒娇 2025-01-31 19:57:20

Android Studio将自动创建一个local.properties文件,其中包含cmake.dir属性。

当您在构建服务器上构建时,您的源很有可能没有local.properties文件,因为该文件通常不会被检查到代码存储库中。您要么需要创建此文件,要么修改path环境变量以包括cmake二进制。当然,这假定您在构建服务器上安装了CMAKE。您可以使用.zip/.tarball手动执行此操作,或者如果您可以访问构建服务器上的SDK,则可以使用build Tools -> 如何在命令上安装Android SDK构建工具行?

Android studio will automatically create a local.properties file which contains the cmake.dir property.

When you build on the build server, it's more than likely that you your source doesn't have a local.properties file as that file is not normally checked into code repositories. You'll either need to create this file or modify the PATH environment variable to include the cmake binary. This of course presumes that you have CMake installed on the build server. You can do this manually with a .zip/.tarball or if you have access to the SDK on the build server, you can install with the build tools -> How to install Android SDK Build Tools on the command line?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文