Skip to content

Commit 90122ef

Browse files
committed
ENH: Replace __ELASTIX_VERSION by ELASTIX_VERSION_STRING
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`.
1 parent 55b6f3f commit 90122ef

8 files changed

Lines changed: 60 additions & 47 deletions

File tree

CMake/elastixVersion.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Elastix version number components.
2+
set(ELASTIX_VERSION_MAJOR "5")
3+
set(ELASTIX_VERSION_MINOR "0")
4+
set(ELASTIX_VERSION_PATCH "1")

CMakeLists.txt

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@ endif()
1313
cmake_policy( SET CMP0012 NEW )
1414
cmake_policy( SET CMP0042 NEW )
1515

16-
#---------------------------------------------------------------------
17-
# Get version information.
18-
19-
# Get the version number of elastix
20-
file( STRINGS ${elastix_SOURCE_DIR}/Core/Install/elxBaseComponent.h
21-
ELASTIX_VERSION REGEX "\(#define\ __ELASTIX_VERSION\)" )
22-
string( SUBSTRING ${ELASTIX_VERSION} 26 3 ELASTIX_VERSION )
23-
24-
# Split version in major minor. Assuming no patch number, just x.y
25-
string( REGEX MATCH "[0-9]+" ELASTIX_VERSION_MAJOR "${ELASTIX_VERSION}" )
26-
string( REGEX REPLACE "([0-9]+)\\." "" ELASTIX_VERSION_MINOR "${ELASTIX_VERSION}" )
27-
2816
#---------------------------------------------------------------------
2917
include( CTest )
3018

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

34+
#---------------------------------------------------------------------
35+
# Get version information.
36+
include( elastixVersion )
37+
4638
# Function for exporting targets
4739
include(elastixExportTarget)
4840

@@ -427,10 +419,9 @@ if( ELASTIX_ENABLE_PACKAGER )
427419
# Version information
428420
# If the next line is uncommented the package name will be like
429421
# elastix-4.3-win64 instead of elastix-4.3.0-win64
430-
#set( CPACK_PACKAGE_VERSION ${ELASTIX_VERSION} )
431422
set( CPACK_PACKAGE_VERSION_MAJOR ${ELASTIX_VERSION_MAJOR} )
432423
set( CPACK_PACKAGE_VERSION_MINOR ${ELASTIX_VERSION_MINOR} )
433-
set( CPACK_PACKAGE_VERSION_PATCH "0" )
424+
set( CPACK_PACKAGE_VERSION_PATCH ${ELASTIX_VERSION_PATCH} )
434425

435426
# Also install the copyright file, since when the user enables packaging
436427
# we assume that the package is meant to distribute.

Core/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ source_group( "Configuration" FILES ${ConfigurationFiles} )
8686
source_group( "ComponentBaseClasses" FILES ${ComponentBaseClassFiles} )
8787
source_group( "ProgressCommand" FILES ${ProgressCommandFiles} )
8888

89+
#---------------------------------------------------------------------
90+
91+
configure_file(
92+
elxVersionMacros.h.in
93+
elxVersionMacros.h)
94+
8995
#---------------------------------------------------------------------
9096
# Create the elxCore library.
9197

Core/Install/elxBaseComponent.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@
4040

4141
#include <string>
4242

43-
/** The current elastix version. */
44-
#define __ELASTIX_VERSION 5.000
45-
4643
/** All elastix components should be in namespace elastix. */
4744
namespace elastix
4845
{

Core/Kernel/elxElastixBase.cxx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*
1717
*=========================================================================*/
1818
#include "elxElastixBase.h"
19+
#include <Core/elxVersionMacros.h>
1920
#include <sstream>
2021
#include "itkMersenneTwisterRandomVariateGenerator.h"
2122

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

112113
/** Print to log file. */
113-
elxout << std::fixed;
114-
elxout << std::showpoint;
115-
elxout << std::setprecision( 3 );
116-
elxout << "ELASTIX version: " << __ELASTIX_VERSION << std::endl;
117-
elxout << std::setprecision( this->GetDefaultOutputPrecision() );
114+
elxout << "ELASTIX version: " ELASTIX_VERSION_STRING "\n";
118115

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

264261
/** Print to log file. */
265-
elxout << std::fixed;
266-
elxout << std::showpoint;
267-
elxout << std::setprecision( 3 );
268-
elxout << "ELASTIX version: " << __ELASTIX_VERSION << std::endl;
262+
elxout << "ELASTIX version: " ELASTIX_VERSION_STRING "\n";
269263
elxout << std::setprecision( this->GetDefaultOutputPrecision() );
270264

271265
/** Check Command line options and print them to the logfile. */

Core/Main/elastix.cxx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// Elastix header files:
2020
#include "elastix.h"
2121
#include "elxElastixMain.h"
22+
#include <Core/elxVersionMacros.h>
2223
#include "itkUseMevisDicomTiff.h"
2324

2425
// ITK header files:
@@ -57,20 +58,13 @@ main( int argc, char ** argv )
5758
}
5859
else if( argument == "--version" )
5960
{
60-
std::cout << std::fixed;
61-
std::cout << std::showpoint;
62-
std::cout << std::setprecision( 3 );
63-
std::cout << "elastix version: " << __ELASTIX_VERSION << std::endl;
61+
std::cout << "elastix version: " ELASTIX_VERSION_STRING << std::endl;
6462
return 0;
6563
}
6664
else if (argument == "--extended-version")
6765
{
6866
std::cout
69-
<< std::fixed
70-
<< std::showpoint
71-
<< std::setprecision(3)
72-
<< "elastix version: "
73-
<< __ELASTIX_VERSION
67+
<< "elastix version: " ELASTIX_VERSION_STRING
7468
<< "\nITK version: "
7569
<< ITK_VERSION_MAJOR << '.'
7670
<< ITK_VERSION_MINOR << '.'
@@ -372,10 +366,7 @@ void
372366
PrintHelp( void )
373367
{
374368
/** Print the version. */
375-
std::cout << std::fixed;
376-
std::cout << std::showpoint;
377-
std::cout << std::setprecision( 3 );
378-
std::cout << "elastix version: " << __ELASTIX_VERSION << "\n" << std::endl;
369+
std::cout << "elastix version: " << ELASTIX_VERSION_STRING "\n\n";
379370

380371
/** What is elastix? */
381372
std::cout << "elastix registers a moving image to a fixed image.\n";

Core/Main/transformix.cxx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// Elastix header files:
2020
#include "elastix.h"
2121
#include "elxTransformixMain.h"
22+
#include <Core/elxVersionMacros.h>
2223
#include "itkUseMevisDicomTiff.h"
2324

2425
// ITK header files:
@@ -50,10 +51,7 @@ main( int argc, char ** argv )
5051
}
5152
else if( argument == "--version" )
5253
{
53-
std::cout << std::fixed;
54-
std::cout << std::showpoint;
55-
std::cout << std::setprecision( 3 );
56-
std::cout << "transformix version: " << __ELASTIX_VERSION << std::endl;
54+
std::cout << "transformix version: " ELASTIX_VERSION_STRING << std::endl;
5755
return 0;
5856
}
5957
else
@@ -250,10 +248,7 @@ void
250248
PrintHelp( void )
251249
{
252250
/** Print the version. */
253-
std::cout << std::fixed;
254-
std::cout << std::showpoint;
255-
std::cout << std::setprecision( 3 );
256-
std::cout << "transformix version: " << __ELASTIX_VERSION << "\n" << std::endl;
251+
std::cout << "transformix version: " ELASTIX_VERSION_STRING "\n\n";
257252

258253
/** What is transformix? */
259254
std::cout << "transformix applies a transform on an input image and/or "

Core/elxVersionMacros.h.in

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*=========================================================================
2+
*
3+
* Copyright UMC Utrecht and contributors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0.txt
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*=========================================================================*/
18+
#ifndef elxVersionMacros_h
19+
#define elxVersionMacros_h
20+
21+
// Note: This header file is generated automatically, by CMake configure_file.
22+
23+
/** Major component of elastix version. */
24+
#define ELASTIX_VERSION_MAJOR @ELASTIX_VERSION_MAJOR@
25+
26+
/** Minor component of elastix version. */
27+
#define ELASTIX_VERSION_MINOR @ELASTIX_VERSION_MINOR@
28+
29+
/** Patch component of elastix version. */
30+
#define ELASTIX_VERSION_PATCH @ELASTIX_VERSION_PATCH@
31+
32+
/** String representation of elastix version. */
33+
#define ELASTIX_VERSION_STRING "@ELASTIX_VERSION_MAJOR@.@ELASTIX_VERSION_MINOR@.@ELASTIX_VERSION_PATCH@"
34+
35+
#endif

0 commit comments

Comments
 (0)