Commit f30326eb authored by jcfr's avatar jcfr

COMP: Factor out VTK specific python wrapping code into vtkMacroKitPythonWrap

git-svn-id: http://svn.slicer.org/Slicer4/trunk@16345 3bd1e089-480b-0410-8dfb-8563597acbee
parent 8ee316d4
......@@ -182,38 +182,17 @@ install(TARGETS ${lib_name}
# Create Python wrappers if VTK is wrapped in Python
#
IF(VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS)
SET(KIT_PYTHON_LIBRARIES ${VTK_LIBRARIES})
INCLUDE(${VTK_CMAKE_DIR}/vtkWrapPython.cmake)
VTK_WRAP_PYTHON3(${lib_name}Python PYTHON_SRCS "${SlicerBaseLogic_SRCS}")
ADD_LIBRARY(${lib_name}PythonD ${PYTHON_SRCS})
SET_TARGET_PROPERTIES(${lib_name}PythonD PROPERTIES LABELS ${lib_name})
ADD_LIBRARY(${lib_name}Python MODULE ${lib_name}PythonInit.cxx)
SET_TARGET_PROPERTIES(${lib_name}Python PROPERTIES LABELS ${lib_name})
TARGET_LINK_LIBRARIES(${lib_name}PythonD ${lib_name})
TARGET_LINK_LIBRARIES(${lib_name}PythonD MRMLLogicPythonD)
FOREACH(c ${KIT_PYTHON_LIBRARIES})
TARGET_LINK_LIBRARIES(${lib_name}PythonD ${c}PythonD)
ENDFOREACH(c)
TARGET_LINK_LIBRARIES(${lib_name}Python ${lib_name}PythonD)
TARGET_LINK_LIBRARIES(${lib_name}Python MRMLLogicPythonD)
## Python modules on Windows must have the extension ".pyd"
IF(WIN32 AND NOT CYGWIN)
SET_TARGET_PROPERTIES(${lib_name}Python PROPERTIES SUFFIX ".pyd")
ENDIF(WIN32 AND NOT CYGWIN)
INSTALL(TARGETS ${lib_name}PythonD ${lib_name}Python
RUNTIME DESTINATION ${Slicer_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${Slicer_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${Slicer_INSTALL_LIB_DIR} COMPONENT Development)
IF(VTK_WRAP_PYTHON)
vtkMacroKitPythonWrap(
KIT_NAME ${lib_name}
KIT_SRCS ${SlicerBaseLogic_SRCS}
KIT_PYTHON_LIBRARIES MRMLLogicPythonD
KIT_INSTALL_BIN_DIR ${Slicer_INSTALL_BIN_DIR}
KIT_INSTALL_LIB_DIR ${Slicer_INSTALL_LIB_DIR}
)
ENDIF(VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS)
ENDIF()
# --------------------------------------------------------------------------
# Testing (requires some of the examples)
......
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...)
#
# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for
# parsing the arguments given to that macro or function.
# It processes the arguments and defines a set of variables which hold the
# values of the respective options.
#
# The <options> argument contains all options for the respective macro,
# i.e. keywords which can be used when calling the macro without any value
# following, like e.g. the OPTIONAL keyword of the install() command.
#
# The <one_value_keywords> argument contains all keywords for this macro
# which are followed by one value, like e.g. DESTINATION keyword of the
# install() command.
#
# The <multi_value_keywords> argument contains all keywords for this macro
# which can be followed by more than one value, like e.g. the TARGETS or
# FILES keywords of the install() command.
#
# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the
# keywords listed in <options>, <one_value_keywords> and
# <multi_value_keywords> a variable composed of the given <prefix>
# followed by "_" and the name of the respective keyword.
# These variables will then hold the respective value from the argument list.
# For the <options> keywords this will be TRUE or FALSE.
#
# All remaining arguments are collected in a variable
# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see whether
# your macro was called with unrecognized parameters.
#
# As an example here a my_install() macro, which takes similar arguments as the
# real install() command:
#
# function(MY_INSTALL)
# set(options OPTIONAL FAST)
# set(oneValueArgs DESTINATION RENAME)
# set(multiValueArgs TARGETS CONFIGURATIONS)
# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
# ...
#
# Assume my_install() has been called like this:
# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub)
#
# After the cmake_parse_arguments() call the macro will have set the following
# variables:
# MY_INSTALL_OPTIONAL = TRUE
# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install()
# MY_INSTALL_DESTINATION = "bin"
# MY_INSTALL_RENAME = "" (was not used)
# MY_INSTALL_TARGETS = "foo;bar"
# MY_INSTALL_CONFIGURATIONS = "" (was not used)
# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL"
#
# You can the continue and process these variables.
#
# Keywords terminate lists of values, e.g. if directly after a one_value_keyword
# another recognized keyword follows, this is interpreted as the beginning of
# the new option.
# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in
# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would
# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor.
#=============================================================================
# Copyright 2010 Alexander Neundorf <neundorf@kde.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
if(__CMAKE_PARSE_ARGUMENTS_INCLUDED)
return()
endif()
set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE)
function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames)
# first set all result variables to empty/FALSE
foreach(arg_name ${_singleArgNames} ${_multiArgNames})
set(${prefix}_${arg_name})
endforeach(arg_name)
foreach(option ${_optionNames})
set(${prefix}_${option} FALSE)
endforeach(option)
set(${prefix}_UNPARSED_ARGUMENTS)
set(insideValues FALSE)
set(currentArgName)
# now iterate over all arguments and fill the result variables
foreach(currentArg ${ARGN})
list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword
list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword
list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword
if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1)
if(insideValues)
if("${insideValues}" STREQUAL "SINGLE")
set(${prefix}_${currentArgName} ${currentArg})
set(insideValues FALSE)
elseif("${insideValues}" STREQUAL "MULTI")
list(APPEND ${prefix}_${currentArgName} ${currentArg})
endif()
else(insideValues)
list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg})
endif(insideValues)
else()
if(NOT ${optionIndex} EQUAL -1)
set(${prefix}_${currentArg} TRUE)
set(insideValues FALSE)
elseif(NOT ${singleArgIndex} EQUAL -1)
set(currentArgName ${currentArg})
set(${prefix}_${currentArgName})
set(insideValues "SINGLE")
elseif(NOT ${multiArgIndex} EQUAL -1)
set(currentArgName ${currentArg})
set(${prefix}_${currentArgName})
set(insideValues "MULTI")
endif()
endif()
endforeach(currentArg)
# propagate the result variables to the caller:
foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames})
set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE)
endforeach(arg_name)
set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE)
endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs)
################################################################################
#
# Program: 3D Slicer
#
# Copyright (c) 2010 Kitware Inc.
#
# See Doc/copyright/copyright.txt
# or http://www.slicer.org/copyright/copyright.txt for details.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
# and was partially funded by NIH grant 3P41RR013218-12S1
#
################################################################################
# Based on VTK/CMake/KitCommonWrapBlock.cmake
MACRO(vtkMacroKitPythonWrap)
set(options)
set(oneValueArgs KIT_NAME KIT_INSTALL_BIN_DIR KIT_INSTALL_LIB_DIR)
set(multiValueArgs KIT_SRCS KIT_PYTHON_EXTRA_SRCS KIT_WRAP_HEADERS KIT_PYTHON_LIBRARIES)
cmake_parse_arguments(MY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# Sanity checks
SET(expected_defined_vars
VTK_CMAKE_DIR VTK_WRAP_PYTHON BUILD_SHARED_LIBS VTK_LIBRARIES)
FOREACH(var ${expected_defined_vars})
IF(NOT DEFINED ${var})
MESSAGE(FATAL_ERROR "error: ${var} CMake variable is not defined !")
ENDIF()
ENDFOREACH()
SET(expected_nonempty_vars MY_KIT_NAME MY_KIT_INSTALL_BIN_DIR MY_KIT_INSTALL_LIB_DIR)
FOREACH(var ${expected_nonempty_vars})
IF("${${var}}" STREQUAL "")
MESSAGE(FATAL_ERROR "error: ${var} CMake variable is empty !")
ENDIF()
ENDFOREACH()
IF(VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS)
# Tell vtkWrapPython.cmake to set VTK_PYTHON_LIBRARIES for us.
SET(VTK_WRAP_PYTHON_FIND_LIBS 1)
INCLUDE(${VTK_CMAKE_DIR}/vtkWrapPython.cmake)
SET(TMP_WRAP_FILES ${MY_KIT_SRCS} ${MY_KIT_WRAP_HEADERS})
VTK_WRAP_PYTHON3(${MY_KIT_NAME}Python KitPython_SRCS "${TMP_WRAP_FILES}")
INCLUDE_DIRECTORIES("${PYTHON_INCLUDE_PATH}")
# Create a python module that can be loaded dynamically. It links to
# the shared library containing the wrappers for this kit.
ADD_LIBRARY(${MY_KIT_NAME}PythonD ${KitPython_SRCS} ${MY_KIT_PYTHON_EXTRA_SRCS})
SET(VTK_KIT_PYTHON_LIBRARIES)
FOREACH(c ${VTK_LIBRARIES})
LIST(APPEND VTK_KIT_PYTHON_LIBRARIES ${c}PythonD)
ENDFOREACH()
TARGET_LINK_LIBRARIES(${MY_KIT_NAME}PythonD ${MY_KIT_NAME} vtkPythonCore ${VTK_PYTHON_LIBRARIES} ${VTK_KIT_PYTHON_LIBRARIES} ${MY_KIT_PYTHON_LIBRARIES})
INSTALL(TARGETS ${MY_KIT_NAME}PythonD
RUNTIME DESTINATION ${MY_KIT_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${MY_KIT_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${MY_KIT_INSTALL_LIB_DIR} COMPONENT Development
)
# Add a top-level dependency on the main kit library. This is needed
# to make sure no python source files are generated until the
# hierarchy file is built (it is built when the kit library builds)
ADD_DEPENDENCIES(${MY_KIT_NAME}PythonD ${MY_KIT_NAME})
# Add dependencies that may have been generated by VTK_WRAP_PYTHON3 to
# the python wrapper library. This is needed for the
# pre-custom-command hack in Visual Studio 6.
IF(KIT_PYTHON_DEPS)
ADD_DEPENDENCIES(${MY_KIT_NAME}PythonD ${KIT_PYTHON_DEPS})
ENDIF()
# Create a python module that can be loaded dynamically. It links to
# the shared library containing the wrappers for this kit.
ADD_LIBRARY(${MY_KIT_NAME}Python MODULE ${MY_KIT_NAME}PythonInit.cxx)
TARGET_LINK_LIBRARIES(${MY_KIT_NAME}Python ${MY_KIT_NAME}PythonD)
# Python extension modules on Windows must have the extension ".pyd"
# instead of ".dll" as of Python 2.5. Older python versions do support
# this suffix.
IF(WIN32 AND NOT CYGWIN)
SET_TARGET_PROPERTIES(${MY_KIT_NAME}Python PROPERTIES SUFFIX ".pyd")
ENDIF()
# Make sure that no prefix is set on the library
SET_TARGET_PROPERTIES(${MY_KIT_NAME}Python PROPERTIES PREFIX "")
INSTALL(TARGETS ${MY_KIT_NAME}Python
RUNTIME DESTINATION ${MY_KIT_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${MY_KIT_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${MY_KIT_INSTALL_LIB_DIR} COMPONENT Development
)
ENDIF()
ENDMACRO()
......@@ -474,6 +474,8 @@ IF(Slicer_USE_QT)
MESSAGE(FATAL_ERROR "Since both Slicer_USE_QT and Slicer_USE_PYTHONQT are ON, VTK_WRAP_PYTHON is expected to be ON. Disable Slicer_USE_PYTHONQT or re-configure VTK with python wrapping.")
ENDIF()
INCLUDE(vtkMacroKitPythonWrap)
SET(PYTHONQT_INSTALL_DIR ${CTK_PYTHONQT_INSTALL_DIR})
LINK_DIRECTORIES(${PYTHONQT_INSTALL_DIR}/lib)
INCLUDE(ctkMacroWrapPythonQt)
......
......@@ -137,37 +137,16 @@ INSTALL(TARGETS ${lib_name}
)
# --------------------------------------------------------------------------
# Create Python wrappers if VTK is wrapped in Python
#
IF(VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS)
SET(KIT_PYTHON_LIBRARIES ${VTK_LIBRARIES})
INCLUDE(${VTK_CMAKE_DIR}/vtkWrapPython.cmake)
VTK_WRAP_PYTHON3(${lib_name}Python PYTHON_SRCS "${FreeSurfer_SRCS}")
ADD_LIBRARY(${lib_name}PythonD ${PYTHON_SRCS})
ADD_LIBRARY(${lib_name}Python MODULE ${lib_name}PythonInit.cxx)
TARGET_LINK_LIBRARIES(${lib_name}PythonD ${lib_name} ${PYTHON_LIBRARIES})
FOREACH(c ${KIT_PYTHON_LIBRARIES})
TARGET_LINK_LIBRARIES(${lib_name}PythonD ${c}PythonD)
ENDFOREACH(c)
TARGET_LINK_LIBRARIES(${lib_name}Python ${lib_name}PythonD)
## Python modules on Windows must have the extension ".pyd"
IF(WIN32 AND NOT CYGWIN)
SET_TARGET_PROPERTIES(${lib_name}Python PROPERTIES SUFFIX ".pyd")
ENDIF(WIN32 AND NOT CYGWIN)
INSTALL(TARGETS ${lib_name}PythonD ${lib_name}Python
RUNTIME DESTINATION ${${lib_name}_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${${lib_name}_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${${lib_name}_INSTALL_LIB_DIR} COMPONENT Development)
ENDIF(VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS)
# Python Wrapping
# --------------------------------------------------------------------------
IF(VTK_WRAP_PYTHON)
vtkMacroKitPythonWrap(
KIT_NAME ${lib_name}
KIT_SRCS ${FreeSurfer_SRCS}
KIT_INSTALL_BIN_DIR ${${lib_name}_INSTALL_BIN_DIR}
KIT_INSTALL_LIB_DIR ${${lib_name}_INSTALL_LIB_DIR}
)
ENDIF()
# --------------------------------------------------------------------------
# Install support files
......
......@@ -308,48 +308,16 @@ INSTALL(TARGETS ${lib_name}
)
# --------------------------------------------------------------------------
# Create Python wrappers if VTK is wrapped in Python
#
IF(VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS)
SET(KIT_PYTHON_LIBRARIES ${VTK_LIBRARIES})
INCLUDE(${VTK_CMAKE_DIR}/vtkWrapPython.cmake)
VTK_WRAP_PYTHON3(${lib_name}Python PYTHON_SRCS "${MRML_SRCS}")
ADD_LIBRARY(${lib_name}PythonD ${PYTHON_SRCS})
ADD_LIBRARY(${lib_name}Python MODULE ${lib_name}PythonInit.cxx)
TARGET_LINK_LIBRARIES(${lib_name}PythonD ${lib_name} ${PYTHON_LIBRARIES})
FOREACH(c ${KIT_PYTHON_LIBRARIES})
TARGET_LINK_LIBRARIES(${lib_name}PythonD ${c}PythonD)
ENDFOREACH(c)
TARGET_LINK_LIBRARIES(${lib_name}Python ${lib_name}PythonD)
## Python modules on Windows must have the extension ".pyd"
IF(WIN32 AND NOT CYGWIN)
SET_TARGET_PROPERTIES(${lib_name}Python PROPERTIES SUFFIX ".pyd")
ENDIF(WIN32 AND NOT CYGWIN)
# Apply user-defined properties to the library target.
IF(Slicer_LIBRARY_PROPERTIES)
SET_TARGET_PROPERTIES(${lib_name}Python PROPERTIES
${Slicer_LIBRARY_PROPERTIES}
)
SET_TARGET_PROPERTIES(${lib_name}PythonD PROPERTIES
${Slicer_LIBRARY_PROPERTIES}
)
ENDIF(Slicer_LIBRARY_PROPERTIES)
INSTALL(TARGETS ${lib_name}PythonD ${lib_name}Python
RUNTIME DESTINATION ${${lib_name}_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${${lib_name}_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${${lib_name}_INSTALL_LIB_DIR} COMPONENT Development
# Python Wrapping
# --------------------------------------------------------------------------
IF(VTK_WRAP_PYTHON)
vtkMacroKitPythonWrap(
KIT_NAME ${lib_name}
KIT_SRCS ${MRML_SRCS}
KIT_INSTALL_BIN_DIR ${${lib_name}_INSTALL_BIN_DIR}
KIT_INSTALL_LIB_DIR ${${lib_name}_INSTALL_LIB_DIR}
)
ENDIF(VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS)
ENDIF()
# --------------------------------------------------------------------------
# Testing (requires some of the examples)
......
......@@ -107,7 +107,7 @@ endif (VTK_WRAP_TCL)
SET(lib_name ${PROJECT_NAME})
ADD_LIBRARY(${lib_name}
${srcs}
)
)
SET(libs
MRML
......@@ -139,45 +139,14 @@ INSTALL(TARGETS ${lib_name}
)
# --------------------------------------------------------------------------
# Create Python wrappers if VTK is wrapped in Python
#
IF(VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS)
SET(KIT_PYTHON_LIBRARIES ${VTK_LIBRARIES} MRML)
INCLUDE(${VTK_CMAKE_DIR}/vtkWrapPython.cmake)
VTK_WRAP_PYTHON3(${lib_name}Python PYTHON_SRCS "${MRMLCLI_SRCS}")
ADD_LIBRARY(${lib_name}PythonD ${PYTHON_SRCS})
ADD_LIBRARY(${lib_name}Python MODULE ${lib_name}PythonInit.cxx)
TARGET_LINK_LIBRARIES(${lib_name}PythonD ${lib_name} ${PYTHON_LIBRARIES})
FOREACH(c ${KIT_PYTHON_LIBRARIES})
TARGET_LINK_LIBRARIES(${lib_name}PythonD ${c}PythonD)
ENDFOREACH(c)
TARGET_LINK_LIBRARIES(${lib_name}Python ${lib_name}PythonD)
## Python modules on Windows must have the extension ".pyd"
IF(WIN32 AND NOT CYGWIN)
SET_TARGET_PROPERTIES(${lib_name}Python PROPERTIES SUFFIX ".pyd")
ENDIF(WIN32 AND NOT CYGWIN)
# Apply user-defined properties to the library target.
IF(Slicer_LIBRARY_PROPERTIES)
SET_TARGET_PROPERTIES(${lib_name}Python PROPERTIES
${Slicer_LIBRARY_PROPERTIES}
)
SET_TARGET_PROPERTIES(${lib_name}PythonD PROPERTIES
${Slicer_LIBRARY_PROPERTIES}
)
ENDIF(Slicer_LIBRARY_PROPERTIES)
INSTALL(TARGETS ${lib_name}PythonD ${lib_name}Python
RUNTIME DESTINATION ${${lib_name}_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${${lib_name}_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${${lib_name}_INSTALL_LIB_DIR} COMPONENT Development
# Python Wrapping
# --------------------------------------------------------------------------
IF(VTK_WRAP_PYTHON)
vtkMacroKitPythonWrap(
KIT_NAME ${lib_name}
KIT_SRCS ${MRMLCLI_SRCS}
KIT_PYTHON_LIBRARIES MRMLPythonD
KIT_INSTALL_BIN_DIR ${${lib_name}_INSTALL_BIN_DIR}
KIT_INSTALL_LIB_DIR ${${lib_name}_INSTALL_LIB_DIR}
)
ENDIF(VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS)
ENDIF()
......@@ -217,49 +217,17 @@ INSTALL(TARGETS ${lib_name}
)
# --------------------------------------------------------------------------
# Create Python wrappers if VTK is wrapped in Python
#
IF(MRMLDisplayableManager_USE_PYTHON AND VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS)
SET(KIT_PYTHON_LIBRARIES ${VTK_LIBRARIES} MRMLLogic)
INCLUDE(${VTK_CMAKE_DIR}/vtkWrapPython.cmake)
VTK_WRAP_PYTHON3(${lib_name}Python PYTHON_SRCS "${KIT_SRCS}")
ADD_LIBRARY(${lib_name}PythonD ${PYTHON_SRCS})
ADD_LIBRARY(${lib_name}Python MODULE ${lib_name}PythonInit.cxx)
TARGET_LINK_LIBRARIES(${lib_name}PythonD ${lib_name} ${PYTHON_LIBRARIES})
FOREACH(c ${KIT_PYTHON_LIBRARIES})
TARGET_LINK_LIBRARIES(${lib_name}PythonD ${c}PythonD)
ENDFOREACH(c)
TARGET_LINK_LIBRARIES(${lib_name}Python ${lib_name}PythonD)
## Python modules on Windows must have the extension ".pyd"
IF(WIN32 AND NOT CYGWIN)
SET_TARGET_PROPERTIES(${lib_name}Python PROPERTIES SUFFIX ".pyd")
ENDIF(WIN32 AND NOT CYGWIN)
# Apply user-defined properties to the library target.
IF(Slicer_LIBRARY_PROPERTIES)
SET_TARGET_PROPERTIES(${lib_name}Python PROPERTIES
${Slicer_LIBRARY_PROPERTIES}
)
SET_TARGET_PROPERTIES(${lib_name}PythonD PROPERTIES
${Slicer_LIBRARY_PROPERTIES}
)
ENDIF(Slicer_LIBRARY_PROPERTIES)
INSTALL(TARGETS ${lib_name}PythonD ${lib_name}Python
RUNTIME DESTINATION ${${lib_name}_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${${lib_name}_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${${lib_name}_INSTALL_LIB_DIR} COMPONENT Development
# Python Wrapping
# --------------------------------------------------------------------------
IF(MRMLDisplayableManager_USE_PYTHON AND VTK_WRAP_PYTHON)
vtkMacroKitPythonWrap(
KIT_NAME ${lib_name}
KIT_SRCS ${KIT_SRCS}
KIT_PYTHON_LIBRARIES MRMLLogicPythonD
KIT_INSTALL_BIN_DIR ${${lib_name}_INSTALL_BIN_DIR}
KIT_INSTALL_LIB_DIR ${${lib_name}_INSTALL_LIB_DIR}
)
ADD_SUBDIRECTORY(Python)
ENDIF()
# --------------------------------------------------------------------------
......
......@@ -159,48 +159,16 @@ INSTALL(TARGETS ${lib_name}
)
# --------------------------------------------------------------------------
# Create Python wrappers if VTK is wrapped in Python
#
IF(VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS)
SET(KIT_PYTHON_LIBRARIES ${VTK_LIBRARIES})
INCLUDE(${VTK_CMAKE_DIR}/vtkWrapPython.cmake)
VTK_WRAP_PYTHON3(${lib_name}Python PYTHON_SRCS "${MRMLLogic_SRCS}")
ADD_LIBRARY(${lib_name}PythonD ${PYTHON_SRCS})
ADD_LIBRARY(${lib_name}Python MODULE ${lib_name}PythonInit.cxx)
TARGET_LINK_LIBRARIES(${lib_name}PythonD ${lib_name} ${PYTHON_LIBRARIES})
FOREACH(c ${KIT_PYTHON_LIBRARIES})
TARGET_LINK_LIBRARIES(${lib_name}PythonD ${c}PythonD)
ENDFOREACH(c)
TARGET_LINK_LIBRARIES(${lib_name}Python ${lib_name}PythonD)
## Python modules on Windows must have the extension ".pyd"
IF(WIN32 AND NOT CYGWIN)
SET_TARGET_PROPERTIES(${lib_name}Python PROPERTIES SUFFIX ".pyd")
ENDIF(WIN32 AND NOT CYGWIN)
# Apply user-defined properties to the library target.
IF(Slicer_LIBRARY_PROPERTIES)
SET_TARGET_PROPERTIES(${lib_name}Python PROPERTIES
${Slicer_LIBRARY_PROPERTIES}
)
SET_TARGET_PROPERTIES(${lib_name}PythonD PROPERTIES
${Slicer_LIBRARY_PROPERTIES}
)
ENDIF(Slicer_LIBRARY_PROPERTIES)
INSTALL(TARGETS ${lib_name}PythonD ${lib_name}Python
RUNTIME DESTINATION ${${lib_name}_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${${lib_name}_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${${lib_name}_INSTALL_LIB_DIR} COMPONENT Development
# Python Wrapping
# --------------------------------------------------------------------------
IF(VTK_WRAP_PYTHON)
vtkMacroKitPythonWrap(
KIT_NAME ${lib_name}
KIT_SRCS ${MRMLLogic_SRCS}
KIT_INSTALL_BIN_DIR ${${lib_name}_INSTALL_BIN_DIR}
KIT_INSTALL_LIB_DIR ${${lib_name}_INSTALL_LIB_DIR}
)
ENDIF(VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS)
ENDIF()
# --------------------------------------------------------------------------
# Testing
......
......@@ -125,14 +125,10 @@ IF (VTK_WRAP_TCL)
ENDIF (VTK_WRAP_TCL)
add_library(${lib_name} ${srcs})
SET(VTK_LIBRARIES
MRML
)
SET(libs
${SLICERLIBCURL_LIBRARIES}
${VTK_LIBRARIES}
MRML
)
target_link_libraries(${lib_name} ${libs})
......@@ -158,48 +154,17 @@ INSTALL(TARGETS ${lib_name}
)
# --------------------------------------------------------------------------
# Create Python wrappers if VTK is wrapped in Python
#
IF(VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS)
SET(KIT_PYTHON_LIBRARIES ${VTK_LIBRARIES})
INCLUDE(${VTK_CMAKE_DIR}/vtkWrapPython.cmake)
VTK_WRAP_PYTHON3(${lib_name}Python PYTHON_SRCS "${RemoteIO_SRCS}")
ADD_LIBRARY(${lib_name}PythonD ${PYTHON_SRCS})
ADD_LIBRARY(${lib_name}Python MODULE ${lib_name}PythonInit.cxx)
TARGET_LINK_LIBRARIES(${lib_name}PythonD ${lib_name} ${PYTHON_LIBRARIES})
FOREACH(c ${KIT_PYTHON_LIBRARIES})
TARGET_LINK_LIBRARIES(${lib_name}PythonD ${c}PythonD)
ENDFOREACH(c)
TARGET_LINK_LIBRARIES(${lib_name}Python ${lib_name}PythonD)
## Python modules on Windows must have the extension ".pyd"
IF(WIN32 AND NOT CYGWIN)
SET_TARGET_PROPERTIES(${lib_name}Python PROPERTIES SUFFIX ".pyd")
ENDIF(WIN32 AND NOT CYGWIN)
# Apply user-defined properties to the library target.
IF(Slicer_LIBRARY_PROPERTIES)
SET_TARGET_PROPERTIES(${lib_name}Python PROPERTIES
${Slicer_LIBRARY_PROPERTIES}
)
SET_TARGET_PROPERTIES(${lib_name}PythonD PROPERTIES
${Slicer_LIBRARY_PROPERTIES}
)
ENDIF(Slicer_LIBRARY_PROPERTIES)
INSTALL(TARGETS ${lib_name}PythonD ${lib_name}Python
RUNTIME DESTINATION ${${lib_name}_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${${lib_name}_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${${lib_name}_INSTALL_LIB_DIR} COMPONENT Development
# Python Wrapping
# --------------------------------------------------------------------------
IF(VTK_WRAP_PYTHON)
vtkMacroKitPythonWrap(
KIT_NAME ${lib_name}
KIT_SRCS ${RemoteIO_SRCS}
KIT_PYTHON_LIBRARIES MRMLPythonD
KIT_INSTALL_BIN_DIR ${${lib_name}_INSTALL_BIN_DIR}
KIT_INSTALL_LIB_DIR ${${lib_name}_INSTALL_LIB_DIR}
)
ENDIF(VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS)
ENDIF()
# --------------------------------------------------------------------------
# Testing (requires some of the examples)
......
......@@ -188,54 +188,16 @@ install(TARGETS ${lib_name}
)
# --------------------------------------------------------------------------
# Create Python wrappers if VTK is wrapped in Python
#
SET(VTK_LIBRARIES
vtkImaging
vtkFiltering
vtkCommon
)
IF(VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS)
SET(KIT_PYTHON_LIBRARIES ${VTK_LIBRARIES})
INCLUDE(${VTK_CMAKE_DIR}/vtkWrapPython.cmake)
VTK_WRAP_PYTHON3(${lib_name}Python PYTHON_SRCS "${vtkITK_SRCS}")
ADD_LIBRARY(${lib_name}PythonD ${PYTHON_SRCS})
ADD_LIBRARY(${lib_name}Python MODULE ${lib_name}PythonInit.cxx)
TARGET_LINK_LIBRARIES(${lib_name}PythonD ${lib_name} ${PYTHON_LIBRARIES})
FOREACH(c ${KIT_PYTHON_LIBRARIES})
TARGET_LINK_LIBRARIES(${lib_name}PythonD ${c}PythonD ${c})
ENDFOREACH(c)
TARGET_LINK_LIBRARIES(${lib_name}Python ${lib_name}PythonD ${lib_name})
## Python modules on Windows must have the extension ".pyd"
IF(WIN32 AND NOT CYGWIN)
SET_TARGET_PROPERTIES(${lib_name}Python PROPERTIES SUFFIX ".pyd")
ENDIF(WIN32 AND NOT CYGWIN)
# Apply user-defined properties to the library target.
IF(Slicer_LIBRARY_PROPERTIES)
SET_TARGET_PROPERTIES(${lib_name}Python PROPERTIES
${Slicer_LIBRARY_PROPERTIES}
)
SET_TARGET_PROPERTIES(${lib_name}PythonD PROPERTIES
${Slicer_LIBRARY_PROPERTIES}
)
ENDIF(Slicer_LIBRARY_PROPERTIES)
INSTALL(TARGETS ${lib_name}PythonD ${lib_name}Python
RUNTIME DESTINATION ${${lib_name}_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${${lib_name}_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${${lib_name}_INSTALL_LIB_DIR} COMPONENT Development
# Python Wrapping
# --------------------------------------------------------------------------
IF(VTK_WRAP_PYTHON)
vtkMacroKitPythonWrap(
KIT_NAME ${lib_name}
KIT_SRCS ${vtkITK_SRCS}
KIT_INSTALL_BIN_DIR ${${lib_name}_INSTALL_BIN_DIR}
KIT_INSTALL_LIB_DIR ${${lib_name}_INSTALL_LIB_DIR}
)
ENDIF(VTK_WRAP_PYTHON AND BUILD_SHARED_LIBS)