1 # gdcm Python wrapping stuff:
9 #-----------------------------------------------------------------------------
13 # CMake 2.0 will fully support Swig wrapping so split based on cmake version:
15 # We need to pass that to swig to be sure all modules are generated in the proper dir
16 SET(CMAKE_SWIG_FLAGS "-outdir ${GDCM_BINARY_DIR}/gdcmPython")
17 # Looks like a bug to me in cmake 2.0.x:
18 SEPARATE_ARGUMENTS(CMAKE_SWIG_FLAGS)
20 FIND_PACKAGE(SWIG REQUIRED)
22 INCLUDE(${SWIG_USE_FILE})
26 SET_SOURCE_FILES_PROPERTIES(gdcm.i PROPERTIES CPLUSPLUS ON)
27 SWIG_ADD_MODULE(gdcm python gdcm.i) #gdcm_wrap.cxx, or gdcmPYTHON_wrap.cxx
28 SWIG_LINK_LIBRARIES(gdcm gdcm ${PYTHON_LIBRARIES})
30 # Get rid of -Wall / -W / -pedantic if exist
31 SET(CMAKE_CXX_FLAGS "")
32 # I guess I need to put them back on this file:
33 SET_SOURCE_FILES_PROPERTIES(
34 ${swig_generated_file_fullname}
35 PROPERTIES COMPILE_FLAGS "")
37 INSTALL_TARGETS(/lib/gdcm/ _gdcm)
39 #-----------------------------------------------------------------------------
43 # Include the VTK library
44 INCLUDE(${VTK_USE_FILE})
47 ${GDCM_SOURCE_DIR}/vtk
50 SET(vtkgdcmPython_la_SOURCES
51 ${GDCM_SOURCE_DIR}/vtk/vtkGdcmReader.cxx
52 ${GDCM_SOURCE_DIR}/vtk/vtkGdcmWriter.cxx
54 SET_SOURCE_FILES_PROPERTIES(vtkGdcmReaderPython.cxx GENERATED)
56 # Configure Python module, which is the plugin itself
58 IF(NOT VTK_WRAP_PYTHON)
59 MESSAGE(FATAL_ERROR "Can't build gdcm python wrapping if VTK_WRAP_PYTHON is OFF" )
60 ENDIF(NOT VTK_WRAP_PYTHON)
61 VTK_WRAP_PYTHON2(vtkgdcmPython gdcmWrapSOURCES
62 ${vtkgdcmPython_la_SOURCES})
63 # The C++ files must be made into a C++ library
64 ADD_LIBRARY(vtkgdcmPython SHARED ${gdcmWrapSOURCES}) #MODULE on apple ?
65 # set the libraries to link against
66 #SET_TARGET_PROPERTIES(${foobar} PROPERTIES PREFIX "")
68 #GET_TARGET_PROPERTY(swig_gdcm_fullpath "${SWIG_MODULE_gdcm_REAL_NAME}" LOCATION)
69 TARGET_LINK_LIBRARIES (vtkgdcmPython
73 INSTALL_TARGETS(/lib/gdcm/ vtkgdcmPython)
75 ENDIF (GDCM_WRAP_PYTHON)
78 # generate a setup.py according to VTK installation
79 # put it in subdir in order to not override old one
81 #GET_FILENAME_COMPONENT(VTKPATH ${VTK_DIR}/../../ ABSOLUTE)
83 # ${GDCM_SOURCE_DIR}/gdcmPython/setup.py.in
84 # ${GDCM_BINARY_DIR}/setup.py
87 #-----------------------------------------------------------------------------
88 # Python package configuration
89 FILE(WRITE ${GDCM_BINARY_DIR}/gdcmPython/gdcmVersion.py
90 "gdcmVERSION=\"${GDCM_VERSION}\"\n"
93 FILE(WRITE ${GDCM_BINARY_DIR}/gdcmPython/__init__.py
94 "__all__ = [\"core\",\n"
99 FILE(WRITE ${GDCM_BINARY_DIR}/gdcmPython/core.py
100 "from gdcmVersion import *\n"
102 "GDCM_DATA_ROOT = \"${GDCM_DATA_ROOT}\"\n"
106 FILE(WRITE ${GDCM_BINARY_DIR}/gdcmPython/vtk.py
108 "from gdcmVersion import *\n"
109 "if os.name == 'posix':\n"
110 " from libvtkgdcmPython import *\n"
112 " from vtkgdcmPython import *\n"
113 "GDCM_DATA_ROOT = \"${GDCM_DATA_ROOT}\"\n"
117 #-----------------------------------------------------------------------------
118 # Python installation
120 FILE(WRITE ${GDCM_BINARY_DIR}/gdcmPython/gdcmPython.pth
121 "${GDCM_BINARY_DIR}\n"
122 "${GDCM_BINARY_DIR}/bin/release\n"
125 FILE(WRITE ${GDCM_BINARY_DIR}/gdcmPython/gdcmPython.pth
126 "${CMAKE_INSTALL_PREFIX}/lib/gdcm\n"
129 FIND_PATH(PYTHON_INSTALL "site-packages"
130 [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath]
131 [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]
132 [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.2\\InstallPath]
133 [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.1\\InstallPath]
134 [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.0\\InstallPath]
135 [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.6\\InstallPath]
136 [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.5\\InstallPath]
145 STRING(REGEX REPLACE "/usr(.*)/config.*" "\\1" PYTHON_INSTALL ${PYTHON_LIBRARY})
147 INSTALL_FILES(${PYTHON_INSTALL}/site-packages "\\.pth$")
148 INSTALL_FILES(/lib/gdcm/gdcmPython "\\.py$")
149 INSTALL_FILES(/lib/gdcm/gdcmPython FILES "gdcm.py")
151 #-----------------------------------------------------------------------------
152 # Add test from demo subdir: