Commit ebf6777d authored by Brad King's avatar Brad King

Refactor VTK version handling

Move VTK_(MAJOR|MINOR|BUILD)_VERSION out of "CMakeLists.txt" into
dedicated file "CMake/vtkVersion.cmake".  Move the preprocessor macros
from "vtkConfigure.h" to new configured header "vtkVersionMacros.h".
This avoids rebuilding everything when the version number changes.
Include the new header from the old location to provide the macros for
compatibility unless VTK_LEGACY_REMOVE is ON.

Define the BUILD version to be a date during development and the patch
level for releases (or during preparation of one as we are currently).
The CMake package version file (VTKConfigVersion.cmake) already does
this so make the C++-presented version consistent with it.  Add a
"CMake/vtkVersion.bash" script to help a nightly robot update the build
version when it is a date.  This replaces KWSys DateStamp for VTK.

Compile the wrapping parser with only the major and minor version number
components instead of the full version number.  This avoids causing a
full rebuild of all wrappers whenever the build version component
changes.  The wrapper only needs the version to provide its --version
option anyway.

Teach the documentation generation scripts to extract the VTK version
numbers from the new version file.  Drop the separate revision file
infrastructure because everything is now in one version file.

Also remove unused file CMake/VTKVersionMacros.cmake.

Change-Id: If988b32c738e6161237f7e3edaff49e75cb15b25
parent 7f6a8423
# ---------------------------------------------------------------------------
# VTK_GET_SOURCE_REVISION_AND_DATE
# Get vtkVTKVersion's source revision and date and store them in
# ${revision_varname} and ${date_varname} respectively.
#
# This macro can be used to require a specific revision of the VTK
# library in between version changes.
# For example:
# INCLUDE("${VTK_CMAKE_DIR}/VTKVersionMacros.cmake")
# VTK_GET_SOURCE_REVISION_AND_DATE(source_revision source_date)
# IF(source_revision LESS 1.4)
# MESSAGE(FATAL_ERROR "Sorry, your VTK library was last updated on ${source_date}. Its source revision, according to vtkVTKVersion.h, is ${source_revision}. Please update to a newer revision.")
# ENDIF(source_revision LESS 1.4)
MACRO(VTK_GET_SOURCE_REVISION_AND_DATE
revision_varname
date_varname)
SET(${revision_varname})
SET(${date_varname})
SET(___vtk_version_found)
FOREACH(dir ${VTK_INCLUDE_DIRS} ${VTK_INCLUDE_PATH})
IF(NOT ___vtk_version_found)
SET(file "${dir}/vtkVersion.h")
IF(EXISTS ${file})
FILE(READ ${file} file_contents)
STRING(REGEX REPLACE "(.*Revision: )([0-9]+\\.[0-9]+)( .*)" "\\2"
${revision_varname} "${file_contents}")
STRING(REGEX REPLACE "(.*Date: )(.+)( \\$.*)" "\\2"
${date_varname} "${file_contents}")
SET(___vtk_version_found 1)
ENDIF(EXISTS ${file})
ENDIF(NOT ___vtk_version_found)
ENDFOREACH(dir)
IF(NOT ${revision_varname} OR NOT ${date_varname})
MESSAGE(FATAL_ERROR "Sorry, vtkVTKVersion's source revision could not be found, either because vtkVTKVersion.h is nowhere in sight, or its contents could not be parsed successfully.")
ENDIF(NOT ${revision_varname} OR NOT ${date_varname})
ENDMACRO(VTK_GET_SOURCE_REVISION_AND_DATE)
......@@ -207,14 +207,6 @@ endforeach()
SET(_VTK_VERSION_MAJOR ${VTK_MAJOR_VERSION})
SET(_VTK_VERSION_MINOR ${VTK_MINOR_VERSION})
SET(_VTK_VERSION_PATCH ${VTK_BUILD_VERSION})
# We use odd minor numbers for development versions.
# Use a date for the development patch level.
if("${_VTK_VERSION_MINOR}" MATCHES "[13579]$")
include(${VTK_SOURCE_DIR}/Utilities/KWSys/vtksys/kwsysDateStamp.cmake)
set(_VTK_VERSION_PATCH
"${KWSYS_DATE_STAMP_YEAR}${KWSYS_DATE_STAMP_MONTH}${KWSYS_DATE_STAMP_DAY}"
)
endif()
# Create list of available modules and libraries.
set(VTK_CONFIG_MODULES_ENABLED "")
......
#!/usr/bin/env bash
# Update the version component if it looks like a date or -f is given.
if test "x$1" = "x-f"; then shift ; n='*' ; else n='\{8\}' ; fi
if test "$#" -gt 0; then echo 1>&2 "usage: vtkVersion.bash [-f]"; exit 1; fi
sed -i -e '
s/\(^set(VTK_BUILD_VERSION\) [0-9]'"$n"'\(.*\)/\1 '"$(date +%Y%m%d)"'\2/
' "${BASH_SOURCE%/*}/vtkVersion.cmake"
# VTK version number components.
set(VTK_MAJOR_VERSION 6)
set(VTK_MINOR_VERSION 0)
set(VTK_BUILD_VERSION 0)
......@@ -57,10 +57,7 @@ option(BUILD_SHARED_LIBS "Build VTK with shared libraries." ON)
set(VTK_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
#-----------------------------------------------------------------------------
# VTK version number. An even minor number corresponds to releases.
set(VTK_MAJOR_VERSION 6)
set(VTK_MINOR_VERSION 0)
set(VTK_BUILD_VERSION 0)
include(vtkVersion)
set(VTK_VERSION
"${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.${VTK_BUILD_VERSION}")
......
......@@ -136,6 +136,7 @@ SET(Module_SRCS
vtkSystemIncludes.h
${CMAKE_CURRENT_BINARY_DIR}/vtkConfigure.h
${CMAKE_CURRENT_BINARY_DIR}/vtkMathConfigure.h
${CMAKE_CURRENT_BINARY_DIR}/vtkVersionMacros.h
vtkTypedArray.h
vtkTypeTemplate.h
)
......@@ -226,6 +227,14 @@ vtk_prepare_cmakedefine(NOT VTK_COMPILER_HAS_FULL_SPECIALIZATION
VTK_NO_FULL_TEMPLATE_SPECIALIZATION)
vtk_prepare_cmakedefine("" OPENGL_LIBRARY VTK_USE_OPENGL_LIBRARY)
# Provide version macros through vtkConfigure.h for compatibility.
if(VTK_LEGACY_REMOVE)
set(VTK_CONFIG_LEGACY_VERSION "")
else()
set(VTK_CONFIG_LEGACY_VERSION "#include \"vtkVersionMacros.h\" // removed by VTK_LEGACY_REMOVE")
endif()
configure_file(vtkVersionMacros.h.in vtkVersionMacros.h @ONLY)
configure_file(vtkConfigure.h.in vtkConfigure.h @ONLY)
configure_file(vtkToolkits.h.in vtkToolkits.h @ONLY)
......@@ -347,6 +356,7 @@ set_source_files_properties(
vtkType.h
${CMAKE_CURRENT_BINARY_DIR}/vtkMathConfigure.h
${CMAKE_CURRENT_BINARY_DIR}/vtkConfigure.h
${CMAKE_CURRENT_BINARY_DIR}/vtkVersionMacros.h
PROPERTIES WRAP_HEADER 1
)
......@@ -394,6 +404,7 @@ set_source_files_properties(
vtkSystemIncludes
vtkMathConfigure
vtkType
vtkVersionMacros
vtkConfigure
ABSTRACT
)
......
......@@ -139,14 +139,7 @@
# define MAC_OSX_TK
#endif
/*--------------------------------------------------------------------------*/
/* VTK Versioning */
/* Version number. */
#define VTK_MAJOR_VERSION @VTK_MAJOR_VERSION@
#define VTK_MINOR_VERSION @VTK_MINOR_VERSION@
#define VTK_BUILD_VERSION @VTK_BUILD_VERSION@
#define VTK_VERSION "@VTK_VERSION@"
@VTK_CONFIG_LEGACY_VERSION@
/* C++ compiler used. */
#define VTK_CXX_COMPILER "@CMAKE_CXX_COMPILER@"
......
......@@ -28,14 +28,9 @@
#include "vtkCommonCoreModule.h" // For export macro
#include "vtkObject.h"
#include "vtkVersionMacros.h" // For version macros
#if VTK_MINOR_VERSION & 1
# include <vtksys/DateStamp.h> // For date stamp
# define VTK_SOURCE_VERSION "vtk version " VTK_VERSION ", Date: " vtksys_DATE_STAMP_STRING
#else
# define VTK_SOURCE_VERSION "vtk version " VTK_VERSION
#endif
#define VTK_SOURCE_VERSION "vtk version " VTK_VERSION
class VTKCOMMONCORE_EXPORT vtkVersion : public vtkObject
{
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkVersionMacros.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm 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.
=========================================================================*/
#ifndef __vtkVersionMacros_h
#define __vtkVersionMacros_h
/* In development versions the minor component is odd and the build
component encodes a date in CCYYMMDD format. In release versions
(or preparation of one) the minor component is even and the build
component is a small integer patch level. */
#define VTK_MAJOR_VERSION @VTK_MAJOR_VERSION@
#define VTK_MINOR_VERSION @VTK_MINOR_VERSION@
#define VTK_BUILD_VERSION @VTK_BUILD_VERSION@
#define VTK_VERSION "@VTK_VERSION@"
#endif
......@@ -314,8 +314,7 @@ execute_process(COMMAND ${PERL}
step(4 "extract VTK version")
execute_process(COMMAND ${PERL}
"${PATH_TO_VTK_DOX_SCRIPTS}/doc_version.pl"
--version_file "${SOURCE_DIR}/${REL_PATH_TO_TOP}/CMakeLists.txt"
--revision_file "@VTK_BINARY_DIR@/Utilities/vtksys/DateStamp.h"
--version_file "${SOURCE_DIR}/${REL_PATH_TO_TOP}/CMake/vtkVersion.cmake"
--logo "${PATH_TO_VTK_DOX_SCRIPTS}/vtk-logo.gif"
--store "doc_${PROJECT_NAME}_version.dox"
--to "${INTERMEDIATE_DOX_DIR}"
......
......@@ -272,8 +272,7 @@ fi
if test "x$PERL_PROG" != "xNOTFOUND" ; then
"$PERL_PROG" "$PATH_TO_VTK_DOX_SCRIPTS/doc_version.pl" \
--version_file "$SOURCE_DIR/$REL_PATH_TO_TOP/CMakeLists.txt" \
--revision_file "@VTK_BINARY_DIR@/Utilities/vtksys/DateStamp.h" \
--version_file "$SOURCE_DIR/$REL_PATH_TO_TOP/CMake/vtkVersion.cmake" \
--logo "$PATH_TO_VTK_DOX_SCRIPTS/vtk-logo.gif" \
--store "doc_""$PROJECT_NAME""_version.dox" \
--to "$INTERMEDIATE_DOX_DIR"
......
......@@ -69,8 +69,7 @@ print "$PROGNAME $VERSION, by $AUTHOR\n";
my %default =
(
version_file => "../../CMakeLists.txt",
revison_file => "../../Common/vtkVersion.h",
version_file => "../../CMake/vtkVersion.cmake",
store => "doc_VTK_version.dox",
to => "../../../VTK-doxygen"
);
......@@ -80,14 +79,13 @@ my %default =
my %args;
Getopt::Long::Configure("bundling");
GetOptions (\%args, "help", "revision_file=s", "version_file=s", "logo=s", "store=s", "to=s");
GetOptions (\%args, "help", "version_file=s", "logo=s", "store=s", "to=s");
if (exists $args{"help"}) {
print <<"EOT";
by $AUTHOR
Usage : $PROGNAME [--help] [--revision_file file] [--store file] [--to path]
Usage : $PROGNAME [--help] [--version_file file] [--store file] [--to path]
--help : this message
--revision_file file : use 'file' to find revision (default: $default{revision_file})
--version_file file : use 'file' to find version info (default: $default{version_file})
--logo file : use 'file' as logo (default: $default{logo})
--store file : use 'file' to store version (default: $default{store})
......@@ -99,7 +97,6 @@ EOT
exit;
}
$args{"revision_file"} = $default{"revision_file"} if ! exists $args{"revision_file"};
$args{"version_file"} = $default{"version_file"} if ! exists $args{"version_file"};
$args{"logo"} = $default{"logo"} if ! exists $args{"logo"};
$args{"store"} = $default{"store"} if ! exists $args{"store"};
......@@ -111,9 +108,9 @@ my $open_file_as_text = $os_is_win ? O_TEXT : 0;
my $start_time = time();
# -------------------------------------------------------------------------
# Try to get VTK version and revision
# Try to get VTK version
my ($major_version, $minor_version, $build_version, $date) = (undef, undef, undef, undef);
my ($major_version, $minor_version, $build_version) = (undef, undef, undef);
sysopen(FILE, $args{"version_file"}, O_RDONLY|$open_file_as_text)
or croak "$PROGNAME: unable to open $args{version_file}\n";
......@@ -136,22 +133,6 @@ close(FILE);
croak "$PROGNAME: unable to find version in " . $args{"version_file"} . "\n"
if (!defined $major_version || !defined $minor_version || !defined $build_version);
sysopen(FILE, $args{"revision_file"}, O_RDONLY|$open_file_as_text)
or croak "$PROGNAME: unable to open $args{revision_file}\n";
while (<FILE>) {
if ($_ =~ /define\s+vtksys_DATE_STAMP_STRING\s+\"([^\"]+)\"/) {
$date = $1;
print " date => $date\n";
last;
}
}
close(FILE);
carp "$PROGNAME: unable to find revision/date in " . $args{"revision_file"} . "\n"
if (!defined $date);
# -------------------------------------------------------------------------
# Build documentation
......@@ -170,10 +151,6 @@ print DEST_FILE
" \@image html " . basename($args{"logo"}) . "\n"
if exists $args{"logo"} && -f $args{"logo"};
if (defined $date) {
print DEST_FILE " \@date $date\n";
}
print DEST_FILE
" \@par Useful links:\n",
" \@li VTK Home: http://www.vtk.org\n",
......
......@@ -14,7 +14,6 @@ SET(KWSYS_USE_SystemInformation 1)
SET(KWSYS_USE_FundamentalType 1)
SET(KWSYS_USE_MD5 1)
SET(KWSYS_USE_Glob 1)
SET(KWSYS_USE_DateStamp 1)
set(KWSYS_HEADER_ROOT ${CMAKE_CURRENT_BINARY_DIR})
SET(KWSYS_PROPERTIES_CXX ${VTK_LIBRARY_PROPERTIES})
SET(KWSYS_INSTALL_EXPORT_NAME ${VTK_INSTALL_EXPORT_NAME})
......
......@@ -18,6 +18,9 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/vtkPythonConfigure.h.in
get_property(_python_modules GLOBAL PROPERTY VTK_PYTHON_WRAPPED)
get_property(_java_modules GLOBAL PROPERTY VTK_JAVA_WRAPPED)
set_property(SOURCE vtkParseMain.c PROPERTY COMPILE_DEFINITIONS
VTK_PARSE_VERSION="${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}")
if(NOT CMAKE_CROSSCOMPILING)
if(VTK_WRAP_TCL OR VTK_WRAP_PYTHON OR VTK_WRAP_JAVA)
add_executable(vtkWrapHierarchy vtkParse.tab.c vtkParsePreprocess.c
......
......@@ -24,7 +24,6 @@ the code that parses the header file.
#include "vtkParse.h"
#include "vtkParseMain.h"
#include "vtkParseInternal.h"
#include "vtkConfigure.h" // VTK_VERSION
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -184,7 +183,7 @@ int main(int argc, char *argv[])
if (vtk_parse_version)
{
const char *ver = VTK_VERSION;
const char *ver = VTK_PARSE_VERSION;
const char *exename = argv[0];
/* remove directory part of exe name */
for (exename += strlen(exename); exename > argv[0]; --exename)
......
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