vtk-m/Utilities/Git/GitInfo
Kenneth Moreland 3ffd16a8a6 Add ability to get VTK-m version from git
In addition to keeping the version number accurate, this will help us
differentiate between-the-numbers commits.
2017-01-26 10:02:04 -07:00

58 lines
1.5 KiB
Bash

#!/usr/bin/env bash
#=============================================================================
# Copyright 2011 Kitware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
# Path conversion function.
case "$(uname)" in
*CYGWIN*)
native_path() {
cygpath -m "$1"
}
;;
*MINGW*)
native_path() {
cmd //c echo "$1" | sed 's/^"//;s/"$//'
}
;;
*)
native_path() {
echo "$1"
}
;;
esac
# Compute native path to "git" executable.
if git="$(type -p git)"; then
git="$(native_path "${git}")"
else
git=''
fi
# Compute native path to ".git" dir.
if dir="$(git rev-parse --git-dir)"; then
dir="$(cd "$dir"; pwd)"
git_dir="$(native_path "${dir}")"
else
git_dir=''
fi
# Store the values in a CMake file next to this script.
echo >"${BASH_SOURCE%/*}/GitInfo.cmake" '# Generated by GitInfo
set(GitInfo 1)
set(GitInfo_GIT_EXECUTABLE "'"$git"'")
set(GitInfo_GIT_DIR "'"$git_dir"'")
'