From bc2023c63240b9f65a94fc0f809e8d193715bbbb Mon Sep 17 00:00:00 2001 From: "Karl W. Schulz" Date: Fri, 11 Nov 2022 06:44:40 -0600 Subject: [PATCH] add capture of git revision into VERSION.sha Signed-off-by: Karl W. Schulz [ROCm/rocprofiler-compute commit: 0d314be72dd0ea0a2e5116b092b4955912ce26ae] --- projects/rocprofiler-compute/.gitignore | 1 + projects/rocprofiler-compute/CMakeLists.txt | 15 +++++++++++++++ projects/rocprofiler-compute/cmake/VERSION.sha.in | 1 + 3 files changed, 17 insertions(+) create mode 100644 projects/rocprofiler-compute/cmake/VERSION.sha.in diff --git a/projects/rocprofiler-compute/.gitignore b/projects/rocprofiler-compute/.gitignore index 95f8be7bd8..aecccd7a1a 100644 --- a/projects/rocprofiler-compute/.gitignore +++ b/projects/rocprofiler-compute/.gitignore @@ -14,6 +14,7 @@ __pycache__ .coverage saved_analysis pmc_kernel_top.csv +VERSION.sha # temp files /tests/Testing \ No newline at end of file diff --git a/projects/rocprofiler-compute/CMakeLists.txt b/projects/rocprofiler-compute/CMakeLists.txt index 3ddf8b5341..5bf9a55811 100644 --- a/projects/rocprofiler-compute/CMakeLists.txt +++ b/projects/rocprofiler-compute/CMakeLists.txt @@ -33,6 +33,17 @@ project( include(ExternalProject) include(GNUInstallDirs) +# version control info +find_package(Git) + +if(Git_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") + execute_process( + COMMAND git log --pretty=format:%h -n 1 + OUTPUT_VARIABLE OMNIPERF_GIT_REV + OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) +endif() +message(STATUS "Git revision: ${GIT_REV}") + set(CMAKE_BUILD_TYPE "Release") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX @@ -151,6 +162,10 @@ if(LOCALHOST MATCHES "TheraS01|.*\.thera\.amd\.com|thera-hn") list(POP_BACK CMAKE_MESSAGE_INDENT) endif() +# git versioning file +configure_file(${PROJECT_SOURCE_DIR}/cmake/VERSION.sha.in + ${PROJECT_SOURCE_DIR}/VERSION.sha @ONLY) + enable_testing() add_test( diff --git a/projects/rocprofiler-compute/cmake/VERSION.sha.in b/projects/rocprofiler-compute/cmake/VERSION.sha.in new file mode 100644 index 0000000000..5b3d301508 --- /dev/null +++ b/projects/rocprofiler-compute/cmake/VERSION.sha.in @@ -0,0 +1 @@ +@OMNIPERF_GIT_REV@