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