Commit 3ffd16a8 authored by Kenneth Moreland's avatar Kenneth Moreland

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.
parent d32f3457
......@@ -39,9 +39,10 @@ cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
# The VTKm version number
set(VTKm_MAJOR_VERSION "@VTKm_MAJOR_VERSION@")
set(VTKm_MINOR_VERSION "@VTKm_MINOR_VERSION@")
set(VTKm_PATCH_VERSION "@VTKm_PATCH_VERSION@")
set(VTKm_VERSION_MAJOR "@VTKm_VERSION_MAJOR@")
set(VTKm_VERSION_MINOR "@VTKm_VERSION_MINOR@")
set(VTKm_VERSION_PATCH "@VTKm_VERSION_PATCH@")
set(VTKm_VERSION_FULL "@VTKm_VERSION_FULL@")
set(VTKm_VERSION "@VTKm_VERSION@")
# This is true when the package is still in the build directory (not installed)
......
##============================================================================
## Copyright (c) Kitware, Inc.
## All rights reserved.
## See LICENSE.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 above copyright notice for more information.
##
## Copyright 2017 Sandia Corporation.
## Copyright 2017 UT-Battelle, LLC.
## Copyright 2017 Los Alamos National Security.
##
## Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
## the U.S. Government retains certain rights in this software.
##
## Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
## Laboratory (LANL), the U.S. Government retains certain rights in
## this software.
##============================================================================
# Used to determine the version for VTK-m source using "git describe", if git
# is found. On success sets the following variables in caller's scope:
# ${var_prefix}_VERSION
# ${var_prefix}_VERSION_MAJOR
# ${var_prefix}_VERSION_MINOR
# ${var_prefix}_VERSION_PATCH
# ${var_prefix}_VERSION_PATCH_EXTRA
# ${var_prefix}_VERSION_FULL
# ${var_prefix}_VERSION_IS_RELEASE is true, if patch-extra is empty.
#
# If git is not found, or git describe cannot be run successfully, then these
# variables are left unchanged and a status message is printed.
#
# Arguments are:
# source_dir : Source directory
# git_command : git executable
# var_prefix : prefix for variables e.g. "VTKm".
function(determine_version source_dir git_command var_prefix)
if ("$Format:$" STREQUAL "")
# We are in an exported tarball and should use the shipped version
# information. Just return here to avoid the warning message at the end of
# this function.
return ()
elseif (NOT VTKm_GIT_DESCRIBE)
if(EXISTS ${git_command})
execute_process(
COMMAND ${git_command} describe
WORKING_DIRECTORY ${source_dir}
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
endif()
else()
set(result 0)
set(output ${VTKm_GIT_DESCRIBE})
endif()
extract_version_components("${output}" tmp)
if(DEFINED tmp_VERSION)
message(STATUS "Determined Source Version : ${tmp_VERSION_FULL}")
foreach(suffix VERSION VERSION_MAJOR VERSION_MINOR VERSION_PATCH
VERSION_PATCH_EXTRA VERSION_FULL VERSION_IS_RELEASE)
set(${var_prefix}_${suffix} ${tmp_${suffix}} PARENT_SCOPE)
endforeach()
else()
message(STATUS
"Could not use git to determine source version, using version ${${var_prefix}_VERSION_FULL}")
endif()
endfunction()
# Extracts components from a version string. See determine_version() for usage.
function(extract_version_components version_string var_prefix)
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)[-]*(.*)"
version_matches "${version_string}")
if(CMAKE_MATCH_0)
set(full ${CMAKE_MATCH_0})
set(major ${CMAKE_MATCH_1})
set(minor ${CMAKE_MATCH_2})
set(patch ${CMAKE_MATCH_3})
set(patch_extra ${CMAKE_MATCH_4})
set(${var_prefix}_VERSION "${major}.${minor}" PARENT_SCOPE)
set(${var_prefix}_VERSION_MAJOR ${major} PARENT_SCOPE)
set(${var_prefix}_VERSION_MINOR ${minor} PARENT_SCOPE)
set(${var_prefix}_VERSION_PATCH ${patch} PARENT_SCOPE)
set(${var_prefix}_VERSION_PATCH_EXTRA ${patch_extra} PARENT_SCOPE)
set(${var_prefix}_VERSION_FULL ${full} PARENT_SCOPE)
if("${major}.${minor}.${patch}" VERSION_EQUAL "${full}")
set(${var_prefix}_VERSION_IS_RELEASE TRUE PARENT_SCOPE)
else()
set(${var_prefix}_VERSION_IS_RELEASE FALSE PARENT_SCOPE)
endif()
endif()
endfunction()
......@@ -27,11 +27,6 @@ cmake_minimum_required(VERSION 3.3)
project (VTKm)
set(VTKm_MAJOR_VERSION 1)
set(VTKm_MINOR_VERSION 1)
set(VTKm_PATCH_VERSION 0)
set(VTKm_VERSION "${VTKm_MAJOR_VERSION}.${VTKm_MINOR_VERSION}.${VTKm_PATCH_VERSION}")
set(VTKm_INSTALL_INCLUDE_DIR "include")
set(VTKm_INSTALL_CONFIG_DIR "lib")
set(VTKm_INSTALL_LIB_DIR "lib")
......@@ -43,6 +38,15 @@ set(VTKm_EXPORT_NAME "VTKmTargets")
set(VTKm_CMAKE_MODULE_PATH ${VTKm_SOURCE_DIR}/CMake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${VTKm_CMAKE_MODULE_PATH})
# Determine VTK-m version
include(Utilities/Git/Git.cmake)
include(VTKmDetermineVersion)
# Load hardcoded version in case this is not a Git repository
file(STRINGS version.txt version_txt)
extract_version_components("${version_txt}" "VTKm")
# Get the version from git if we can
determine_version(${VTKm_SOURCE_DIR} ${GIT_EXECUTABLE} "VTKm")
# include some vtkm-specific cmake code.
include(VTKmMacros)
......@@ -314,9 +318,9 @@ install(EXPORT ${VTKm_EXPORT_NAME}
set(CPACK_PACKAGE_DESCRIPTION_FILE ${VTKm_SOURCE_DIR}/README.md)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The VTKm Toolkit")
set(CPACK_PACKAGE_NAME "VTKm")
set(CPACK_PACKAGE_VERSION_MAJOR ${VTKm_MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${VTKm_MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${VTKm_PATCH_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR ${VTKm_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VTKm_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${VTKm_VERSION_PATCH})
set(CPACK_PACKAGE_FILE_NAME "VTKm-${VTKm_VERSION}")
set(CPACK_RESOURCE_FILE_LICENSE ${VTKm_SOURCE_DIR}/LICENSE.txt)
set(CPACK_RESOURCE_FILE_README ${VTKm_SOURCE_DIR}/README.md)
......
......@@ -72,6 +72,7 @@ licenses.
- - - - - - - - - - - - - - - - - - - - - - - - do not remove this line
CMake/FindTBB.cmake
CMake/FindGLEW.cmake
Utilities
vtkm/cont/tbb/internal/parallel_sort.h
vtkm/testing/OptionParser.h
vtkm/internal/brigand.hpp
\ No newline at end of file
vtkm/internal/brigand.hpp
# Generated in source tree by GitInfo script
GitInfo.cmake
#=============================================================================
# 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.
#=============================================================================
# Check for a hint left by the 'GitInfo' script.
if(NOT GIT_EXECUTABLE)
get_filename_component(_Git_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
include(${_Git_DIR}/GitInfo.cmake OPTIONAL)
if(GitInfo_GIT_EXECUTABLE)
if(EXISTS "${GitInfo_GIT_EXECUTABLE}")
set(GIT_EXECUTABLE "${GitInfo_GIT_EXECUTABLE}")
elseif(EXISTS "${GitInfo_GIT_EXECUTABLE}.exe")
set(GIT_EXECUTABLE "${GitInfo_GIT_EXECUTABLE}.exe")
endif()
endif()
endif()
# Find Git.
find_package(Git)
#!/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"'")
'
This diff is collapsed.
Git Support Scripts
Copyright 2011 Kitware, Inc.
This product includes software developed at Kitware, Inc.
(http://www.kitware.com/).
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment