Merge "Fixes inconsistent spelling of Git cmake variables" into release-4-6
authorRoland Schulz <roland@utk.edu>
Sun, 27 Nov 2011 23:57:57 +0000 (00:57 +0100)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Sun, 27 Nov 2011 23:57:57 +0000 (00:57 +0100)
cmake/FindGit.cmake [new file with mode: 0644]
cmake/gmxGenerateVersionInfo.cmake
src/gmxlib/CMakeLists.txt

diff --git a/cmake/FindGit.cmake b/cmake/FindGit.cmake
new file mode 100644 (file)
index 0000000..2d82142
--- /dev/null
@@ -0,0 +1,46 @@
+# The module defines the following variables:
+#   GIT_EXECUTABLE - path to git command line client
+#   GIT_FOUND - true if the command line client was found
+# Example usage:
+#   find_package(Git)
+#   if(GIT_FOUND)
+#     message("git found: ${GIT_EXECUTABLE}")
+#   endif()
+
+#=============================================================================
+# Copyright 2010 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distributed this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+# Look for 'git' or 'eg' (easy git)
+#
+set(git_names git eg)
+
+# Prefer .cmd variants on Windows unless running in a Makefile
+# in the MSYS shell.
+#
+if(WIN32)
+  if(NOT CMAKE_GENERATOR MATCHES "MSYS")
+    set(git_names git.cmd git eg.cmd eg)
+  endif()
+endif()
+
+find_program(GIT_EXECUTABLE
+  NAMES ${git_names}
+  DOC "git command line client"
+  )
+mark_as_advanced(GIT_EXECUTABLE)
+
+# Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if
+# all listed variables are TRUE
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Git DEFAULT_MSG GIT_EXECUTABLE)
index e1359cb968b54ec8262a1d34d8e5645ed4d0c5d1..165a941d34c7f37370808b3259686f6f623d3296 100644 (file)
@@ -7,8 +7,8 @@
 # GEN_VERSION_INFO_INTERNAL has to be set ON.
 #
 # The following variables have to be previously defined: 
-# Git_EXECUTABLE        - path to git binary
-# Git_VERSION           - git version (if not defined it's assumed that >=1.5.3)
+# GIT_EXECUTABLE        - path to git binary
+# GIT_VERSION           - git version (if not defined it's assumed that >=1.5.3)
 # PROJECT_VERSION       - hard-coded version string, should have the following structure: 
 #                       VERSION[-dev-SUFFIX] where the VERSION can have any form and the suffix 
 #                       is optional but should start with -dev
@@ -48,9 +48,9 @@ endif()
 # if git executable xists and it's compatible version
 # build the development version string 
 # this should at some point become VERSION_LESS
-if(EXISTS ${Git_EXECUTABLE} AND NOT Git_VERSION STRLESS "1.5.1")
+if(EXISTS ${GIT_EXECUTABLE} AND NOT ${GIT_VERSION} STRLESS "1.5.1")
     # refresh git index 
-    execute_process(COMMAND ${Git_EXECUTABLE} update-index -q --refresh
+    execute_process(COMMAND ${GIT_EXECUTABLE} update-index -q --refresh
         WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
         TIMEOUT 5
         OUTPUT_QUIET
@@ -59,7 +59,7 @@ if(EXISTS ${Git_EXECUTABLE} AND NOT Git_VERSION STRLESS "1.5.1")
     ) 
 
    # get the full hash of the current HEAD 
-    execute_process(COMMAND ${Git_EXECUTABLE} rev-parse HEAD
+    execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
         WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
         OUTPUT_VARIABLE GMX_GIT_HEAD_HASH
         ERROR_VARIABLE EXEC_ERR
@@ -69,7 +69,7 @@ if(EXISTS ${Git_EXECUTABLE} AND NOT Git_VERSION STRLESS "1.5.1")
     string(SUBSTRING ${GMX_GIT_HEAD_HASH} 0 5 HEAD_HASH_SHORT) 
 
     # if there are local uncommitted changes, the build gets labeled "dirty"
-    execute_process(COMMAND ${Git_EXECUTABLE} diff-index --name-only HEAD
+    execute_process(COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD
         WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
         OUTPUT_VARIABLE SRC_LOCAL_CHANGES
         ERROR_VARIABLE EXEC_ERR
@@ -83,8 +83,8 @@ if(EXISTS ${Git_EXECUTABLE} AND NOT Git_VERSION STRLESS "1.5.1")
     # if git is older then 1.5.3 we need to extract the RFC2822 style date 
     # and massage it, otherwise the ISO 8601 format is more trusworthy
     # this should at some point become VERSION_LESS
-    if (NOT Git_VERSION STREQUAL "" AND Git_VERSION STRLESS "1.5.3")
-        execute_process(COMMAND ${Git_EXECUTABLE} rev-list -n1 "--pretty=format:%cD" HEAD
+    if (NOT GIT_VERSION STREQUAL "" AND GIT_VERSION STRLESS "1.5.3")
+        execute_process(COMMAND ${GIT_EXECUTABLE} rev-list -n1 "--pretty=format:%cD" HEAD
             WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
             OUTPUT_VARIABLE HEAD_DATE
             ERROR_VARIABLE EXEC_ERR
@@ -111,7 +111,7 @@ if(EXISTS ${Git_EXECUTABLE} AND NOT Git_VERSION STRLESS "1.5.1")
         string(REGEX REPLACE "DEC" "12" HEAD_DATE ${HEAD_DATE})
     else()
         # get the date of the HEAD commit
-        execute_process(COMMAND ${Git_EXECUTABLE} rev-list -n1 "--pretty=format:%ci" HEAD
+        execute_process(COMMAND ${GIT_EXECUTABLE} rev-list -n1 "--pretty=format:%ci" HEAD
             WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
             OUTPUT_VARIABLE HEAD_DATE
             ERROR_VARIABLE EXEC_ERR
@@ -126,7 +126,7 @@ if(EXISTS ${Git_EXECUTABLE} AND NOT Git_VERSION STRLESS "1.5.1")
     set(VERSION_STR_SUFFIX "${HEAD_DATE}-${HEAD_HASH_SHORT}${DIRTY_STR}") 
     
     # find the name of the remote which is located on the official gromacs git server
-    execute_process(COMMAND ${Git_EXECUTABLE} config --get-regexp 
+    execute_process(COMMAND ${GIT_EXECUTABLE} config --get-regexp 
                     "remote\\..*\\.url" "git\\.gromacs\\.org[:|/]gromacs"
         WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
         OUTPUT_VARIABLE GMX_REMOTE
@@ -143,7 +143,7 @@ if(EXISTS ${Git_EXECUTABLE} AND NOT Git_VERSION STRLESS "1.5.1")
         # find the first ancestor in the list provided by rev-list (not 
         # necessarily the last though) which is in GMX_REMOTE, extract the 
         # hash and the number of commits HEAD is ahead with 
-        execute_process(COMMAND ${Git_EXECUTABLE} rev-list --max-count=100 HEAD
+        execute_process(COMMAND ${GIT_EXECUTABLE} rev-list --max-count=100 HEAD
             WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
             OUTPUT_VARIABLE ANCESTOR_LIST
         )
@@ -152,7 +152,7 @@ if(EXISTS ${Git_EXECUTABLE} AND NOT Git_VERSION STRLESS "1.5.1")
         set(AHEAD 0)
         set(GMX_GIT_REMOTE_HASH "")
         foreach(OBJ ${ANCESTOR_LIST})
-            execute_process(COMMAND ${Git_EXECUTABLE} name-rev --refs=refs/remotes/${GMX_REMOTE}/* ${OBJ}
+            execute_process(COMMAND ${GIT_EXECUTABLE} name-rev --refs=refs/remotes/${GMX_REMOTE}/* ${OBJ}
                 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
                 OUTPUT_VARIABLE HASH_AND_REVNAME
                 OUTPUT_STRIP_TRAILING_WHITESPACE
index 021ed19ad138962f38f83df5185f93193b09a5b8..4a681b24aee8ebeb67f6a1f2b9b96cb3765ea216 100644 (file)
@@ -6,8 +6,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 if(USE_VERSION_H)
     add_custom_target(gmx_version ALL
             COMMAND ${CMAKE_COMMAND} 
-                -D Git_EXECUTABLE="${Git_EXECUTABLE}"
-                -D Git_VERSION="${Git_VERSION}"
+                -D GIT_EXECUTABLE="${GIT_EXECUTABLE}"
+                -D GIT_VERSION="${GIT_VERSION}"
                 -D PROJECT_VERSION="${PROJECT_VERSION}"
                 -D PROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}"
                 -D VERSION_C_CMAKEIN="${CMAKE_SOURCE_DIR}/src/gmxlib/version.c.cmakein"