From 08b21339ec3c53e2c738df81899c79746e35b21b Mon Sep 17 00:00:00 2001 From: Braulio Valdivielso Date: Mon, 23 Aug 2021 23:06:04 +0100 Subject: [PATCH] print out git status information at configure stage This fixes #24373. Having the git status information available in the CMake logs will make it easier to troubleshoot build failure reports. --- CMakeLists.txt | 1 + cmake/git_status.cmake | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 cmake/git_status.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 1aef8c9fc8d..8a5a6293f7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,7 @@ include (cmake/arch.cmake) include (cmake/target.cmake) include (cmake/tools.cmake) include (cmake/analysis.cmake) +include (cmake/git_status.cmake) # Ignore export() since we don't use it, # but it gets broken with a global targets via link_libraries() diff --git a/cmake/git_status.cmake b/cmake/git_status.cmake new file mode 100644 index 00000000000..8748aacfedd --- /dev/null +++ b/cmake/git_status.cmake @@ -0,0 +1,17 @@ +# Print the status of the git repository (if git is available). +# This is useful for troubleshooting build failure reports +find_package(Git) + +if (Git_FOUND) + execute_process( + COMMAND ${GIT_EXECUTABLE} rev-parse HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_ID + OUTPUT_STRIP_TRAILING_WHITESPACE) + message(STATUS "HEAD's commit hash ${GIT_COMMIT_ID}") + execute_process( + COMMAND ${GIT_EXECUTABLE} status + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) +else() + message(STATUS "The git program could not be found.") +endif()