diff --git a/CMake/elxModules.cmake b/CMake/elxModules.cmake index 1e4955cb693e7a071a8eb10779ca64149ea8ecba..0b993b9570fca4351a47dacadb59c42e476d1f3b 100644 --- a/CMake/elxModules.cmake +++ b/CMake/elxModules.cmake @@ -16,28 +16,25 @@ macro( _elxmodule_enable MODULE ) _elxmodule_check_name( ${MODULE} ) if( NOT ${MODULE}_ENABLED ) - set( "${MODULE}_ENABLED" ON ) + set( USE_${MODULE} ON ) - add_subdirectory( "${${MODULE}_SOURCE_DIR}" ) + include( ${${MODULE}_FILE} ) if( ${MODULE}_INCLUDE_DIRS ) include_directories( ${${MODULE}_INCLUDE_DIRS} ) endif() + add_subdirectory( ${${MODULE}_SOURCE_DIR} ) + if( ${MODULE}_LIBRARIES ) - link_directories( ${${MODULE}_LIBRARY_DIR} ) - endif() + link_directories( ${${MODULE}_LIBRARY_DIRS} ) - if( ${${MODULE}_LIBRARIES} ) list( APPEND ELASTIX_LIBRARIES ${${MODULE}_LIBRARIES} ) endif() # TODO: Add recursive dependency walk - # foreach( DEPENDENCY IN LISTS ${MODULE}_DEPENDS ) - # _elxmodule_enable( ${DEPENDENCY} ) - # endforeach() endif() endmacro() @@ -49,7 +46,7 @@ macro( _elxmodules_initialize ) set( ELXMODULE_ALL ) file( GLOB MODULE_FILES RELATIVE "${CMAKE_SOURCE_DIR}" - "${CMAKE_SOURCE_DIR}/Modules/*/ELXMODULE_*.cmake" + "${CMAKE_SOURCE_DIR}/Modules/*/elxModule*.cmake" ) message( STATUS "Found the following elastix modules:") @@ -59,10 +56,14 @@ macro( _elxmodules_initialize ) message( STATUS " ${MODULE}" ) option( "USE_${MODULE}" OFF ) + set( "${MODULE}_FILE" ${CMAKE_SOURCE_DIR}/${MODULE_FILE} ) set( "${MODULE}_ENABLED" OFF ) set( ${MODULE}_SOURCE_DIR ${CMAKE_SOURCE_DIR}/${MODULE_PATH} ) set( ${MODULE}_BINARY_DIR ${CMAKE_BINARY_DIR}/${MODULE_PATH} ) + + set( ${MODULE}_INCLUDE_DIRS ) + set( ${MODULE}_LIBRARY_DIRS ) set( ${MODULE}_LIBRARIES ) list(APPEND ELXMODULE_ALL ${MODULE} ) @@ -75,8 +76,12 @@ _elxmodules_initialize() # Public interface macro( elxmodule_enable MODULE ) - option( USE_${MODULE} ON ) _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() diff --git a/CMakeLists.txt b/CMakeLists.txt index 96e2f9c876f751b4dda3f391569ab098f688721f..eea7b29716863cb1db0a6dd49cd4fbc9f6ef7f3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,11 @@ set( MSVC_INCREMENTAL_DEFAULT ON ) # --------------------------------------------------------------------- project( Elastix ) +# Place libraries and executables in the bin directory +set( CMAKE_RUNTIME_OUTPUT_DIRECTORY + "${CMAKE_BINARY_DIR}/bin" +) + # Include SuperElastix CMake scripts set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" @@ -27,26 +32,14 @@ include( "${CMAKE_CURRENT_SOURCE_DIR}/CMake/elxITKRequiredModules.cmake" ) # --------------------------------------------------------------------- # Boost Graph Library find_package( Boost REQUIRED graph ) -include_directories(${Boost_INCLUDE_DIRS}) +include_directories( ${Boost_INCLUDE_DIRS} ) # --------------------------------------------------------------------- # Build Elastix -set( ELASTIX_COMMON_INCLUDE_DIRECTORIES - ${CMAKE_SOURCE_DIR}/Modules/Core/Common/include -) - -set( ELASTIX_CORE_INCLUDE_DIRECTORIES - ${CMAKE_SOURCE_DIR}/Modules/Core/Blueprints/include -) - -set( ELASTIX_INCLUDE_DIRECTORIES - ${ELASTIX_COMMON_INCLUDE_DIRECTORIES} - ${ELASTIX_CORE_INCLUDE_DIRECTORIES} -) - -include_directories( ${ELASTIX_INCLUDE_DIRECTORIES} ) -add_subdirectory( Modules ) +# For now we just enable all modules +include( "${CMAKE_CURRENT_SOURCE_DIR}/CMake/elxModules.cmake" ) +elxmodule_enable( elxModuleCore ) # --------------------------------------------------------------------- # Testing diff --git a/Modules/Core/Blueprints/CMakeLists.txt b/Modules/Core/Blueprints/CMakeLists.txt deleted file mode 100644 index 88e196eb772e989b05c104ac6e047e24e6d0a09d..0000000000000000000000000000000000000000 --- a/Modules/Core/Blueprints/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -include_directories( include ) -add_subdirectory( src ) diff --git a/Modules/Core/Blueprints/include/elxComponentDescriptor.h b/Modules/Core/Blueprints/include/elxComponentDescriptor.h index 8cfcde65694a513cbf50750ab4bcfbce076f0d84..8f5402e4526532088cc8089d4af95d775a848b33 100644 --- a/Modules/Core/Blueprints/include/elxComponentDescriptor.h +++ b/Modules/Core/Blueprints/include/elxComponentDescriptor.h @@ -2,6 +2,7 @@ #define __ComponentDescriptor_h #include "elxMacro.h" +#include "itkObjectFactory.h" #include "itkDataObject.h" namespace elx { @@ -15,6 +16,9 @@ public: // 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 ); diff --git a/Modules/Core/Blueprints/src/CMakeLists.txt b/Modules/Core/Blueprints/src/CMakeLists.txt deleted file mode 100644 index 28d535fe78ba61e547940c35eb07c7cc6469cad5..0000000000000000000000000000000000000000 --- a/Modules/Core/Blueprints/src/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -message( STATUS "In directory ${CMAKE_CURRENT_LIST_DIR}" ) - -add_library( Blueprints - elxComponentDescriptor.cxx - elxBlueprint.cxx -) \ No newline at end of file diff --git a/Modules/Core/Blueprints/src/elxBlueprint.cxx b/Modules/Core/Blueprints/src/elxBlueprint.cxx index 2c7e3d32aa93832d805aceb3937d4e82b1971ead..b3319d01551325a82b0926f0f1a33fd4fd3f7abf 100644 --- a/Modules/Core/Blueprints/src/elxBlueprint.cxx +++ b/Modules/Core/Blueprints/src/elxBlueprint.cxx @@ -5,16 +5,10 @@ #include "elxBlueprint.h" -namespace elastix { +namespace elx { -void -Blueprint< ComponentDescriptor > -::Blueprint( void ) -{ - this->SetGraph( GraphType ); -} - -ComponentDescriptorType +/* +Blueprint< ComponentDescriptor >::ComponentDescriptorType Blueprint< ComponentDescriptor > ::AddComponent( ComponentDescriptorType component ) { @@ -70,11 +64,14 @@ Blueprint< ComponentDescriptor > // boost::write_graphviz(std::cout, this->m_Graph); std::cout << "Printed graph" << std::endl; } -void +*/ + +template<> +int Blueprint< ComponentDescriptor > ::TestFunction( void ) { return 0; } -} +} // namespace elx #endif // __Blueprint_hxx \ No newline at end of file diff --git a/Modules/Core/Blueprints/src/elxComponentDescriptor.cxx b/Modules/Core/Blueprints/src/elxComponentDescriptor.cxx index b37f5f3fbf8bfbac685ad6eb3a43f88a59903827..9589451733f5f3b2c14b45e990f70711bab241e5 100644 --- a/Modules/Core/Blueprints/src/elxComponentDescriptor.cxx +++ b/Modules/Core/Blueprints/src/elxComponentDescriptor.cxx @@ -1,5 +1,5 @@ -#ifndef __ComponentDescriptor_hxx -#define __ComponentDescriptor_hxx +#ifndef __ComponentDescriptor_cxx +#define __ComponentDescriptor_cxx #include "elxComponentDescriptor.h" @@ -11,36 +11,8 @@ ComponentDescriptor ::ComponentDescriptor( const ComponentNameType componentName ) { this->SetComponentName( componentName ); - this->SetComponentUniqueId( this->GenerateUniqueId() ); - this->SetParameterMap( this->ParameterMapType() ); -} - -ComponentDescriptor -::ComponentDescriptor( const ComponentNameType componentName, - const ComponentUniqueIdType componentUniqueId ) -{ - this->SetComponentName( componentName ); - this->SetComponentUniqueId( componentUniqueId ); - this->SetParameterMap( this->ParameterMapType() ); -} - -ComponentDescriptor -::ComponentDescriptor( const ComponentNameType componentName, - const ComponentIdType componentUniqueId, - const ParameterMapType parameterMap ) -{ - this->SetComponentName( componentName ); - this->SetComponentUniqueId( componentUniqueId ); - this->SetParameterMap( parameterMap ); -} - -ComponentDescriptor::ComponentIdType -ComponentDescriptor -::GenerateUniqueId() -{ - } } // namespace elx -#endif // __ComponentDescriptor_hxx \ No newline at end of file +#endif // __ComponentDescriptor_cxx \ No newline at end of file diff --git a/Modules/Core/CMakeLists.txt b/Modules/Core/CMakeLists.txt index d45d6001371a6a233a3ec2fb1941853f422a27a6..50296aa3c753ddf0818b1b78653383350f700b40 100644 --- a/Modules/Core/CMakeLists.txt +++ b/Modules/Core/CMakeLists.txt @@ -1,15 +1 @@ -project( ELXMODULE_CORE ) - -# TODO: Include directures using the module API -include_directories( - Common/include - Blueprints/include -) - -add_subdirectory( Common ) -add_subdirectory( Blueprints ) - -set( "${PROJECT_NAME}_LIBRARIES" - Blueprints -) - +elxmodule_compile( ${MODULE} ) diff --git a/Modules/Core/Common/CMakeLists.txt b/Modules/Core/Common/CMakeLists.txt deleted file mode 100644 index b83cfce3b85bc48c4c713194051c1e70655c7a95..0000000000000000000000000000000000000000 --- a/Modules/Core/Common/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -include_directories( include ) diff --git a/Modules/Core/ELXMODULE_CORE.cmake b/Modules/Core/ELXMODULE_CORE.cmake deleted file mode 100644 index f0ed9132d95b47c2c4528d98e9feb6a24d8aee7b..0000000000000000000000000000000000000000 --- a/Modules/Core/ELXMODULE_CORE.cmake +++ /dev/null @@ -1,10 +0,0 @@ -set( DOCUMENTATION - "This module contains the core components of elastix library such as the component database and component pipeline instantiation functionality." -) - -elxmodule_enable( ELXMODULE_CORE - DEPENDS - ELXMODULE_COMMON - DESCRIPTION - "${DOCUMENTATION}" -) diff --git a/Modules/Core/elxModuleCore.cmake b/Modules/Core/elxModuleCore.cmake new file mode 100644 index 0000000000000000000000000000000000000000..eaebd893405d56be9b9edeb671461538b04cca09 --- /dev/null +++ b/Modules/Core/elxModuleCore.cmake @@ -0,0 +1,13 @@ +set( ${MODULE}_INCLUDE_DIRS + ${CMAKE_SOURCE_DIR}/${MODULE_PATH}/Common/include + ${CMAKE_SOURCE_DIR}/${MODULE_PATH}/Blueprints/include +) + +set( ${MODULE}_SOURCE_FILES + ${CMAKE_SOURCE_DIR}/${MODULE_PATH}/Blueprints/src/elxComponentDescriptor.cxx + ${CMAKE_SOURCE_DIR}/${MODULE_PATH}/Blueprints/src/elxBlueprint.cxx +) + +set( ${MODULE}_LIBRARIES + elxModuleCore +) \ No newline at end of file diff --git a/Testing/Unit/elxBluePrintTest.cxx b/Testing/Unit/elxBluePrintTest.cxx index 31dc1d8eb25d5af8536a9b3bca11568a22d16ae2..8aa289fc4201a92af8d6c185905855bd58c5ab4e 100644 --- a/Testing/Unit/elxBluePrintTest.cxx +++ b/Testing/Unit/elxBluePrintTest.cxx @@ -24,4 +24,4 @@ TEST( Blueprint, Instantiation ) ASSERT_TRUE( true ); } -} // namespace elx \ No newline at end of file +} // namespace elx