Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add support for conditionally building with ITKFactoryRegistration #851

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Applications/SlicerApp/Main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
#include "qSlicerStyle.h"

// ITK includes
#ifdef Slicer_USE_ITKFactoryRegistration
#include <itkFactoryRegistration.h>
#endif

// VTK includes
//#include <vtkObject.h>
Expand Down Expand Up @@ -95,7 +97,9 @@ void splashMessage(QScopedPointer<QSplashScreen>& splashScreen, const QString& m
//----------------------------------------------------------------------------
int SlicerAppMain(int argc, char* argv[])
{
#ifdef Slicer_USE_ITKFactoryRegistration
itk::itkFactoryRegistration();
#endif

#if QT_VERSION >= 0x040803
#ifdef Q_OS_MACX
Expand Down
15 changes: 13 additions & 2 deletions Base/CLI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,23 @@ include_directories(${include_dirs})
# --------------------------------------------------------------------------
# Update SlicerExecutionModel_EXTRA_INCLUDE_DIRECTORIES
# --------------------------------------------------------------------------
set(SlicerExecutionModel_EXTRA_INCLUDE_DIRECTORIES
set(_include_dirs
${SlicerExecutionModel_EXTRA_INCLUDE_DIRECTORIES}
${Slicer_BaseCLI_INCLUDE_DIRS}
${ITKFactoryRegistration_INCLUDE_DIRS}
)
if(Slicer_USE_ITKFactoryRegistration)
list(APPEND _include_dirs
${ITKFactoryRegistration_INCLUDE_DIRS}
)
endif()
set(SlicerExecutionModel_EXTRA_INCLUDE_DIRECTORIES
${_include_dirs}
CACHE INTERNAL "SlicerExecutionModel extra includes" FORCE
)

# --------------------------------------------------------------------------
# Update SlicerExecutionModel_CLI_LIBRARY_WRAPPER_CXX
# --------------------------------------------------------------------------
set(SlicerExecutionModel_CLI_LIBRARY_WRAPPER_CXX
${CMAKE_CURRENT_BINARY_DIR}/SEMCommandLineLibraryWrapper.cxx
CACHE INTERNAL "SlicerExecutionModel extra includes" FORCE
Expand Down
9 changes: 9 additions & 0 deletions Base/CLI/Testing/itkTestMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@
#include "itksys/SystemTools.hxx"
#include "itkIntTypes.h"
#include "itkFloatingPointExceptions.h"

// Slicer includes
#include <vtkSlicerConfigure.h> //For Slicer_* macros

// ITK includes
#ifdef Slicer_USE_ITKFactoryRegistration
#include <itkFactoryRegistration.h>
#endif

#define ITK_TEST_DIMENSION_MAX 6

Expand Down Expand Up @@ -96,7 +103,9 @@ int main(int ac, char *av[])
typedef std::pair<char *, char *> ComparePairType;
std::vector<ComparePairType> compareList;

#ifdef Slicer_USE_ITKFactoryRegistration
itk::itkFactoryRegistration();
#endif

RegisterTests();
std::string testToRun;
Expand Down
12 changes: 7 additions & 5 deletions Base/Logic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ if(Slicer_BUILD_CLI_SUPPORT)
list(APPEND ${PROJECT_NAME}_ITK_COMPONENTS ${ModuleDescriptionParser_ITK_COMPONENTS})
endif()
find_package(ITK 4.6 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED)
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
list(APPEND ITK_LIBRARIES ITKFactoryRegistration)
list(APPEND ITK_INCLUDE_DIRS
${ITKFactoryRegistration_INCLUDE_DIRS}
)
if(Slicer_USE_ITKFactoryRegistration)
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
list(APPEND ITK_LIBRARIES ITKFactoryRegistration)
list(APPEND ITK_INCLUDE_DIRS
${ITKFactoryRegistration_INCLUDE_DIRS}
)
endif()
include(${ITK_USE_FILE})

#
Expand Down
4 changes: 3 additions & 1 deletion Base/QTCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ if(Slicer_BUILD_CLI_SUPPORT)
ITKCommon
)
find_package(ITK 4.6 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED)
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
if(Slicer_USE_ITKFactoryRegistration)
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
endif()
include(${ITK_USE_FILE})
endif()

Expand Down
23 changes: 16 additions & 7 deletions Base/QTGUI/Testing/Cxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,34 @@ if(BUILD_TESTING)
ITKCommon
)
find_package(ITK 4.6 COMPONENTS ${${KIT}Testing_ITK_COMPONENTS} REQUIRED)
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
list(APPEND ITK_LIBRARIES ITKFactoryRegistration)
list(APPEND ITK_INCLUDE_DIRS
${ITKFactoryRegistration_INCLUDE_DIRS}
)
if(Slicer_USE_ITKFactoryRegistration)
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
list(APPEND ITK_LIBRARIES ITKFactoryRegistration)
list(APPEND ITK_INCLUDE_DIRS
${ITKFactoryRegistration_INCLUDE_DIRS}
)
endif()
include(${ITK_USE_FILE})

#-----------------------------------------------------------------------------
set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "
DEBUG_LEAKS_ENABLE_EXIT_ERROR();
TESTING_OUTPUT_INIT();
itk::itkFactoryRegistration();
")
if(Slicer_USE_ITKFactoryRegistration)
set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "${CMAKE_TESTDRIVER_BEFORE_TESTMAIN}
itk::itkFactoryRegistration();
")
endif()

set(CMAKE_TESTDRIVER_AFTER_TESTMAIN "
TESTING_OUTPUT_ASSERT_WARNINGS_ERRORS(0);
")

set(EXTRA_INCLUDE "vtkMRMLDebugLeaksMacro.h\"\n\#include <itkConfigure.h>\n\#include <itkFactoryRegistration.h>\n\#include \"vtkTestingOutputWindow.h")
set(EXTRA_INCLUDE "vtkMRMLDebugLeaksMacro.h\"\n\#include <itkConfigure.h>\n\#include \"vtkTestingOutputWindow.h")
if(Slicer_USE_ITKFactoryRegistration)
set(EXTRA_INCLUDE "${EXTRA_INCLUDE}\"\n\#include \"itkFactoryRegistration.h")
endif()

include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(KIT_TEST_SRCS
Expand Down
1 change: 1 addition & 0 deletions CMake/SlicerConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ endif()
# --------------------------------------------------------------------------
# Slicer options
# --------------------------------------------------------------------------
set(Slicer_USE_ITKFactoryRegistration "@Slicer_USE_ITKFactoryRegistration@")
set(Slicer_USE_NUMPY "@Slicer_USE_NUMPY@")
set(Slicer_USE_OpenIGTLink "@Slicer_USE_OpenIGTLink@")
set(Slicer_USE_PYTHONQT "@Slicer_USE_PYTHONQT@")
Expand Down
12 changes: 7 additions & 5 deletions CMake/UseSlicer.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ endif()
# Prerequisites
# --------------------------------------------------------------------------

# Expose mechanism allowing extensions to register ITK IOFactories.
# For details: http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=21592
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
list(APPEND ITK_LIBRARIES ITKFactoryRegistration)
list(APPEND ITK_INCLUDE_DIRS ${ITKFactoryRegistration_INCLUDE_DIRS})
if(Slicer_USE_ITKFactoryRegistration)
# Expose mechanism allowing extensions to register ITK IOFactories.
# For details: http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=21592
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
list(APPEND ITK_LIBRARIES ITKFactoryRegistration)
list(APPEND ITK_INCLUDE_DIRS ${ITKFactoryRegistration_INCLUDE_DIRS})
endif()

# By default, the "<PROJECT>_USE_FILE" of each slicer external project will be included.
# This can be changed by setting the variable Slicer_SKIP_EXTERNAL_PROJECTS_USEFILE to TRUE
Expand Down
1 change: 1 addition & 0 deletions CMake/vtkSlicerConfigure.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#endif

#cmakedefine Slicer_USE_IGSTK
#cmakedefine Slicer_USE_ITKFactoryRegistration
#cmakedefine Slicer_USE_NAVITRACK
#cmakedefine Slicer_USE_NUMPY
#cmakedefine Slicer_USE_PYTHONQT
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ CMAKE_DEPENDENT_OPTION(
"Slicer_BUILD_CLI_SUPPORT" OFF
)

if(NOT DEFINED Slicer_USE_ITKFactoryRegistration)
set(Slicer_USE_ITKFactoryRegistration ${Slicer_BUILD_CLI_SUPPORT})
endif()
mark_as_superbuild(Slicer_USE_ITKFactoryRegistration:BOOL)

mark_as_superbuild(Slicer_BUILD_CLI)
CMAKE_DEPENDENT_OPTION(
Slicer_BUILD_LEGACY_CLI "Build Slicer LEGACY_CLI Plugins" ON
Expand Down
16 changes: 9 additions & 7 deletions Libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ set(GENERATECLP_USE_MD5 ON)

set(dirs )

list(APPEND dirs
ITKFactoryRegistration
)
set(SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES
${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES} ITKFactoryRegistration
CACHE INTERNAL "SlicerExecutionModel extra executable target libraries" FORCE
)
if(Slicer_USE_ITKFactoryRegistration)
list(APPEND dirs
ITKFactoryRegistration
)
set(SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES
${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES} ITKFactoryRegistration
CACHE INTERNAL "SlicerExecutionModel extra executable target libraries" FORCE
)
endif()

list(APPEND dirs
vtkAddon
Expand Down
8 changes: 5 additions & 3 deletions Libs/MRML/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ set(${PROJECT_NAME}_ITK_COMPONENTS
ITKTransform
)
find_package(ITK 4.6 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED)
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
list(APPEND ITK_LIBRARIES ITKFactoryRegistration)
list(APPEND ITK_INCLUDE_DIRS ${ITKFactoryRegistration_INCLUDE_DIRS})
if(Slicer_USE_ITKFactoryRegistration)
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
list(APPEND ITK_LIBRARIES ITKFactoryRegistration)
list(APPEND ITK_INCLUDE_DIRS ${ITKFactoryRegistration_INCLUDE_DIRS})
endif()
include(${ITK_USE_FILE})

#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@

=========================================================================auto=*/

// Slicer includes
#include <vtkSlicerConfigure.h> // For Slicer_* macros

// ITK includes
#include <itkConfigure.h>
#ifdef Slicer_USE_ITKFactoryRegistration
#include <itkFactoryRegistration.h>
#endif

#include "vtkOrientedBSplineTransform.h"
#include "vtkOrientedGridTransform.h"
Expand Down Expand Up @@ -40,7 +44,9 @@ int TestGetTransform();

int vtkMRMLNonlinearTransformNodeTest1(int argc, char * argv[] )
{
#ifdef Slicer_USE_ITKFactoryRegistration
itk::itkFactoryRegistration();
#endif

const char *filename = 0;
if (argc > 1)
Expand Down
8 changes: 5 additions & 3 deletions Libs/MRML/IDImageIO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ set(${PROJECT_NAME}_ITK_COMPONENTS
ITKIOImageBase
)
find_package(ITK 4.6 COMPONENTS ${${PROJECT_NAME}_ITK_COMPONENTS} REQUIRED)
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
list(APPEND ITK_LIBRARIES ITKFactoryRegistration)
list(APPEND ITK_INCLUDE_DIRS ${ITKFactoryRegistration_INCLUDE_DIRS})
if(Slicer_USE_ITKFactoryRegistration)
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
list(APPEND ITK_LIBRARIES ITKFactoryRegistration)
list(APPEND ITK_INCLUDE_DIRS ${ITKFactoryRegistration_INCLUDE_DIRS})
endif()
include(${ITK_USE_FILE})

#
Expand Down
12 changes: 7 additions & 5 deletions Libs/MRML/Logic/Testing/Cxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ set(${KIT}Testing_ITK_COMPONENTS
ITKCommon
)
find_package(ITK 4.6 COMPONENTS ${${KIT}Testing_ITK_COMPONENTS} REQUIRED)
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
list(APPEND ITK_LIBRARIES ITKFactoryRegistration)
list(APPEND ITK_INCLUDE_DIRS
${ITKFactoryRegistration_INCLUDE_DIRS}
)
if(Slicer_USE_ITKFactoryRegistration)
set(ITK_NO_IO_FACTORY_REGISTER_MANAGER 1) # See Libs/ITKFactoryRegistration/CMakeLists.txt
list(APPEND ITK_LIBRARIES ITKFactoryRegistration)
list(APPEND ITK_INCLUDE_DIRS
${ITKFactoryRegistration_INCLUDE_DIRS}
)
endif()
include(${ITK_USE_FILE})

#-----------------------------------------------------------------------------
Expand Down
8 changes: 7 additions & 1 deletion Libs/MRML/Logic/Testing/Cxx/vtkMRMLSliceLogicTest2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,20 @@
#include <vtkTimerLog.h>
#include <vtkVersion.h>

// Slicer includes
#include <vtkSlicerConfigure.h> // For Slicer_* macros

// ITK includes
#include <itkConfigure.h>
#ifdef Slicer_USE_ITKFactoryRegistration
#include <itkFactoryRegistration.h>
#endif

//-----------------------------------------------------------------------------
int vtkMRMLSliceLogicTest2(int argc, char * argv [] )
{
#ifdef Slicer_USE_ITKFactoryRegistration
itk::itkFactoryRegistration();
#endif
// vtkMultiThreader::SetGlobalMaximumNumberOfThreads(1);

if( argc < 2 )
Expand Down
8 changes: 7 additions & 1 deletion Libs/MRML/Logic/Testing/Cxx/vtkMRMLSliceLogicTest3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@
#include <vtkTimerLog.h>
#include <vtkVersion.h>

// Slicer includes
#include <vtkSlicerConfigure.h> // For Slicer_* macros

// ITK includes
#include <itkConfigure.h>
#ifdef Slicer_USE_ITKFactoryRegistration
#include <itkFactoryRegistration.h>
#endif

//-----------------------------------------------------------------------------
vtkMRMLScalarVolumeNode* loadVolume(const char* volume, vtkMRMLScene* scene)
Expand Down Expand Up @@ -81,7 +85,9 @@ vtkMRMLScalarVolumeNode* loadVolume(const char* volume, vtkMRMLScene* scene)
//-----------------------------------------------------------------------------
int vtkMRMLSliceLogicTest3(int argc, char * argv [] )
{
#ifdef Slicer_USE_ITKFactoryRegistration
itk::itkFactoryRegistration();
#endif

if( argc < 2 )
{
Expand Down
8 changes: 7 additions & 1 deletion Libs/MRML/Logic/Testing/Cxx/vtkMRMLSliceLogicTest4.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@
#include <vtkNew.h>
#include <vtkVersion.h>

// Slicer includes
#include <vtkSlicerConfigure.h> // For Slicer_* macros

// ITK includes
#include <itkConfigure.h>
#ifdef Slicer_USE_ITKFactoryRegistration
#include <itkFactoryRegistration.h>
#endif

//-----------------------------------------------------------------------------
vtkMRMLScalarVolumeNode* loadVolume2(const char* volume, vtkMRMLScene* scene)
Expand Down Expand Up @@ -79,7 +83,9 @@ vtkMRMLScalarVolumeNode* loadVolume2(const char* volume, vtkMRMLScene* scene)
//-----------------------------------------------------------------------------
int vtkMRMLSliceLogicTest4(int argc, char * argv [] )
{
#ifdef Slicer_USE_ITKFactoryRegistration
itk::itkFactoryRegistration();
#endif

if( argc < 2 )
{
Expand Down
8 changes: 7 additions & 1 deletion Libs/MRML/Logic/Testing/Cxx/vtkMRMLSliceLogicTest5.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@
#include <vtkTimerLog.h>
#include <vtkVersion.h>

// Slicer includes
#include <vtkSlicerConfigure.h> // For Slicer_* macros

// ITK includes
#include <itkConfigure.h>
#ifdef Slicer_USE_ITKFactoryRegistration
#include <itkFactoryRegistration.h>
#endif

//-----------------------------------------------------------------------------
vtkMRMLScalarVolumeNode* vtkMRMLSliceLogicTest5_loadVolume(const char* volume, vtkMRMLScene* scene)
Expand Down Expand Up @@ -83,7 +87,9 @@ vtkMRMLScalarVolumeNode* vtkMRMLSliceLogicTest5_loadVolume(const char* volume, v
//-----------------------------------------------------------------------------
int vtkMRMLSliceLogicTest5(int argc, char * argv [] )
{
#ifdef Slicer_USE_ITKFactoryRegistration
itk::itkFactoryRegistration();
#endif

if( argc < 2 )
{
Expand Down
Loading