-#Should install in path of PYTHON_LIBRARY and not the default CMAKE_INSTALL_PREFIX
-
-GET_FILENAME_COMPONENT(PYTHON_LIB_INSTALL ${PYTHON_LIBRARY} PATH)
-GET_FILENAME_COMPONENT(SITEPACKAGE
- ${PYTHON_LIB_INSTALL}/../site-packages ABSOLUTE)
-#MESSAGE(STATUS ${SITEPACKAGE})
-#INSTALL_FILES(/include "\\.h$")
-#INSTALL_TARGETS(/lib/ gdcm)
-
-# gdcm.py is a file generated by swig
-# then from python you can do import gdcm, and it will load _gdcm.so
-#INSTALL_TARGETS(/lib/ gdcm.py)
-#INSTALL_PROGRAMS(/lib/ gdcm.py)
-#INSTALL_FILES(/lib/ .py gdcm.py)
-
-# When installing swig-generated python module one should pay attention
-# to library naming convention, see here for more detail:
-# http://www.swig.org/Doc1.3/Python.html#n6
-# even with the $swig -module mylib, there is always a trailing underscore added
+# Cmake cannot handle installing since python wants stuff to be installed
+# in /usr/lib/pythonx.x/site-package and not a a std /usr/lib
+# Thus generate a setup.py file using distutils
+
+# Create a gdcm.pth file:
+
+FILE(WRITE ${GDCM_BINARY_DIR}/gdcmPython/gdcm.pth
+ "gdcmPython\n"
+ )
+
+FILE(WRITE ${GDCM_BINARY_DIR}/gdcmPython/__init__.py
+ "import gdcm\n"
+ )
+
+IF(GDCM_VTK)
+ FILE(APPEND ${GDCM_BINARY_DIR}/gdcmPython/__init__.py
+ "import os\n"
+ "if os.name == 'posix':\n"
+ " from libvtkgdcmPython import *\n"
+ "else:\n"
+ " from vtkgdcmPython import *\n"
+ )
+ENDIF(GDCM_VTK)
+
+#-----------------------------------------------------------------------------
+# Add test from demo subdir:
+
+SUBDIRS(demo)