+#-----------------------------------------------------------------------------
+# SWIG Wrapping
+#
+
+# CMake 2.0 will fully support Swig wrapping so split based on cmake version:
+
+IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
+
+ # We need to pass that to swig to be sure all modules are generated in the proper dir
+ SET(CMAKE_SWIG_FLAGS "-outdir ${GDCM_BINARY_DIR}/gdcmPython")
+ # Looks like a bug to me in cmake 2.0.x:
+ SEPARATE_ARGUMENTS(CMAKE_SWIG_FLAGS)
+
+ FIND_PACKAGE(SWIG REQUIRED)
+ INCLUDE(${SWIG_USE_FILE})
+
+ #SET_SOURCE_FILES_PROPERTIES(gdcm.i PROPERTIES PYTHON ON)
+ SET_SOURCE_FILES_PROPERTIES(gdcm.i PROPERTIES CPLUSPLUS ON)
+ # Setting SWIG_FLAGS to "-includeall" at the following line looks like
+ # a bad idea since swig tries to recursively include all the referenced
+ # files, "including" the C++ <sstream>, <list>, <map>... Of course swig
+ # has no way of finding the path to those files (unless it is told by
+ # cmake) since they are related to the compiler installation layout.
+ # Anyhow, since this inclusion recursion is not necessary, just don't
+ # do it.
+ # Note: apparently the line is required in order to avoid a NOTFOUND
+ # as argument of swig on invocation of make.
+ SET_SOURCE_FILES_PROPERTIES(gdcm.i PROPERTIES SWIG_FLAGS "")
+ SWIG_ADD_MODULE(gdcm python gdcm.i) #gdcm_wrap.cxx
+ SWIG_LINK_LIBRARIES(gdcm gdcm ${PYTHON_LIBRARIES})
+
+ SET(GDCM_CXX_FLAGS ${CMAKE_SWIG_FLAGS})
+ # Get rid of -Wall / -W / -pedantic if exist
+ SET(CMAKE_CXX_FLAGS "")
+ # I guess I need to put them back on the this file:
+ SET_SOURCE_FILES_PROPERTIES(${GDCM_BINARY_DIR}/gdcmPython/gdcm_wrap.cxx
+ PROPERTIES COMPILE_FLAGS "")
+# SET_TARGET_PROPERTIES(${GDCM_BINARY_DIR}/gdcmPython/gdcm_wrap.cxx
+# PROPERTIES CMAKE_CXX_FLAGS "-foo")
+
+ELSE(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)