diff --git a/CMLibGit.cmake b/CMLibGit.cmake index 7733432..94ced49 100644 --- a/CMLibGit.cmake +++ b/CMLibGit.cmake @@ -5,10 +5,12 @@ elseif(ARGV0) set(output_file ${ARGV0}) endif() -add_custom_target(git-version ALL ${CMAKE_COMMAND} - -DCMLIB_PROJECT_NAME_UPPER=${CMLIB_PROJECT_NAME_UPPER} - -DCMLIB_MODULE_DIR=${CMLIB_MODULE_DIR} - -DCMLIB_GIT_VERSION_FILE=${output_file} -P ${CMLIB_MODULE_DIR}/CMLibGitVersion.cmake +# cmake-format: off +add_custom_target(git-version ALL + ${CMAKE_COMMAND} -DCMLIB_PROJECT_NAME_UPPER=${CMLIB_PROJECT_NAME_UPPER} + -DCMLIB_MODULE_DIR=${CMLIB_MODULE_DIR} + -DCMLIB_GIT_VERSION_FILE=${output_file} -P ${CMLIB_MODULE_DIR}/CMLibGitVersion.cmake WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) +# cmake-format: on unset(output_file) diff --git a/CMLibGitVersion.cmake b/CMLibGitVersion.cmake index 880c071..fbb9bad 100644 --- a/CMLibGitVersion.cmake +++ b/CMLibGitVersion.cmake @@ -3,8 +3,6 @@ set(CMLIB_GIT_DIFF "") set(CMLIB_GIT_TAG "N/A") set(CMLIB_GIT_BRANCH "N/A") -message("aaaaaa") - find_program(GIT_EXECUTABLE git) if(GIT_EXECUTABLE) execute_process(COMMAND git log --pretty=format:'%h' -n 1 OUTPUT_VARIABLE CMLIB_GIT_REV ERROR_QUIET) @@ -18,7 +16,7 @@ if(GIT_EXECUTABLE) execute_process(COMMAND git rev-parse --abbrev-ref HEAD OUTPUT_VARIABLE CMLIB_GIT_BRANCH) string(STRIP "${CMLIB_GIT_REV}" CMLIB_GIT_REV) - string(SUBSTRING "${CMLIB_GIT_REV}" 1 8 CMLIB_GIT_REV) + string(SUBSTRING "${CMLIB_GIT_REV}" 1 7 CMLIB_GIT_REV) string(STRIP "${CMLIB_GIT_DIFF}" CMLIB_GIT_DIFF) string(STRIP "${CMLIB_GIT_TAG}" CMLIB_GIT_TAG) string(STRIP "${CMLIB_GIT_BRANCH}" CMLIB_GIT_BRANCH)