Commit a9c6ab1e authored by jcfr's avatar jcfr

ENH: Add option "Slicer_USE_ITKPython" to turn on ITK Python wrapping.

The option is disabled by default.

Note: This is currently only tested on the build tree with Linux.

This change depends on InsightSoftwareConsortium/ITK@13b368b fixing for
the WrapITK.pth
Reviewed-by: Jean-Christophe Fillion-Robin's avatarJean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>

From: Matt McCormick <matt.mccormick@kitware.com>

git-svn-id: http://svn.slicer.org/Slicer4/trunk@24405 3bd1e089-480b-0410-8dfb-8563597acbee
parent a299d916
......@@ -272,6 +272,9 @@ mark_as_superbuild(Slicer_USE_QtTesting)
option(Slicer_USE_SimpleITK "Build Slicer with SimpleITK support" ON)
mark_as_superbuild(Slicer_USE_SimpleITK)
option(Slicer_USE_ITKPython "Build Python wrapping for ITK" OFF)
mark_as_superbuild(Slicer_USE_ITKPython)
set(default_vtk_version_major 6)
set(VTK_VERSION_MAJOR ${default_vtk_version_major} CACHE STRING "Choose the expected VTK major version to build Slicer (5 or 6).")
......
......@@ -6,6 +6,9 @@ set(${proj}_DEPENDENCIES "zlib")
if(Slicer_BUILD_DICOM_SUPPORT)
list(APPEND ${proj}_DEPENDENCIES DCMTK)
endif()
if(Slicer_USE_ITKPython)
list(APPEND ${proj}_DEPENDENCIES Swig python)
endif()
# Include dependent projects if any
ExternalProject_Include_Dependencies(${proj} PROJECT_VAR proj DEPENDS_VAR ${proj}_DEPENDENCIES)
......@@ -31,7 +34,7 @@ if(NOT DEFINED ITK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
set(EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS)
if(Slicer_USE_PYTHONQT)
if(Slicer_USE_PYTHONQT OR Slicer_USE_ITKPython)
# XXX Ensure python executable used for ITKModuleHeaderTest
# is the same as Slicer.
# This will keep the sanity check implemented in SlicerConfig.cmake
......@@ -40,6 +43,31 @@ if(NOT DEFINED ITK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
-DPYTHON_EXECUTABLE:PATH=${PYTHON_EXECUTABLE}
)
endif()
if(Slicer_USE_ITKPython)
list(APPEND EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS
-DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY}
-DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR}
-DITK_WRAP_PYTHON:BOOL=ON
-DSWIG_EXECUTABLE:PATH=${SWIG_EXECUTABLE}
-DITK_USE_SYSTEM_SWIG:BOOL=ON
-DITK_LEGACY_SILENT:BOOL=ON
)
# Install WrapITK.pth for use in the build tree
set(python_check "from __future__ import print_function\ntry:\n import distutils.sysconfig\n print(distutils.sysconfig.get_python_lib(plat_specific=1))\nexcept:\n pass")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/det_spp.py ${python_check})
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}/det_spp.py"
OUTPUT_VARIABLE py_spp
ERROR_VARIABLE py_spp
)
string(REGEX REPLACE "\n" "" py_spp_no_newline "${py_spp}")
string(REGEX REPLACE "\\\\" "/" py_spp_nobackslashes "${py_spp_no_newline}")
set(_install_command ${CMAKE_COMMAND} -E copy
"${CMAKE_BINARY_DIR}/${proj}-build/Wrapping/Generators/Python/WrapITK.pth"
"${py_spp_nobackslashes}"
)
else()
set(_install_command "")
endif()
ExternalProject_Add(${proj}
${${proj}_EP_ARGS}
......@@ -74,7 +102,7 @@ if(NOT DEFINED ITK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
-DZLIB_INCLUDE_DIR:PATH=${ZLIB_INCLUDE_DIR}
-DZLIB_LIBRARY:FILEPATH=${ZLIB_LIBRARY}
${EXTERNAL_PROJECT_OPTIONAL_CMAKE_CACHE_ARGS}
INSTALL_COMMAND ""
INSTALL_COMMAND ${_install_command}
DEPENDS
${${proj}_DEPENDENCIES}
)
......
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