简体   繁体   中英

Gradle with CMake Issue with git_describe

I did run into issue with running gradle with cmake.

This part of the code inside cmake file does not seem to work correctly

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. 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)

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

It should work out of the box but when using this combination gradle + cmake it fails.

Running git describe --abbrev=7 in terminal shows the expected value.

I have replaced git_describe with execute_process

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

This solved issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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