Commit 03909c9c authored by jcfr's avatar jcfr

ENH: Adding SimpleITK for Linux/Mac

This is a first pass at incorporating
SimpleITK in to Slicer4 with ITK.  It works
on Linux/Mac, but not windows yet.  There is
a known way to make windows work, but that
is going to take some time.

This set of patches will allow for
a parallel set of development improvements
to the Slicer/SimpleITK integration while
the windows swig integration is worked out by
more fully qualifed windows experts.

git-svn-id: http://svn.slicer.org/Slicer4/trunk@18494 3bd1e089-480b-0410-8dfb-8563597acbee
parent c354e881
......@@ -73,6 +73,15 @@ endif()
set(Slicer_DEPENDENCIES LibArchive cmcurl OpenIGTLink teem VTK ${ITK_EXTERNAL_NAME} CTK qCDashAPI SlicerExecutionModel EMSegment ChangeTrackerPy)
if(Slicer_BUILD_WITH_ITKv4)
option(Slicer_BUILD_SimpleITK "Build SimpleITK for Slicer" OFF)
mark_as_advanced(Slicer_BUILD_SimpleITK)
if(Slicer_BUILD_SimpleITK)
list(APPEND SimpleITK_DEPENDENCIES Swig)
list(APPEND Slicer_DEPENDENCIES SimpleITK Swig)
endif()
endif()
if(Slicer_BUILD_BRAINSTOOLS)
list(APPEND Slicer_DEPENDENCIES BRAINSTools)
endif()
......
# Make sure this file is included only once
get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE)
if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED)
return()
endif()
set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1)
# Sanity checks
if(DEFINED PCRE_DIR AND NOT EXISTS ${PCRE_DIR})
message(FATAL_ERROR "PCRE_DIR variable is defined but corresponds to non-existing directory")
endif()
# Set dependency list
set(PCRE_DEPENDENCIES "")
# Include dependent projects if any
SlicerMacroCheckExternalProjectDependency(PCRE)
# Perl Compatible Regular Expressions
ExternalProject_add(PCRE
URL http://downloads.sourceforge.net/project/pcre/pcre/8.12/pcre-8.12.tar.gz
URL_MD5 fa69e4c5d8971544acd71d1f10d59193
CONFIGURE_COMMAND ../PCRE/configure --prefix=${CMAKE_CURRENT_BINARY_DIR}
BUILD_COMMAND ${BUILD_COMMAND_STRING}
)
# Make sure this file is included only once
get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE)
if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED)
return()
endif()
set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1)
# Sanity checks
if(DEFINED SimpleITK_DIR AND NOT EXISTS ${SimpleITK_DIR})
message(FATAL_ERROR "SimpleITK_DIR variable is defined but corresponds to non-existing directory")
endif()
# Set dependency list
set(SimpleITK_DEPENDENCIES "ITKv4;Swig;python")
# Include dependent projects if any
SlicerMacroCheckExternalProjectDependency(SimpleITK)
#
# SimpleITK externalBuild
#
include(ExternalProject)
if(APPLE)
set(SIMPLEITK_PYTHON_ARGS
-DPYTHON_EXECUTABLE:PATH=${slicer_PYTHON_EXECUTABLE}
-DPYTHON_FRAMEWORKS:PATH=${slicer_PYTHON_FRAMEWORK}
-DPYTHON_LIBRARY:FILEPATH=${slicer_PYTHON_LIBRARY}
-DPYTHON_INCLUDE_DIR:PATH=${slicer_PYTHON_INCLUDE}
)
else()
set(SIMPLEITK_PYTHON_ARGS
-DPYTHON_EXECUTABLE:PATH=${slicer_PYTHON_EXECUTABLE}
-DPYTHON_LIBRARY:FILEPATH=${slicer_PYTHON_LIBRARY}
-DPYTHON_INCLUDE_DIR:PATH=${slicer_PYTHON_INCLUDE}
)
endif()
configure_file(SuperBuild/SimpleITK_install_step.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/SimpleITK_install_step.cmake
@ONLY)
set(SimpleITK_INSTALL_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/SimpleITK_install_step.cmake)
ExternalProject_add(SimpleITK
SOURCE_DIR SimpleITK
BINARY_DIR SimpleITK-build
GIT_REPOSITORY http://itk.org/SimpleITK.git
GIT_TAG v0.3.0b
UPDATE_COMMAND ""
CMAKE_ARGS
${ep_common_args}
# SimpleITK does not work with shared libs turned on
-DBUILD_SHARED_LIBS:BOOL=OFF
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}
-DITK_DIR:PATH=${ITK_DIR}
-DBUILD_EXAMPLES:BOOL=ON
-DBUILD_TESTING:BOOL=ON
-DBUILD_DOXYGEN:BOOL=OFF
-DWRAP_PYTHON:BOOL=ON
-DWRAP_TCL:BOOL=OFF
-DWRAP_JAVA:BOOL=OFF
-DWRAP_RUBY:BOOL=OFF
-DWRAP_LUA:BOOL=OFF
${SIMPLEITK_PYTHON_ARGS}
-DSWIG_EXECUTABLE:PATH=${SWIG_EXECUTABLE}
#
INSTALL_COMMAND ${SimpleITK_INSTALL_COMMAND}
#
DEPENDS ${SimpleITK_DEPENDENCIES}
)
# Make sure this file is included only once
get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE)
if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED)
return()
endif()
set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1)
# Sanity checks
if(DEFINED Swig_DIR AND NOT EXISTS ${Swig_DIR})
message(FATAL_ERROR "Swig_DIR variable is defined but corresponds to non-existing directory")
endif()
# Set dependency list
set(Swig_DEPENDENCIES "PCRE")
# Include dependent projects if any
SlicerMacroCheckExternalProjectDependency(Swig)
ExternalProject_add(Swig
URL http://prdownloads.sourceforge.net/swig/swig-2.0.1.tar.gz
URL_MD5 df4465a62ccc5f0120fee0890ea1a31f
CONFIGURE_COMMAND ../Swig/configure --prefix=${CMAKE_CURRENT_BINARY_DIR}
# --without-pcre
--with-pcre-prefix=${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${Swig_DEPENDENCIES}
)
set(SWIG_DIR ${CMAKE_CURRENT_BINARY_DIR}/share/swig/2.0.1)
set(SWIG_EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/bin/swig)
set(Swig_DEPEND Swig)
## This file performs the necessary steps to install SimpleITK into the python environment of Slicer.
execute_process(
COMMAND @slicer_PYTHON_EXECUTABLE@ -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(SimpleITK_SITE_PACKAGE_DIR ${PYTHON_SITE_PACKAGES_DIR})
make_directory( ${SimpleITK_SITE_PACKAGE_DIR} )
configure_file(@CMAKE_CURRENT_BINARY_DIR@/SimpleITK-build/Wrapping/__init__.py ${SimpleITK_SITE_PACKAGE_DIR}/__init__.py COPYONLY)
configure_file(@CMAKE_CURRENT_BINARY_DIR@/SimpleITK-build/lib/_SimpleITK.so ${SimpleITK_SITE_PACKAGE_DIR}/_SimpleITK.so COPYONLY)
configure_file(@CMAKE_CURRENT_BINARY_DIR@/SimpleITK-build/Wrapping/SimpleITK.py ${SimpleITK_SITE_PACKAGE_DIR}/SimpleITK.py COPYONLY)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment