]> Creatis software - gdcm.git/blobdiff - gdcmPython/CMakeLists.txt
FileHelper has CallProgressMethod and others
[gdcm.git] / gdcmPython / CMakeLists.txt
index 9581048645b7eb5fbe33a89a3c34b0901ed01338..8f1623a413140f696bc4c982ca013b8bc7a607a0 100644 (file)
@@ -2,6 +2,7 @@
 
 INCLUDE_DIRECTORIES(
   ${GDCM_SOURCE_DIR}/src
+  ${GDCM_SOURCE_DIR}/gdcmPython
   ${PYTHON_INCLUDE_PATH}
   ${GDCM_BINARY_DIR}/
 )
@@ -13,36 +14,30 @@ INCLUDE_DIRECTORIES(
 # CMake 2.0 will fully support Swig wrapping so split based on cmake version:
 
 # 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")
+SET(CMAKE_SWIG_FLAGS "-outdir \"${GDCM_BINARY_DIR}/gdcmPython\"")
+#SET(CMAKE_SWIG_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})
+IF(SWIG_FOUND)
+  INCLUDE(${SWIG_USE_FILE})
+ENDIF(SWIG_FOUND)
+
 
 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.
+# BUG: This is only needed with cmake <= 2.0.5
 SET_SOURCE_FILES_PROPERTIES(gdcm.i PROPERTIES SWIG_FLAGS "")
-SWIG_ADD_MODULE(gdcm python gdcm.i)  #gdcm_wrap.cxx
+# END OF BUG
+SWIG_ADD_MODULE(gdcm python gdcm.i)  #gdcm_wrap.cxx, or gdcmPYTHON_wrap.cxx
 SWIG_LINK_LIBRARIES(gdcm gdcm ${PYTHON_LIBRARIES})
 
 # 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 "")
-ADD_DEPENDENCIES(
-  ${GDCM_BINARY_DIR}/gdcmPython/gdcm_wrap.cxx
-  ${GDCM_SOURCE_DIR}/gdcmConfigure.h
-  )
+SET(CMAKE_CXX_FLAGS "")
+# I guess I need to put them back on this file:
+#SET_SOURCE_FILES_PROPERTIES(
+#  ${swig_generated_file_fullname}
+#  PROPERTIES COMPILE_FLAGS "")
 
 INSTALL_TARGETS(/lib/gdcm/ _gdcm)
 
@@ -136,27 +131,29 @@ ELSE(WIN32)
        "${CMAKE_INSTALL_PREFIX}/lib/gdcm\n"
   )
 ENDIF(WIN32)
-FIND_PATH(PYTHON_INSTALL "site-packages"
-    [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath]
-    [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]
-    [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.2\\InstallPath]
-    [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.1\\InstallPath]
-    [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.0\\InstallPath]
-    [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.6\\InstallPath]
-    [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.5\\InstallPath]
-    /usr/lib/python2.4
-    /usr/lib/python2.3
-    /usr/lib/python2.2
-    /usr/lib/python2.1
-    /usr/lib/python2.0
-    /usr/lib/python1.6
-    /usr/lib/python1.5
-)
-STRING(REGEX REPLACE "/usr(.*)/config.*" "\\1" PYTHON_INSTALL ${PYTHON_LIBRARY})
 
-INSTALL_FILES(${PYTHON_INSTALL}/site-packages "\\.pth$")
-INSTALL_FILES(/lib/gdcm/gdcmPython "\\.py$")
-INSTALL_FILES(/lib/gdcm/gdcmPython FILES "gdcm.py")
+# Install a python path file in site-packages that tells
+# python where to find the gdcmPython module
+IF(UNIX)
+  FIND_PATH(PYTHON_DIR "site-packages"
+     /usr/lib/python2.4
+     /usr/lib/python2.3
+     /usr/lib/python2.2
+     /usr/lib/python2.1
+  ) 
+  STRING(REGEX REPLACE "/usr" "" PYTHON_DIR ${PYTHON_DIR})
+
+  INSTALL_FILES(${PYTHON_DIR}/site-packages FILES 
+    "${GDCM_BINARY_DIR}/gdcmPython/gdcmPython.pth"
+  )
+  INSTALL_FILES(/lib/gdcm/gdcmPython FILES 
+    "gdcm.py" 
+    "__init__.py" 
+    "gdcmVersion.py" 
+    "core.py" 
+    "vtk.py"
+  )
+ENDIF(UNIX)
 
 #-----------------------------------------------------------------------------
 # Add test from demo subdir: