Skip to content

Commit

Permalink
ENH: Replace __ELASTIX_VERSION by ELASTIX_VERSION_STRING
Browse files Browse the repository at this point in the history
Elastix version number (currently "5.0.1") is now specified at elastix-source-dir/CMake/elastixVersion.cmake

CMake generated header, defining version macro's (including `ELASTIX_VERSION_STRING`): elastix-binary-dir/Core/elxVersionMacros.h

Removed `__ELASTIX_VERSION`.
  • Loading branch information
N-Dekker committed Sep 27, 2020
1 parent 55b6f3f commit 90122ef
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 47 deletions.
4 changes: 4 additions & 0 deletions CMake/elastixVersion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Elastix version number components.
set(ELASTIX_VERSION_MAJOR "5")
set(ELASTIX_VERSION_MINOR "0")
set(ELASTIX_VERSION_PATCH "1")
19 changes: 5 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@ endif()
cmake_policy( SET CMP0012 NEW )
cmake_policy( SET CMP0042 NEW )

#---------------------------------------------------------------------
# Get version information.

# Get the version number of elastix
file( STRINGS ${elastix_SOURCE_DIR}/Core/Install/elxBaseComponent.h
ELASTIX_VERSION REGEX "\(#define\ __ELASTIX_VERSION\)" )
string( SUBSTRING ${ELASTIX_VERSION} 26 3 ELASTIX_VERSION )

# Split version in major minor. Assuming no patch number, just x.y
string( REGEX MATCH "[0-9]+" ELASTIX_VERSION_MAJOR "${ELASTIX_VERSION}" )
string( REGEX REPLACE "([0-9]+)\\." "" ELASTIX_VERSION_MINOR "${ELASTIX_VERSION}" )

#---------------------------------------------------------------------
include( CTest )

Expand All @@ -43,6 +31,10 @@ include( ${ITK_USE_FILE} )
# so that CMake is able to find the FindPackage modules.
list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake )

#---------------------------------------------------------------------
# Get version information.
include( elastixVersion )

# Function for exporting targets
include(elastixExportTarget)

Expand Down Expand Up @@ -427,10 +419,9 @@ if( ELASTIX_ENABLE_PACKAGER )
# Version information
# If the next line is uncommented the package name will be like
# elastix-4.3-win64 instead of elastix-4.3.0-win64
#set( CPACK_PACKAGE_VERSION ${ELASTIX_VERSION} )
set( CPACK_PACKAGE_VERSION_MAJOR ${ELASTIX_VERSION_MAJOR} )
set( CPACK_PACKAGE_VERSION_MINOR ${ELASTIX_VERSION_MINOR} )
set( CPACK_PACKAGE_VERSION_PATCH "0" )
set( CPACK_PACKAGE_VERSION_PATCH ${ELASTIX_VERSION_PATCH} )

# Also install the copyright file, since when the user enables packaging
# we assume that the package is meant to distribute.
Expand Down
6 changes: 6 additions & 0 deletions Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ source_group( "Configuration" FILES ${ConfigurationFiles} )
source_group( "ComponentBaseClasses" FILES ${ComponentBaseClassFiles} )
source_group( "ProgressCommand" FILES ${ProgressCommandFiles} )

#---------------------------------------------------------------------

configure_file(
elxVersionMacros.h.in
elxVersionMacros.h)

#---------------------------------------------------------------------
# Create the elxCore library.

Expand Down
3 changes: 0 additions & 3 deletions Core/Install/elxBaseComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@

#include <string>

/** The current elastix version. */
#define __ELASTIX_VERSION 5.000

/** All elastix components should be in namespace elastix. */
namespace elastix
{
Expand Down
12 changes: 3 additions & 9 deletions Core/Kernel/elxElastixBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
*=========================================================================*/
#include "elxElastixBase.h"
#include <Core/elxVersionMacros.h>
#include <sstream>
#include "itkMersenneTwisterRandomVariateGenerator.h"

Expand Down Expand Up @@ -110,11 +111,7 @@ ElastixBase::BeforeAllBase( void )
elxout << std::setprecision( this->m_DefaultOutputPrecision );

/** Print to log file. */
elxout << std::fixed;
elxout << std::showpoint;
elxout << std::setprecision( 3 );
elxout << "ELASTIX version: " << __ELASTIX_VERSION << std::endl;
elxout << std::setprecision( this->GetDefaultOutputPrecision() );
elxout << "ELASTIX version: " ELASTIX_VERSION_STRING "\n";

/** Check Command line options and print them to the logfile. */
elxout << "Command line options from ElastixBase:" << std::endl;
Expand Down Expand Up @@ -262,10 +259,7 @@ ElastixBase::BeforeAllTransformixBase( void )
int returndummy = 0;

/** Print to log file. */
elxout << std::fixed;
elxout << std::showpoint;
elxout << std::setprecision( 3 );
elxout << "ELASTIX version: " << __ELASTIX_VERSION << std::endl;
elxout << "ELASTIX version: " ELASTIX_VERSION_STRING "\n";
elxout << std::setprecision( this->GetDefaultOutputPrecision() );

/** Check Command line options and print them to the logfile. */
Expand Down
17 changes: 4 additions & 13 deletions Core/Main/elastix.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// Elastix header files:
#include "elastix.h"
#include "elxElastixMain.h"
#include <Core/elxVersionMacros.h>
#include "itkUseMevisDicomTiff.h"

// ITK header files:
Expand Down Expand Up @@ -57,20 +58,13 @@ main( int argc, char ** argv )
}
else if( argument == "--version" )
{
std::cout << std::fixed;
std::cout << std::showpoint;
std::cout << std::setprecision( 3 );
std::cout << "elastix version: " << __ELASTIX_VERSION << std::endl;
std::cout << "elastix version: " ELASTIX_VERSION_STRING << std::endl;
return 0;
}
else if (argument == "--extended-version")
{
std::cout
<< std::fixed
<< std::showpoint
<< std::setprecision(3)
<< "elastix version: "
<< __ELASTIX_VERSION
<< "elastix version: " ELASTIX_VERSION_STRING
<< "\nITK version: "
<< ITK_VERSION_MAJOR << '.'
<< ITK_VERSION_MINOR << '.'
Expand Down Expand Up @@ -372,10 +366,7 @@ void
PrintHelp( void )
{
/** Print the version. */
std::cout << std::fixed;
std::cout << std::showpoint;
std::cout << std::setprecision( 3 );
std::cout << "elastix version: " << __ELASTIX_VERSION << "\n" << std::endl;
std::cout << "elastix version: " << ELASTIX_VERSION_STRING "\n\n";

/** What is elastix? */
std::cout << "elastix registers a moving image to a fixed image.\n";
Expand Down
11 changes: 3 additions & 8 deletions Core/Main/transformix.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// Elastix header files:
#include "elastix.h"
#include "elxTransformixMain.h"
#include <Core/elxVersionMacros.h>
#include "itkUseMevisDicomTiff.h"

// ITK header files:
Expand Down Expand Up @@ -50,10 +51,7 @@ main( int argc, char ** argv )
}
else if( argument == "--version" )
{
std::cout << std::fixed;
std::cout << std::showpoint;
std::cout << std::setprecision( 3 );
std::cout << "transformix version: " << __ELASTIX_VERSION << std::endl;
std::cout << "transformix version: " ELASTIX_VERSION_STRING << std::endl;
return 0;
}
else
Expand Down Expand Up @@ -250,10 +248,7 @@ void
PrintHelp( void )
{
/** Print the version. */
std::cout << std::fixed;
std::cout << std::showpoint;
std::cout << std::setprecision( 3 );
std::cout << "transformix version: " << __ELASTIX_VERSION << "\n" << std::endl;
std::cout << "transformix version: " ELASTIX_VERSION_STRING "\n\n";

/** What is transformix? */
std::cout << "transformix applies a transform on an input image and/or "
Expand Down
35 changes: 35 additions & 0 deletions Core/elxVersionMacros.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*=========================================================================
*
* Copyright UMC Utrecht and contributors
*
* 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.txt
*
* 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.
*
*=========================================================================*/
#ifndef elxVersionMacros_h
#define elxVersionMacros_h

// Note: This header file is generated automatically, by CMake configure_file.

/** Major component of elastix version. */
#define ELASTIX_VERSION_MAJOR @ELASTIX_VERSION_MAJOR@

/** Minor component of elastix version. */
#define ELASTIX_VERSION_MINOR @ELASTIX_VERSION_MINOR@

/** Patch component of elastix version. */
#define ELASTIX_VERSION_PATCH @ELASTIX_VERSION_PATCH@

/** String representation of elastix version. */
#define ELASTIX_VERSION_STRING "@ELASTIX_VERSION_MAJOR@.@ELASTIX_VERSION_MINOR@.@ELASTIX_VERSION_PATCH@"

#endif

0 comments on commit 90122ef

Please sign in to comment.