Skip to content
Snippets Groups Projects
Commit cd260ce2 authored by Floris Berendsen's avatar Floris Berendsen
Browse files

Merge branch 'develop' into ELASTIX-24-Component-Interface-Handshake

parents d845a26d 27392ab4
No related branches found
No related tags found
No related merge requests found
Showing
with 482 additions and 283 deletions
[submodule "Testing/GoogleTest"]
path = Testing/GoogleTest
url = https://github.com/kaspermarstal/GoogleTest
tag = release-1.7.0
sudo: false
sudo: required
dist: trusty
language: cpp
......@@ -26,8 +27,8 @@ before_script:
script:
- cmake ../SuperElastix/SuperBuild
- make --jobs=2 | grep -v '^--' | grep -v '^Installing'
- make --jobs=2 | grep -v '^--' | grep -v '^Installing' | grep -v '^common'
after_sucess:
after_success:
- cd Elastix-build
- ctest
macro( ElastixComponent COMPONENT )
ElastixModuleCheckName( ${COMPONENT} )
set( ELASTIX_COMPONENT_{$COMPONENT}_DEFINED TRUE )
endmacro()
macro( ElastixComponentCheckName COMPONENT )
if( NOT "${_name}" MATCHES "^[a-zA-Z][a-zA-Z0-9]*$" )
message( FATAL_ERROR "Invalid component name: ${COMPONENT}" )
endif()
endmacro()
\ No newline at end of file
......@@ -6,7 +6,7 @@ macro( _elxmodule_check_name MODULE )
message( FATAL_ERROR "Invalid module name: ${MODULE}" )
endif()
list( FIND ELXMODULE_ALL "${MODULE}" MODULE_FOUND )
list( FIND ELASTIX_MODULES "${MODULE}" MODULE_FOUND )
if( ${MODULE_FOUND} EQUAL -1 )
message( FATAL_ERROR "Module not found: ${MODULE}")
endif()
......@@ -16,7 +16,7 @@ macro( _elxmodule_enable MODULE )
_elxmodule_check_name( ${MODULE} )
if( NOT ${MODULE}_ENABLED )
set( USE_${MODULE} ON )
set( ELASTIX_USE_${MODULE} ON )
include( ${${MODULE}_FILE} )
......@@ -24,14 +24,9 @@ macro( _elxmodule_enable MODULE )
include_directories( ${${MODULE}_INCLUDE_DIRS} )
endif()
add_subdirectory( ${${MODULE}_SOURCE_DIR} )
if( ${MODULE}_LIBRARIES )
link_directories( ${${MODULE}_LIBRARY_DIRS} )
list( APPEND ELASTIX_LIBRARIES
${${MODULE}_LIBRARIES}
)
list( APPEND ELASTIX_LIBRARIES ${${MODULE}_LIBRARIES} )
endif()
# TODO: Add recursive dependency walk
......@@ -43,30 +38,32 @@ macro( _elxmodule_disable MODULE )
endmacro()
macro( _elxmodules_initialize )
set( ELXMODULE_ALL )
set( ELASTIX_LIBRARIES )
set( ELASTIX_MODULES )
file( GLOB MODULE_FILES RELATIVE "${CMAKE_SOURCE_DIR}"
file( GLOB_RECURSE MODULE_FILES RELATIVE "${CMAKE_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}/Modules/*/elxModule*.cmake"
)
message( STATUS "Found the following elastix modules:")
foreach( MODULE_FILE ${MODULE_FILES})
get_filename_component( MODULE_PATH ${MODULE_FILE} PATH )
get_filename_component( MODULE ${MODULE_FILE} NAME_WE )
message( STATUS " ${MODULE}" )
get_filename_component( MODULE_NAME ${MODULE_FILE} NAME_WE )
get_filename_component( ${MODULE_NAME}_PATH ${MODULE_FILE} PATH )
message( STATUS " ${MODULE_NAME}" )
option( "USE_${MODULE}" OFF )
set( "${MODULE}_FILE" ${CMAKE_SOURCE_DIR}/${MODULE_FILE} )
set( "${MODULE}_ENABLED" OFF )
option( "ELASTIX_USE_${MODULE_NAME}" OFF )
set( "${MODULE_NAME}_FILE" ${CMAKE_SOURCE_DIR}/${MODULE_FILE} )
set( "${MODULE_NAME}_ENABLED" OFF )
set( ${MODULE}_SOURCE_DIR ${CMAKE_SOURCE_DIR}/${MODULE_PATH} )
set( ${MODULE}_BINARY_DIR ${CMAKE_BINARY_DIR}/${MODULE_PATH} )
set( ${MODULE_NAME}_SOURCE_DIR ${CMAKE_SOURCE_DIR}/${${MODULE_NAME}_PATH} )
set( ${MODULE_NAME}_BINARY_DIR ${CMAKE_BINARY_DIR}/${${MODULE_NAME}_PATH} )
set( ${MODULE}_INCLUDE_DIRS )
set( ${MODULE}_LIBRARY_DIRS )
set( ${MODULE}_LIBRARIES )
set( ${MODULE_NAME}_INCLUDE_DIRS )
set( ${MODULE_NAME}_LIBRARY_DIRS )
set( ${MODULE_NAME}_LIBRARIES )
list(APPEND ELXMODULE_ALL ${MODULE} )
list(APPEND ELASTIX_MODULES ${MODULE_NAME} )
endforeach()
endmacro()
......@@ -79,9 +76,3 @@ macro( elxmodule_enable MODULE )
_elxmodule_enable( ${MODULE} )
endmacro()
macro( elxmodule_compile MODULE )
project( "${MODULE}" )
add_library( ${MODULE} STATIC "${${MODULE}_SOURCE_FILES}" )
target_link_libraries( ${MODULE} ${ELASTIX_LIBRARIES} )
list( APPEND ${MODULE}_LIBRARIES ${MODULE} )
endmacro()
# Visual Studio complains if paths are too long
string( LENGTH "${CMAKE_CURRENT_SOURCE_DIR}" n )
if( n GREATER 50 )
message(
FATAL_ERROR
"Source code directory path length is too long for MSVC (${n} > 50)."
"Please move the source code directory to a directory with a shorter path."
)
endif()
if( MSVC )
string( LENGTH "${CMAKE_CURRENT_SOURCE_DIR}" n )
if( n GREATER 50 )
message(
FATAL_ERROR
"Source code directory path length is too long for MSVC (${n} > 50)."
"Please move the source code directory to a directory with a shorter path."
)
endif()
string( LENGTH "${CMAKE_CURRENT_BINARY_DIR}" n )
if( n GREATER 50 )
message(
FATAL_ERROR
"Build directory path length is too long for MSVC (${n} > 50)."
"Please move the build directory to a directory with a shorter path."
)
endif()
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /bigobj" )
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /bigobj" )
string( LENGTH "${CMAKE_CURRENT_BINARY_DIR}" n )
if( n GREATER 50 )
message(
FATAL_ERROR
"Build directory path length is too long for MSVC (${n} > 50)."
"Please move the build directory to a directory with a shorter path."
)
endif()
\ No newline at end of file
# GoogleTest needs static linking
include( elxCompilerFlags.cmake )
foreach( CompilerFlag ${CompilerFlags} )
string( REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}" )
endforeach()
......@@ -2,7 +2,7 @@ cmake_minimum_required( VERSION 2.8 )
# Explicitly add INCREMENTAL linking option to command lines.
# http://www.cmake.org/pipermail/cmake/2010-February/035174.html
set( MSVC_INCREMENTAL_DEFAULT ON )
#set( MSVC_INCREMENTAL_DEFAULT ON )
# ---------------------------------------------------------------------
project( Elastix )
......@@ -13,13 +13,10 @@ set( CMAKE_RUNTIME_OUTPUT_DIRECTORY
)
# Include SuperElastix CMake scripts
set( CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/CMake"
${CMAKE_MODULE_PATH}
)
list( APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake" )
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC" )
include( elxWinConfig.cmake )
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC )
include( elxWinConfig )
endif()
# ---------------------------------------------------------------------
......@@ -31,14 +28,13 @@ include( "${CMAKE_CURRENT_SOURCE_DIR}/CMake/elxITKRequiredModules.cmake" )
# ---------------------------------------------------------------------
# Boost Graph Library
find_package( Boost REQUIRED graph )
find_package( Boost )
include_directories( ${Boost_INCLUDE_DIRS} )
# ---------------------------------------------------------------------
# Build Elastix
# Build SuperElastix
# For now we just enable all modules
include( "${CMAKE_CURRENT_SOURCE_DIR}/CMake/elxModules.cmake" )
include( elxModules )
elxmodule_enable( elxModuleCore )
# ---------------------------------------------------------------------
......@@ -46,14 +42,14 @@ elxmodule_enable( elxModuleCore )
# Testing requires CMake version 2.8.11 to download test data
if( CMAKE_VERSION VERSION_LESS 2.8.11 )
set( ELASTIX_BUILD_TESTING_DEFAULT OFF )
set( SUPERELASTIX_BUILD_TESTING_DEFAULT OFF )
message( STATUS "ELASTIX_BUILD_TESTING is set to OFF because CMake version is less than 2.8.11" )
else()
set( ELASTIX BUILD_TESTING_DEFAULT ON )
set( SUPERELASTIX_BUILD_TESTING_DEFAULT ON )
endif()
option( ELASTIX_BUILD_TESTING "Enable building tests." ${ELASTIX_BUILD_TESTING_DEFAULT} )
if( ${ELASTIX_BUILD_TESTING} )
option( SUPERELASTIX_BUILD_TESTING "Enable building tests." ${SUPERELASTIX_BUILD_TESTING_DEFAULT} )
if( ${SUPERELASTIX_BUILD_TESTING} )
enable_testing()
add_subdirectory( Testing )
endif()
......@@ -61,9 +57,9 @@ endif()
# ---------------------------------------------------------------------
# Build Documentation
mark_as_advanced( ELASTIX_BUILD_DOXYGEN )
option( ELASTIX_BUILD_DOXYGEN "Enable building Doxygen documentation." OFF )
mark_as_advanced( SUPERELASTIX_BUILD_DOXYGEN )
option( SUPERELASTIX_BUILD_DOXYGEN "Enable building Doxygen documentation." OFF )
mark_as_advanced( ELASTIX_BUILD_READTHEDOCS )
option( ELASTIX_BUILD_READTHEDOCS "Enable building readthedocs.org documentation." OFF )
mark_as_advanced( SUPERELASTIX_BUILD_READTHEDOCS )
option( SUPERELASTIX_BUILD_READTHEDOCS "Enable building readthedocs.org documentation." OFF )
#ifndef __Blueprint_h
#define __Blueprint_h
#include "boost/graph/graph_traits.hpp"
#include "boost/graph/directed_graph.hpp"
#include "itkObjectFactory.h"
#include "itkDataObject.h"
#include "elxMacro.h"
#include "elxComponentDescriptor.h"
#include "boost/graph/graph_traits.hpp"
#include "boost/graph/directed_graph.hpp"
namespace elx {
template< class TComponentDescriptor >
class Blueprint : public itk::DataObject
{
public:
elxNewMacro( Blueprint, itk::DataObject );
typedef TComponentDescriptor ComponentDescriptorType;
typedef typename TComponentDescriptor::ComponentNameType ComponentNameType;
typedef std::string ParameterKeyType;
typedef std::vector< std::string > ParameterValueType;
typedef std::map< ParameterKeyType, ParameterValueType > ParameterMapType;
// Component parameter map that sits on a node in the graph
// and holds component configuration settings
struct ComponentPropertyType {
ParameterMapType parameterMap;
};
// Component parameter map that sits on an edge in the graph
// and holds component configuration settings
struct ConnectionPropertyType {
ParameterMapType parameterMap;
};
typedef boost::adjacency_list< boost::vecS,
boost::vecS,
boost::directedS,
ComponentDescriptorType > GraphType;
typedef typename boost::graph_traits< GraphType >::vertex_descriptor ComponentType;
typedef typename boost::graph_traits< GraphType >::vertex_iterator ComponentIterator, ComponentIteratorEnd;
typedef boost::vertex_index_t ComponentIndexType;
typedef typename boost::property_map< GraphType, ComponentIndexType >::type ComponentIndexMapType;
typedef typename boost::graph_traits< GraphType >::edge_descriptor ConnectionDescriptorType;
typedef typename boost::graph_traits< GraphType >::edge_iterator ConnectionIterator, ConnectionIteratorEnd;
typedef typename boost::graph_traits< GraphType >::in_edge_iterator InputIterator, InputIteratorEnd;
typedef typename boost::graph_traits< GraphType >::out_edge_iterator OutputIterator, OutputIteratorEnd;
int TestFunction( void );
bool AddComponent( ComponentDescriptorType component );
bool SetComponent( ComponentIndexType componentIndex, ComponentDescriptorType component );
ComponentDescriptorType GetComponent( ComponentIndexType componentIndex );
bool RemoveComponent( ComponentDescriptorType component );
bool SetConnection( ComponentIndexType upstream, ComponentIndexType downstream );
ConnectionDescriptorType GetConnection( ConnectionDescriptorType Connection );
bool RemoveConnection( ConnectionDescriptorType connection );
void PrintGraph( void );
ComponentPropertyType,
ConnectionPropertyType > GraphType;
typedef boost::graph_traits< GraphType >::vertex_descriptor ComponentIndexType;
typedef boost::graph_traits< GraphType >::vertex_iterator ComponentIteratorType;
typedef std::pair< ComponentIteratorType, ComponentIteratorType > ComponentIteratorPairType;
typedef boost::graph_traits< GraphType >::edge_descriptor ConnectionIndexType;
typedef boost::graph_traits< GraphType >::edge_iterator ConnectionIteratorType;
typedef std::pair< ConnectionIteratorType, ConnectionIteratorType > ConnectionIteratorPairType;
typedef boost::graph_traits< GraphType >::in_edge_iterator InputIteratorType;
typedef std::pair< InputIteratorType, InputIteratorType > InputIteratorPairType;
typedef boost::graph_traits< GraphType >::out_edge_iterator OutputIteratorType;
typedef std::pair< OutputIteratorType, OutputIteratorType > OutputIteratorPairType;
// Interface for managing components
ComponentIndexType AddComponent( void );
ComponentIndexType AddComponent( ParameterMapType parameterMap );
ParameterMapType GetComponent( ComponentIndexType index );
void SetComponent( ComponentIndexType, ParameterMapType parameterMap );
// TODO: Let user delete component. Before we do this, we need a proper way of
// checking that a vertex exist. Otherwise a call to GetComponent() on
// a deleted vertex will result in segfault. It is not really a in issue
// _before_ release since typically we (the developers) will use blueprint
// interface procedurally.
// void DeleteComponent( ComponentIndexType );
ComponentIteratorPairType GetComponentIterator( void ) {
return boost::vertices( this->m_Graph );
}
// Interface for managing connections between components in which we
// deliberately avoid using connection indexes, but instead force
// the user to think in terms of components (which is conceptually simpler)
bool AddConnection( ComponentIndexType upstream, ComponentIndexType downstream );
bool AddConnection( ComponentIndexType upstream, ComponentIndexType downstream, ParameterMapType parameterMap );
ParameterMapType GetConnection( ComponentIndexType upstream, ComponentIndexType downstream );
bool SetConnection( ComponentIndexType upstream, ComponentIndexType downstream, ParameterMapType parameterMap );
bool DeleteConnection( ComponentIndexType upstream, ComponentIndexType downstream );
bool ConnectionExists( ComponentIndexType upstream, ComponentIndexType downstream );
// Returns iterator for all connections in the graph
ConnectionIteratorPairType GetConnectionIterator( void ) {
return boost::edges(this->m_Graph);
}
// Returns the outgoing connections from a component in the graph,
// i.e. all components that reads data from given component
OutputIteratorPairType GetOutputIterator( const ComponentIndexType index ) {
return boost::out_edges( index, this->m_Graph );
}
void WriteBlueprint( const std::string filename );
private:
ConnectionIndexType GetConnectionIndex( ComponentIndexType upsteam, ComponentIndexType downstream );
GraphType m_Graph;
......
#ifndef __ComponentDescriptor_h
#define __ComponentDescriptor_h
#include "elxMacro.h"
#include "itkObjectFactory.h"
#include "itkDataObject.h"
namespace elx {
class ComponentDescriptor : public itk::DataObject
{
public:
elxNewMacro( ComponentDescriptor, itk::DataObject );
// Identifier to find component in the component database
typedef std::string ComponentNameType;
ComponentDescriptor( void ) { this->SetComponentName( ComponentNameType() ); }
ComponentDescriptor( const ComponentNameType componentName );
// TODO: Setter should validate ComponentName exists in ComponentDatabase
itkSetMacro( ComponentName, ComponentNameType );
itkGetMacro( ComponentName, ComponentNameType );
private:
ComponentNameType m_ComponentName;
};
}
#endif // __ComponentDescriptor_h
#ifndef __Blueprint_hxx
#define __Blueprint_hxx
#ifndef __Blueprint_cxx
#define __Blueprint_cxx
#include <boost/graph/graphviz.hpp>
#include "boost/graph/graphviz.hpp"
#include "elxBlueprint.h"
namespace elx {
/*
Blueprint< ComponentDescriptor >::ComponentDescriptorType
Blueprint< ComponentDescriptor >
::AddComponent( ComponentDescriptorType component )
Blueprint::ComponentIndexType
Blueprint
::AddComponent( void )
{
// TODO: Check that the component is in the ComponentDatabase
this->Modified();
return this->m_Graph->add_vertex( component );
ComponentIndexType index = boost::add_vertex( this->m_Graph );
// Return component index so component can retrieved at a later time
return index;
}
bool
Blueprint< ComponentDescriptor >
::SetComponent( ComponentDescriptorType component )
Blueprint::ComponentIndexType
Blueprint
::AddComponent( ParameterMapType parameterMap )
{
this->Modified();
ComponentIndexType index = boost::add_vertex( this->m_Graph );
this->m_Graph[index].parameterMap = parameterMap;
// Return component index so component can retrieved at a later time
return index;
}
Blueprint::ParameterMapType
Blueprint
::GetComponent( ComponentIndexType index )
{
this->Modified();
return this->m_Graph->remove_vertex( connection );
return this->m_Graph[ index ].parameterMap;
}
void
Blueprint
::SetComponent( ComponentIndexType index, ParameterMapType parameterMap )
{
this->Modified();
this->m_Graph[ index ].parameterMap = parameterMap;
}
// TODO: See explanation in elxBlueprint.h
// void
// Blueprint
// ::DeleteComponent( const ComponentIndexType index )
// {
// this->Modified();
//
// clear_vertex( index, this->m_Graph );
// remove_vertex( index, this->m_Graph );
// }
bool
Blueprint< ComponentDescriptor >
::RemoveComponent( ComponentDescriptorType component )
Blueprint
::AddConnection( ComponentIndexType upstream, ComponentIndexType downstream )
{
this->Modified();
return this->m_Graph->remove_vertex( connection );
if( this->ConnectionExists( upstream, downstream) ) {
return false;
}
// Adds directed connection from upstream component to downstream component
return boost::add_edge( upstream, downstream, this->m_Graph ).second;
}
bool
Blueprint< ComponentDescriptor >
::AddConnection( ComponentDescriptorType upsteam, ComponentDescriptorType downstream )
Blueprint
::AddConnection( ComponentIndexType upstream, ComponentIndexType downstream, ParameterMapType parameterMap )
{
this->Modified();
if( !this->ConnectionExists( upstream, downstream ) ) {
ConnectionIndexType index = boost::add_edge( upstream, downstream, this->m_Graph ).first;
this->m_Graph[ index ].parameterMap = parameterMap;
return true;
}
// If the connection does not exist don't do anything because previous settings
// will be overwritten. If the user do want to overwrite current settings,
// she should use SetConnection() instead where the intent is explicit.
return false;
}
Blueprint::ParameterMapType
Blueprint
::GetConnection( ComponentIndexType upstream, ComponentIndexType downstream )
{
this->Modified();
return this->m_Graph->add_edge( upstream, downstream );
return this->m_Graph[ this->GetConnectionIndex( upstream, downstream ) ].parameterMap;
}
ConnectionDescriptorType
Blueprint< ComponentDescriptor >
::GetConnection( ConnectionDescriptorType Connection )
bool
Blueprint
::SetConnection( ComponentIndexType upstream, ComponentIndexType downstream, ParameterMapType parameterMap )
{
this->Modified();
if( !this->ConnectionExists( upstream, downstream ) ) {
return this->AddConnection( upstream, downstream, parameterMap );
} else {
this->m_Graph[ this->GetConnectionIndex( upstream, downstream ) ].parameterMap = parameterMap;
return true;
}
}
void
Blueprint< ComponentDescriptor >
::RemoveConnection( ConnectionType connection )
bool
Blueprint
::DeleteConnection( ComponentIndexType upstream, ComponentIndexType downstream )
{
this->Modified();
this->m_Graph->remove_edge( connection );
if( this->ConnectionExists( upstream, downstream ) ) {
this->m_Graph.remove_edge( this->GetConnectionIndex( upstream, downstream ) );
}
return !this->ConnectionExists( upstream, downstream );
}
void
Blueprint< ComponentDescriptor >
::PrintGraph( void )
bool
Blueprint
::ConnectionExists( ComponentIndexType upstream, ComponentIndexType downstream )
{
// TODO: Link to graphviz library
// boost::write_graphviz(std::cout, this->m_Graph);
std::cout << "Printed graph" << std::endl;
return boost::edge( upstream, downstream, this->m_Graph).second;
}
*/
template<>
int
Blueprint< ComponentDescriptor >
::TestFunction( void )
{ return 0; }
Blueprint::ConnectionIndexType
Blueprint
::GetConnectionIndex( ComponentIndexType upstream, ComponentIndexType downstream )
{
// This function is part of the internal API and should fail hard if we use it incorrectly
if( !this->ConnectionExists( upstream, downstream ) ) {
itkExceptionMacro( "Blueprint does not contain connection from component " << upstream << " to " << downstream );
}
return boost::edge( upstream, downstream, this->m_Graph).first;
}
void
Blueprint
::WriteBlueprint( const std::string filename )
{
std::ofstream dotfile( filename.c_str() );
boost::write_graphviz( dotfile, this->m_Graph );
}
} // namespace elx
#endif // __Blueprint_hxx
\ No newline at end of file
#endif // __Blueprint_cxx
#ifndef __ComponentDescriptor_cxx
#define __ComponentDescriptor_cxx
#include "elxComponentDescriptor.h"
// TODO: Need enum for component name?
namespace elx {
ComponentDescriptor
::ComponentDescriptor( const ComponentNameType componentName )
{
this->SetComponentName( componentName );
}
} // namespace elx
#endif // __ComponentDescriptor_cxx
\ No newline at end of file
elxmodule_compile( ${MODULE} )
set( MODULE elxModuleCore )
# Export include files
set( ${MODULE}_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/${MODULE_PATH}/Common/include
${CMAKE_SOURCE_DIR}/${MODULE_PATH}/Blueprints/include
${${MODULE}_SOURCE_DIR}/Common/include
${${MODULE}_SOURCE_DIR}/Blueprints/include
)
# Export libraries
set( ${MODULE}_LIBRARIES
${MODULE}
)
# Module source files
set( ${MODULE}_SOURCE_FILES
${CMAKE_SOURCE_DIR}/${MODULE_PATH}/Blueprints/src/elxComponentDescriptor.cxx
${CMAKE_SOURCE_DIR}/${MODULE_PATH}/Blueprints/src/elxBlueprint.cxx
${${MODULE}_SOURCE_DIR}/Blueprints/src/elxBlueprint.cxx
)
set( ${MODULE}_LIBRARIES
elxModuleCore
)
\ No newline at end of file
# Compile library
add_library( ${MODULE} STATIC "${${MODULE}_SOURCE_FILES}" )
target_link_libraries( ${MODULE} ${ELASTIX_LIBRARIES} )
cmake_minimum_required( VERSION 2.8 )
# ---------------------------------------------------------------------
project( ElastixSuperBuild )
project( SuperElastixSuperBuild )
find_package( Git REQUIRED )
......@@ -25,24 +25,24 @@ endif()
# Build examples by default
# Examples will be build as an external project to verify the installation of elastix
option( ELASTIX_BUILD_EXAMPLES "Enable building examples." ON )
option( SUPERELASTIX_BUILD_EXAMPLES "Enable building examples." ON )
# Build tests by default
option( ELASTIX_BUILD_TESTING "Enable building tests." ON )
if( ELASTIX_BUILD_TESTING )
option( ELASTIX_BUILD_BENCHMARKING "Enable building benchmarks." ON )
option( ELASTIX_BUILD_DASHBOARD "Enable building benchmarks." ON )
option( SUPERELASTIX_BUILD_TESTING "Enable building tests." ON )
if( SUPERELASTIX_BUILD_TESTING )
option( SUPERELASTIX_BUILD_BENCHMARKING "Enable building benchmarks." ON )
option( SUPERELASTIX_BUILD_DASHBOARD "Enable building benchmarks." ON )
endif()
# Do not build dashboard by default
option( ELASTIX_BUILD_DASHBOARD "Enable building dashboard." OFF )
option( SUPERELASTIX_BUILD_DASHBOARD "Enable building dashboard." OFF )
# ---------------------------------------------------------------------
# Build ITK
set( ITK_VERSION_MAJOR "4" )
set( ITK_VERSION_MINOR "7" )
set( ITK_VERSION_MINOR "8" )
set( ITK_VERSION_PATCH "1" )
set( ITK_VERSION_STRING "${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}.${ITK_VERSION_PATCH}" )
......@@ -51,10 +51,9 @@ option( USE_SYSTEM_ITK "Use an installed version of ITK" OFF )
if( USE_SYSTEM_ITK )
find_package( ITK ${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR} REQUIRED )
include( "${CMAKE_CURRENT_SOURCE_DIR}/../CMake/elxRequiredITKModules.cmake" )
include( elxRequiredITKModules )
else()
include( ExternalITK )
list( APPEND ELASTIX_DEPENDENCIES ITK )
endif()
# ---------------------------------------------------------------------
......@@ -66,13 +65,35 @@ if( USE_SYSTEM_BOOST )
find_package( BOOST REQUIRED graph )
else()
include( ExternalBoost )
list( APPEND ELASTIX_DEPENDENCIES BOOST )
endif()
# ---------------------------------------------------------------------
# Build GoogleTest
option( USE_SYSTEM_GOOGLETEST "Use a pre-compiled version of GoogleTest. " OFF )
mark_as_advanced(USE_SYSTEM_GOOGLETEST)
if ( SUPERELASTIX_BUILD_TESTING )
if ( USE_SYSTEM_GOOGLETEST )
find_package( GTest REQUIRED )
else()
include( ExternalGoogleTest )
endif()
endif()
# ---------------------------------------------------------------------
# Build Elastix
include( Elastix )
# TODO: Add USE_SYSTEM_ELASTICLEGACY option
mark_as_advanced( SUPERELASTIX_BUILD_ELASTIX )
option( SUPERELASTIX_BUILD_ELASTIX ON )
if( SUPERELASTIX_BUILD_ELASTIX )
include( ExternalElastix )
endif()
# ---------------------------------------------------------------------
# Build SuperElastix
include( SuperElastix )
set( PROJECT BOOST )
set( proj BOOST )
# Note: It IS important to download different files on different OS's:
# on Unix-like systems, we need the file persmissions (only available in the .tar.gz),
......@@ -19,7 +19,7 @@ else()
endif()
endif()
set( BOOST_BUILD_DIR "${CMAKE_INSTALL_PREFIX}/${PROJECT}-build/" )
set( BOOST_BUILD_DIR "${CMAKE_INSTALL_PREFIX}/${proj}-build/" )
ExternalProject_Add( BOOST
BUILD_IN_SOURCE 1
......@@ -27,13 +27,10 @@ ExternalProject_Add( BOOST
URL_MD5 ${BOOST_MD5}
UPDATE_COMMAND ""
CONFIGURE_COMMAND ${BOOST_CONFIGURE_COMMAND}
--prefix=${BOOST_BUILD_DIR}/lib
BUILD_COMMAND ${BOOST_BUILD_COMMAND} install
--prefix=${BOOST_BUILD_DIR}
--with-graph
--variant=release
--jobs=4
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
set( BOOST_ROOT ${BOOST_BUILD_DIR} )
set( BOOST_ROOT "${CMAKE_INSTALL_PREFIX}/${proj}-prefix/src/BOOST" )
list( APPEND ELASTIX_DEPENDENCIES ${proj} )
set( proj Elastix )
set( ELASTIX_REPOSITORY git://github.com/mstaring/elastix.git )
set( ELASTIX_TAG 6eb6fc7e0d86bafdfdffb1b8bbd125f2a56a486e )
ExternalProject_Add( ${proj}
GIT_REPOSITORY ${ELASTIX_REPOSITORY}
GIT_TAG ${ELASTIX_TAG}
UPDATE_COMMAND ""
SOURCE_DIR ${proj}
BINARY_DIR ${proj}-build
CMAKE_GENERATOR ${gen}
CMAKE_ARGS
--no-warn-unused-cli
-DELASTIX_BUILD_TESTING:BOOL=OFF
-DELASTIX_BUILD_EXECUTABLE:BOOL=OFF
-DELASTIX_BUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DITK_DIR:PATH=${ITK_DIR}
# Elastix components configuration
-DUSE_AdaptiveStochasticGradientDescent:BOOL=ON
-DUSE_AdvancedAffineTransformElastix:BOOL=ON
-DUSE_AdvancedBSplineTransform:BOOL=ON
-DUSE_AdvancedKappaStatisticMetric:BOOL=ON
-DUSE_AdvancedMattesMutualInformationMetric:BOOL=ON
-DUSE_AdvancedMeanSquaresMetric:BOOL=ON
-DUSE_AdvancedNormalizedCorrelationMetric:BOOL=ON
-DUSE_AffineDTITransformElastix:BOOL=ON
-DUSE_BSplineInterpolator:BOOL=ON
-DUSE_BSplineInterpolatorFloat:BOOL=ON
-DUSE_BSplineResampleInterpolator:BOOL=ON
-DUSE_BSplineResampleInterpolatorFloat:BOOL=ON
-DUSE_BSplineStackTransform:BOOL=ON
-DUSE_BSplineTransformWithDiffusion:BOOL=ON
-DUSE_CMAEvolutionStrategy:BOOL=ON
-DUSE_CUDAResampler:BOOL=OFF
-DUSE_ConjugateGradient:BOOL=ON
-DUSE_ConjugateGradientFRPR:BOOL=ON
-DUSE_CorrespondingPointsEuclideanDistanceMetric:BOOL=ON
-DUSE_DeformationFieldTransform:BOOL=ON
-DUSE_DisplacementMagnitudePenalty:BOOL=ON
-DUSE_DistancePreservingRigidityPenalty:BOOL=ON
-DUSE_EulerTransformElastix:BOOL=ON
-DUSE_FiniteDifferenceGradientDescent:BOOL=ON
-DUSE_FixedGenericPyramid:BOOL=ON
-DUSE_FixedRecursivePyramid:BOOL=ON
-DUSE_FixedShrinkingPyramid:BOOL=ON
-DUSE_FixedSmoothingPyramid:BOOL=ON
-DUSE_FullSampler:BOOL=ON
-DUSE_FullSearch:BOOL=ON
-DUSE_GradientDifferenceMetric:BOOL=ON
-DUSE_GridSampler:BOOL=ON
-DUSE_KNNGraphAlphaMutualInformationMetric:BOOL=OFF
-DUSE_LinearInterpolator:BOOL=ON
-DUSE_LinearResampleInterpolator:BOOL=ON
-DUSE_MissingStructurePenalty:BOOL=ON
-DUSE_MovingRecursivePyramid:BOOL=ON
-DUSE_MovingShrinkingPyramid:BOOL=ON
-DUSE_MovingSmoothingPyramid:BOOL=ON
-DUSE_MultiBSplineTransformWithNormal:BOOL=ON
-DUSE_MultiInputRandomCoordinateSampler:BOOL=ON
-DUSE_MultiMetricMultiResolutionRegistration:BOOL=ON
-DUSE_MultiResolutionRegistration:BOOL=ON
-DUSE_MultiResolutionRegistrationWithFeatures:BOOL=ON
-DUSE_MutualInformationHistogramMetric:BOOL=ON
-DUSE_MyStandardResampler:BOOL=ON
-DUSE_NearestNeighborInterpolator:BOOL=ON
-DUSE_NearestNeighborResampleInterpolator:BOOL=ON
-DUSE_NormalizedGradientCorrelationMetric:BOOL=ON
-DUSE_NormalizedMutualInformationMetric:BOOL=ON
-DUSE_PatternIntensityMetric:BOOL=ON
-DUSE_PolydataDummyPenalty:BOOL=ON
-DUSE_Powell:BOOL=ON
-DUSE_QuasiNewtonLBFGS:BOOL=ON
-DUSE_RSGDEachParameterApart:BOOL=ON
-DUSE_RandomCoordinateSampler:BOOL=ON
-DUSE_RandomSampler:BOOL=ON
-DUSE_RandomSamplerSparseMask:BOOL=ON
-DUSE_RayCastInterpolator:BOOL=ON
-DUSE_RayCastResampleInterpolator:BOOL=ON
-DUSE_ReducedDimensionBSplineInterpolator:BOOL=ON
-DUSE_ReducedDimensionBSplineResampleInterpolator:BOOL=ON
-DUSE_RegularStepGradientDescent:BOOL=ON
-DUSE_SimilarityTransformElastix:BOOL=ON
-DUSE_Simplex:BOOL=ON
-DUSE_SimultaneousPerturbation:BOOL=ON
-DUSE_SplineKernelTransform:BOOL=ON
-DUSE_StandardGradientDescent:BOOL=ON
-DUSE_StatisticalShapePenalty:BOOL=ON
-DUSE_TransformBendingEnergyPenanalty:BOOL=ON
-DUSE_TransformRigidityPenalty:BOOL=ON
-DUSE_TranslationTransformElastix:BOOL=ON
-DUSE_VarianceOverLastDimensionMetric:BOOL=ON
-DUSE_ViolaWellsMutualInformationMetric:BOOL=ON
-DUSE_WeightedCombinationTransformElastix:BOOL=ON
DEPENDS ITK
)
ExternalProject_Get_Property( Elastix binary_dir )
set( ELASTIX_USE_FILE "${binary_dir}/src/UseElastix.cmake" )
list( APPEND ELASTIX_DEPENDENCIES ${proj} )
set( proj GoogleTest )
set( GTEST_TARGET_VERSION 1.7.0 )
set( GTEST_DOWNLOAD_SOURCE_HASH "2d6ec8ccdf5c46b05ba54a9fd1d130d7" )
set( GTEST_binary_dir ${CMAKE_CURRENT_BINARY_DIR}/${proj}-prefix/src/${proj}-build )
set( GTEST_source_dir ${CMAKE_CURRENT_BINARY_DIR}/${proj}-prefix/src/${proj} )
set( GTEST_install_dir ${CMAKE_CURRENT_BINARY_DIR}/${proj} )
set( ${proj}_ARCHIVE_OUTPUT_DIRECTORY "<BINARY_DIR>/lib" )
if( MSVC )
set( ${proj}_ARCHIVE_OUTPUT_DIRECTORY "<BINARY_DIR>/lib/$<CONFIGURATION>" )
endif()
set( MSVS_ARGS )
if(MSVC_VERSION EQUAL 1700)
set(MSVS_ARGS ${MSVS_ARGS} -D CMAKE_CXX_FLAGS=-DGTEST_HAS_TR1_TUPLE=0 ${CMAKE_CXX_FLAGS})
endif()
if( MSVC)
set( MSVS_ARGS ${MSVS_ARGS} -D gtest_force_shared_crt:BOOL=ON )
endif()
ExternalProject_Add(${proj}
URL http://midas3.kitware.com/midas/api/rest?method=midas.bitstream.download&checksum=${GTEST_DOWNLOAD_SOURCE_HASH}&name=swig-${GTEST_TARGET_VERSION}.zip
URL_MD5 ${GTEST_DOWNLOAD_SOURCE_HASH}
INSTALL_DIR ${GTEST_install_dir}
CMAKE_GENERATOR ${gen}
CMAKE_ARGS
--no-warn-unused-cli
${MSVS_ARGS}
-D BUILD_SHARED_LIBS:BOOL=OFF
-D CMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=<BINARY_DIR>/lib
INSTALL_COMMAND
${CMAKE_COMMAND} -E copy_directory ${${proj}_ARCHIVE_OUTPUT_DIRECTORY} <INSTALL_DIR>/lib
COMMAND
${CMAKE_COMMAND} -E copy_directory <SOURCE_DIR>/include <INSTALL_DIR>/include
)
set( GTEST_ROOT ${GTEST_install_dir} )
list( APPEND ELASTIX_DEPENDENCIES ${proj} )
set( PROJECT ITK )
set( proj ITK )
set( ITK_REPOSITORY https://github.com/InsightSoftwareConsortium/ITK.git )
set( ITK_TAG "v${ITK_VERSION_STRING}")
ExternalProject_Add( ${PROJECT}
ExternalProject_Add( ${proj}
GIT_REPOSITORY ${ITK_REPOSITORY}
GIT_TAG ${ITK_TAG}
UPDATE_COMMAND ""
SOURCE_DIR ${PROJECT}
BINARY_DIR ${PROJECT}-build
SOURCE_DIR ${proj}
BINARY_DIR ${proj}-build
CMAKE_ARGS
--no-warn-unused-cli
-DBUILD_EXAMPLES:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
-DITK_BUILD_DEFAULT_MODULES:BOOL=ON
-DModule_ITKReview:BOOL=ON
-DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
-DCMAKE_SKIP_RPATH:BOOL=ON
-DITK_LEGACY_REMOVE:BOOL=ON
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
)
ExternalProject_Get_Property( ITK install_dir )
ExternalProject_Get_Property( ${proj} install_dir )
set( ITK_DIR "${install_dir}/lib/cmake/ITK-${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}" )
list( APPEND ELASTIX_DEPENDENCIES ${proj} )
set( proj Elastix )
set( proj SuperElastix )
ExternalProject_Add( ${proj}
DOWNLOAD_COMMAND ""
......@@ -6,12 +6,14 @@ ExternalProject_Add( ${proj}
BINARY_DIR ${proj}-build
CMAKE_ARGS
--no-warn-unused-cli
-DELASTIX_BUILD_EXAMPLES:BOOL=${ELASTIX_BUILD_EXAMPLES}
-DELASTIX_BUILD_TESTING:BOOL=${ELASTIX_BUILD_TESTING}
-DELASTIX_BUILD_BENCHMARKING:BOOL=${ELASTIX_BUILD_BENCHMARKING}
-DELASTIX_BUILD_DASHBOARD:BOOL=${ELASTIX_BUILD_DASHBOARD}
-DSUPERELASTIX_BUILD_EXAMPLES:BOOL=${SUPERELASTIX_BUILD_EXAMPLES}
-DSUPERELASTIX_BUILD_TESTING:BOOL=${SUPERELASTIX_BUILD_TESTING}
-DSUPERELASTIX_BUILD_BENCHMARKING:BOOL=${SUPERELASTIX_BUILD_BENCHMARKING}
-DSUPERELASTIX_BUILD_DASHBOARD:BOOL=${SUPERELASTIX_BUILD_DASHBOARD}
-DITK_DIR:PATH=${ITK_DIR}
-DBOOST_ROOT:PATH=${BOOST_ROOT}
-DGTEST_ROOT:PATH=${GTEST_ROOT}
-DELASTIX_USE_FILE:PATH=${ELASTIX_USE_FILE}
DEPENDS ${ELASTIX_DEPENDENCIES}
INSTALL_COMMAND ""
)
......@@ -30,50 +30,23 @@ endforeach()
ExternalData_Add_Target( ElastixData )
# ---------------------------------------------------------------------
# Add GoogleTest
# Find GoogleTest library
find_package( Git )
if( NOT EXISTS "${CMAKE_SOURCE_DIR}/Testing/GoogleTest/.git" AND GIT_EXECUTABLE )
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_QUIET
)
endif()
if( NOT EXISTS ${CMAKE_SOURCE_DIR}/Testing/GoogleTest/.git )
message(
FATAL_ERROR "Could not find GoogleTest submodule. Please run
git submodule update --init in the source directory to compile tests."
)
endif()
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC" )
include( elxWinConfigGoogleTest.cmake )
endif()
add_subdirectory( GoogleTest )
include_directories(
${gtest_SOURCE_DIR}/include
)
find_package( GTest REQUIRED )
include_directories( ${GTEST_INCLUDE_DIRS} )
set( TEST_LIBRARIES
gtest_main
${GTEST_BOTH_LIBRARIES}
)
# ---------------------------------------------------------------------
# Build test suite
set( CTEST_CONFIGURATION_TYPE Debug )
# Unit tests
add_subdirectory( Unit )
# Benchmarks
option( ELASTIX_BUILD_BENCHMARKING "Enable building benchmarks." OFF )
if( ${ELASTIX_BUILD_BENCHMARKING} )
add_subdirectory( Benchmark )
endif()
# ---------------------------------------------------------------------
# Configure dashboard
mark_as_advanced( ELASTIX_BUILD_DASHBOARD )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment