2 # http://www.cmake.org/pipermail/cmake/2003-August/004185.html
3 # http://www.cmake.org/pipermail/cmake/2003-January/001092.html
11 #-----------------------------------------------------------------------------
12 # Create the gdcmVersion.py file:
13 FILE(WRITE ${GDCM_BINARY_DIR}/gdcmVersion.py
14 "gdcmVERSION=\"${GDCM_VERSION_FULL}\""
17 #-----------------------------------------------------------------------------
21 # CMake 2.0 will fully support Swig wrapping so split based on cmake version:
23 IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
25 FIND_PACKAGE(SWIG REQUIRED)
26 INCLUDE(${SWIG_USE_FILE})
28 #INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
30 #SET(CMAKE_SWIG_FLAGS "")
32 SET_SOURCE_FILES_PROPERTIES(gdcm.i PROPERTIES CPLUSPLUS ON)
33 SET_SOURCE_FILES_PROPERTIES(gdcm.i PROPERTIES SWIG_FLAGS "-includeall")
34 SWIG_ADD_MODULE(gdcm python
36 SWIG_LINK_LIBRARIES(gdcm ${PYTHON_LIBRARIES})
37 TARGET_LINK_LIBRARIES(_gdcm gdcm)
39 ELSE(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
41 ADD_LIBRARY(pygdcm gdcm_wrap.cxx)
43 # As of 09/10/2003 there was no FindSWIG.cmake
44 # later we should use SWIG instead of swig
45 # Build our custom command :
49 ARGS -python -c++ -I${GDCM_SOURCE_DIR}/src -o
50 ${GDCM_BINARY_DIR}/gdcmPython/gdcm_wrap.cxx
51 ${GDCM_SOURCE_DIR}/gdcmPython/gdcm.i
52 SOURCE ${GDCM_SOURCE_DIR}/gdcmPython/gdcm.i
53 OUTPUTS ${GDCM_BINARY_DIR}/gdcmPython/gdcm_wrap.cxx
54 COMMENT "Generating gdcm_wrap.cxx/gdcm.py based on gdcm.i"
56 # This swig command will also outputs gdcm.py :
57 SET_SOURCE_FILES_PROPERTIES(gdcm.py GENERATED)
58 # Since the file gdcm_wrap.cxx does not exist, mark it as GENERATED:
59 SET_SOURCE_FILES_PROPERTIES(gdcm_wrap.cxx GENERATED)
61 TARGET_LINK_LIBRARIES(pygdcm
65 # http://www.cmake.org/pipermail/cmake/2003-August/004190.html
66 # SET_TARGET_PROPERTIES(pygdcm PROPERTIES PREFIX "_")
68 ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.9)
71 #-----------------------------------------------------------------------------
76 ${GDCM_SOURCE_DIR}/vtk
79 SET(vtkgdcmPython_la_SOURCES
80 ${GDCM_SOURCE_DIR}/vtk/vtkGdcmReader.cxx
82 SET_SOURCE_FILES_PROPERTIES(vtkGdcmReaderPython.cxx GENERATED)
84 # Configure Python module, which is the plugin itself
86 VTK_WRAP_PYTHON2(vtkgdcmPython gdcmfoo
87 ${vtkgdcmPython_la_SOURCES})
88 # The C++ files must be made into a C++ library
89 ADD_LIBRARY(vtkgdcmPython SHARED ${gdcmfoo})
90 # set the libraries to link against
91 TARGET_LINK_LIBRARIES (vtkgdcmPython
96 ENDIF (GDCM_WRAP_PYTHON)
98 #generate a setup.py according to VTK installation
99 #put it in subdir in order to not override old one
100 # as it is a pain...override existing file...
102 GET_FILENAME_COMPONENT(VTKPATH ${VTK_DIR}/../../ ABSOLUTE)
104 ${GDCM_SOURCE_DIR}/gdcmPython/setup.py.in
105 ${GDCM_BINARY_DIR}/setup.py
107 #MESSAGE(STATUS ${VTKPATH})
110 #-----------------------------------------------------------------------------
113 #Should install in path of PYTHON_LIBRARY and not the default CMAKE_INSTALL_PREFIX
115 GET_FILENAME_COMPONENT(PYTHON_LIB_INSTALL ${PYTHON_LIBRARY} PATH)
116 GET_FILENAME_COMPONENT(SITEPACKAGE
117 ${PYTHON_LIB_INSTALL}/../site-packages ABSOLUTE)
118 #MESSAGE(STATUS ${SITEPACKAGE})
119 #INSTALL_FILES(/include "\\.h$")
120 #INSTALL_TARGETS(/lib/ gdcm)
122 # gdcm.py is a file generated by swig
123 # then from python you can do import gdcm, and it will load _gdcm.so
124 #INSTALL_TARGETS(/lib/ gdcm.py)
125 #INSTALL_PROGRAMS(/lib/ gdcm.py)
126 #INSTALL_FILES(/lib/ .py gdcm.py)
128 # When installing swig-generated python module one should pay attention
129 # to library naming convention, see here for more detail:
130 # http://www.swig.org/Doc1.3/Python.html#n6
131 # even with the $swig -module mylib, there is always a trailing underscore added