1set(VERSION_MAJOR 2) 2set(VERSION_MINOR 0) 3set(VERSION_PATCH 7) 4set(VERSION_COMMIT 0) 5 6find_program(GIT git) 7# TODO(kaiyili, b/243773680): the upstream version detect script will break the 8# build. Upstream a change to fix this, and revert the following lines. 9if(FALSE AND GIT AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") 10 execute_process( 11 COMMAND ${GIT} describe --tags 12 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 13 OUTPUT_VARIABLE GIT_DESCRIBE_DIRTY 14 OUTPUT_STRIP_TRAILING_WHITESPACE 15 RESULT_VARIABLE GIT_DESCRIBE_RESULT 16 ) 17 18 if(GIT_DESCRIBE_RESULT EQUAL 0) 19 string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GIT_DESCRIBE_DIRTY}") 20 string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GIT_DESCRIBE_DIRTY}") 21 string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GIT_DESCRIBE_DIRTY}") 22 string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+).*" "\\1" VERSION_COMMIT "${GIT_DESCRIBE_DIRTY}") 23 else() 24 message(WARNING "git describe failed with exit code: ${GIT_DESCRIBE_RESULT}") 25 endif() 26else() 27 message(WARNING "git is not found") 28endif() 29 30message(STATUS "Proceeding with version: ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_COMMIT}") 31