]> Creatis software - gdcm.git/blobdiff - gdcmPython/CMakeLists.txt
STYLE: No DOS file, please
[gdcm.git] / gdcmPython / CMakeLists.txt
index 388454149792bb407645e96deaba6b94a4442e0b..4c9ebd0e7bf3d955948c3fd988ab8ef37ec44257 100644 (file)
@@ -22,7 +22,16 @@ IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
 
   #SET_SOURCE_FILES_PROPERTIES(gdcm.i PROPERTIES PYTHON ON)
   SET_SOURCE_FILES_PROPERTIES(gdcm.i PROPERTIES CPLUSPLUS ON)
-  SET_SOURCE_FILES_PROPERTIES(gdcm.i PROPERTIES SWIG_FLAGS "-includeall")
+  # Setting SWIG_FLAGS to "-includeall" at the following line looks like
+  # a bad idea since swig tries to reculsively 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})
   
@@ -30,6 +39,18 @@ IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
   #MESSAGE(FATAL_ERROR ${swig_generated_file_fullname})
   #MESSAGE(FATAL_ERROR ${swig_source_file_fullname})
 
+  # Swig creates a gdcm.py file put it in the right place, if only cmake
+  # was able to do stuff properly ...
+  ADD_CUSTOM_TARGET( CMAKE_S____ ALL)
+  ADD_CUSTOM_COMMAND(
+    TARGET CMAKE_S____
+    POST_BUILD
+    COMMAND ${CMAKE_COMMAND}
+    ARGS -E copy 
+      ${GDCM_BINARY_DIR}/gdcmPython/gdcm.py
+      ${GDCM_BINARY_DIR}/bin/gdcm.py
+  )
+
 ELSE(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)   
 
   # As of 09/10/2003 there was no FindSWIG.cmake
@@ -75,7 +96,7 @@ ELSE(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
   # Then create the gdcm.py = gdcmVersion.py + gdcm.py (swig) file:
   FILE(WRITE ${GDCM_BINARY_DIR}/bin/gdcmVersion.py
     "import os\n"
-    "gdcmVERSION=\"${GDCM_VERSION_FULL}\"\n"
+    "gdcmVERSION=\"${GDCM_VERSION}\"\n"
     "GDCM_DATA_PATH=\"${GDCM_DATA_ROOT}\"\n\n"
     ${SWIG_GDCM_PY}
     )
@@ -172,7 +193,8 @@ IF(GDCM_VTK)
                            vtkCommonPython
                            vtkIOPython)
   ENDIF (GDCM_WRAP_PYTHON)
-  
+ENDIF(GDCM_VTK)
+
   # generate a setup.py according to VTK installation 
   # put it in subdir in order to not override old one
   
@@ -181,7 +203,6 @@ IF(GDCM_VTK)
       ${GDCM_SOURCE_DIR}/gdcmPython/setup.py.in
       ${GDCM_BINARY_DIR}/setup.py
   )
-ENDIF(GDCM_VTK)
 
 #-----------------------------------------------------------------------------
 # Install stuff: