]> Creatis software - gdcm.git/blob - gdcmPython/CMakeLists.txt
*FIX: Some compilation problem on SunOS with no ANSI STRING STREAM
[gdcm.git] / gdcmPython / CMakeLists.txt
1 #IF(GDCM_WRAP_PYTHON)
2 #If we reach this dir we have selected this option
3
4 # TODO
5 # http://www.cmake.org/pipermail/cmake/2003-August/004185.html
6 # http://www.cmake.org/pipermail/cmake/2003-January/001092.html
7
8 INCLUDE_DIRECTORIES(
9   ${GDCM_SOURCE_DIR}/src
10   ${PYTHON_INCLUDE_PATH}
11 )
12
13 SET(GDCM_INC
14   ${GDCM_SOURCE_DIR}/src
15 )
16
17 SET(SWIG_INC
18   ${PYTHON_INCLUDES}
19   ${GDCM_INC}
20 )
21
22 #ADD_CUSTOM_TARGET(mathieu ALL)
23
24 SET(GDCM_PYTHON_SOURCES
25   gdcm_wrap.cxx
26 )
27
28 SET_SOURCE_FILES_PROPERTIES(gdcm_wrap.cxx GENERATED)
29
30 ADD_LIBRARY(pygdcm ${GDCM_PYTHON_SOURCES})
31 # http://www.cmake.org/pipermail/cmake/2003-August/004190.html
32 # SET_TARGET_PROPERTIES(pygdcm PROPERTIES PREFIX "_")
33 TARGET_LINK_LIBRARIES(pygdcm 
34   ${PYTHON_LIBRARY}
35   gdcm
36 )
37
38 #-----------------------------------------------------------------------------
39 # As of 09/10/2003 there was no FindSWIG.cmake
40 # later we should use SWIG instead of swig
41 # Build our custom command :
42 ADD_CUSTOM_COMMAND(
43   SOURCE    ${GDCM_SOURCE_DIR}/gdcmPython/gdcm.i
44   COMMAND   swig
45   ARGS      -python -c++ -I${GDCM_SOURCE_DIR}/src -o 
46             ${GDCM_BINARY_DIR}/gdcmPython/gdcm_wrap.cxx 
47             ${GDCM_SOURCE_DIR}/gdcmPython/gdcm.i 
48   TARGET    pygdcm
49   OUTPUTS   ${GDCM_BINARY_DIR}/gdcmPython/gdcm_wrap.cxx
50   COMMENT   "Generating gdcm_wrap.cxx based on gdcm.i"
51 )
52
53 IF(GDCM_VTK)
54   INCLUDE_DIRECTORIES(
55     ${GDCM_SOURCE_DIR}/vtk
56   )
57
58   SET(vtkgdcmPython_la_SOURCES
59       ${GDCM_SOURCE_DIR}/vtk/vtkGdcmReader.cxx
60   )
61   SET_SOURCE_FILES_PROPERTIES(vtkGdcmReaderPython.cxx GENERATED)
62   
63   # Configure Python module, which is the plugin itself
64   IF (GDCM_WRAP_PYTHON)
65     VTK_WRAP_PYTHON2(vtkgdcmPython gdcmfoo
66                    ${vtkgdcmPython_la_SOURCES})
67     # The C++ files must be made into a C++ library
68     ADD_LIBRARY(vtkgdcmPython SHARED ${gdcmfoo})
69     # set the libraries to link against
70     TARGET_LINK_LIBRARIES (vtkgdcmPython
71                          pygdcm
72                          vtkgdcm
73                          vtkCommonPython
74                          vtkIOPython)
75   ENDIF (GDCM_WRAP_PYTHON)
76   
77   #generate a setup.py according to VTK installation 
78   #put it in subdir in order to not override old one
79   # as it is a pain...override existing file...
80   
81   GET_FILENAME_COMPONENT(VTKPATH ${VTK_DIR}/../../ ABSOLUTE)
82   CONFIGURE_FILE(
83       ${GDCM_SOURCE_DIR}/gdcmPython/setup.py.in
84       ${GDCM_SOURCE_DIR}/setup.py
85   )
86
87 ENDIF(GDCM_VTK)
88
89 #I should install in path of PYTHON_LIBRARY
90 #GET_FILENAME_COMPONENT(PYTHON_LIB_INSTALL ${PYTHON_LIBRARY} PATH)
91 #GET_FILENAME_COMPONENT(SITEPACKAGE ${PYTHON_LIB_INSTALL}/../site-packages ABSOLUTE)
92 #MESSAGE(STATUS ${SITEPACKAGE})
93 #INSTALL_FILES(/include "\\.h$")
94 #INSTALL_TARGETS(/lib/ gdcm)
95
96 INSTALL_TARGETS(/lib/ "gdcm.py")
97
98 # When installing swig-generated python module one should pay attention
99 # to library naming convention, see here for more detail:
100 # http://www.swig.org/Doc1.3/Python.html#n6
101 # even with the $swig -module mylib, there is always a trailing underscore added