简体   繁体   English

Gradle 与 CMake git_describe 问题

[英]Gradle with CMake Issue with git_describe

I did run into issue with running gradle with cmake.我在运行 gradle 和 cmake 时遇到了问题。

This part of the code inside cmake file does not seem to work correctly cmake 文件中的这部分代码似乎无法正常工作

git_describe(GIT_DESCRIBE "--abbrev=7")

Because there is part of the code that depends on defined GIT_DESCRIBE and because git_describe fails block of that code does not gets execute.因为有部分代码依赖于定义的GIT_DESCRIBE并且因为git_describe失败,该代码块不会被执行。 And I want to make it work as expected thus executing this block of code.我想让它按预期工作,从而执行这段代码。

Here is the scheme of the Project:以下是该项目的方案:

-Root Dir of the Project:
  -Submodule of git repo
  -Rest of the files

Gradle File where it does set the Cmake (CMakeLists is contained inside of that submodule) Gradle 文件,其中设置了 Cmake(CMakeLists 包含在该子模块中)

        externalNativeBuild {
            cmake {
                path 'path/to/CMakeLists.txt'
            }
        }

It should work out of the box but when using this combination gradle + cmake it fails.它应该开箱即用,但是当使用这种组合gradle + cmake时它会失败。

Running git describe --abbrev=7 in terminal shows the expected value.在终端中运行git describe --abbrev=7会显示预期值。

I have replaced git_describe with execute_process我已将git_describe替换为execute_process

execute_process(COMMAND git describe --abbrev=7
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
        OUTPUT_VARIABLE GIT_DESCRIBE)

This solved issue.这解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM