Don't record Git version automatically via cmake (#12046)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/12046

This /sounds/ like a good idea in theory, but a feature
like this must be implemented very carefully, because if
you just plop the Git version in a header (that is included
by every file in your project, as macros.h is), then every
time you do a 'git pull', you will do a FULL rebuild, because
macros.h is going to regenerate to a new version and of course
you have to rebuild a source file if a header file changes.

I don't have time to implement it correctly, so I'm axing
the feature instead. If you want git versions in, e.g.,
nightly builds, please explicitly specify that when you feed
in the version.

Reviewed By: pjh5

Differential Revision: D10030556

fbshipit-source-id: 499d001c7b8ccd4ef15ce10dd6591c300c7df27d
diff --git a/caffe2/core/macros.h.in b/caffe2/core/macros.h.in
index a055de0..1888532 100644
--- a/caffe2/core/macros.h.in
+++ b/caffe2/core/macros.h.in
@@ -11,7 +11,6 @@
 #define CAFFE2_VERSION_MAJOR @CAFFE2_VERSION_MAJOR@
 #define CAFFE2_VERSION_MINOR @CAFFE2_VERSION_MINOR@
 #define CAFFE2_VERSION_PATCH @CAFFE2_VERSION_PATCH@
-#define CAFFE2_GIT_VERSION "@CAFFE2_GIT_VERSION@"
 
 static_assert(
     CAFFE2_VERSION_MINOR < 100,
@@ -54,7 +53,6 @@
 
 // Useful build settings that are recorded in the compiled binary
 #define CAFFE2_BUILD_STRINGS { \
-  {"GIT_VERSION", "${CAFFE2_GIT_VERSION}"}, \
   {"CXX_FLAGS", "${CMAKE_CXX_FLAGS}"}, \
   {"BUILD_TYPE", "${CMAKE_BUILD_TYPE}"}, \
   {"BLAS", "${BLAS}"}, \
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index 4fbf634..4607ef2 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -39,23 +39,6 @@
   endif()
 endif()
 
-# ---[ git: used to generate git build string.
-find_package(Git)
-if(GIT_FOUND)
-  execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty
-                  ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
-                  WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/.."
-                  OUTPUT_VARIABLE CAFFE2_GIT_VERSION
-                  RESULT_VARIABLE __git_result)
-  if(NOT ${__git_result} EQUAL 0)
-    set(CAFFE2_GIT_VERSION "unknown")
-  endif()
-else()
-  message(
-      WARNING
-      "Cannot find git, so Caffe2 won't have any git build info available")
-endif()
-
 # ---[ BLAS
 if(NOT BUILD_ATEN_MOBILE)
   set(BLAS "MKL" CACHE STRING "Selected BLAS library")
diff --git a/cmake/Summary.cmake b/cmake/Summary.cmake
index 16d18ac..3df260f 100644
--- a/cmake/Summary.cmake
+++ b/cmake/Summary.cmake
@@ -5,7 +5,6 @@
   message(STATUS "General:")
   message(STATUS "  CMake version         : ${CMAKE_VERSION}")
   message(STATUS "  CMake command         : ${CMAKE_COMMAND}")
-  message(STATUS "  Git version           : ${CAFFE2_GIT_VERSION}")
   message(STATUS "  System                : ${CMAKE_SYSTEM_NAME}")
   message(STATUS "  C++ compiler          : ${CMAKE_CXX_COMPILER}")
   message(STATUS "  C++ compiler version  : ${CMAKE_CXX_COMPILER_VERSION}")