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