summaryrefslogtreecommitdiff
path: root/libkolabxml/lib/python/CMakeLists.txt
blob: 397405cb3aa09ecc396b6d5e33f9946ab86a3d7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#Generate Python wrapper
include_directories(../)

set(KOLAB_SWIG_PYTHON_SOURCE_FILE python_kolabformat_wrapper.cpp)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${KOLAB_SWIG_PYTHON_SOURCE_FILE}
    COMMAND ${SWIG} -v -c++ -python -o ${CMAKE_CURRENT_BINARY_DIR}/${KOLAB_SWIG_PYTHON_SOURCE_FILE} ../kolabformat.i
    COMMENT "Generating python bindings"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    DEPENDS ../kolabformat.i kolabxml
    VERBATIM
    )

SET_SOURCE_FILES_PROPERTIES(${KOLAB_SWIG_PYTHON_SOURCE_FILE} PROPERTIES GENERATED 1)
ADD_CUSTOM_TARGET(generate_python_bindings ALL DEPENDS ${KOLAB_SWIG_PYTHON_SOURCE_FILE})

#Compile Python Bindings
find_package(PythonLibs)
include_directories(${PYTHON_INCLUDE_DIRS})

# python_add_module(kolabformat ${KOLAB_SWIG_PYTHON_SOURCE_FILE})

add_library(pythonbindings SHARED ${KOLAB_SWIG_PYTHON_SOURCE_FILE})
target_link_libraries(pythonbindings kolabxml ${PYTHON_LIBRARY})
SET_TARGET_PROPERTIES(pythonbindings PROPERTIES OUTPUT_NAME "_kolabformat")
SET_TARGET_PROPERTIES(pythonbindings PROPERTIES PREFIX "")

configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)

install(TARGETS pythonbindings LIBRARY DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/pythonbindings)

install( FILES
  ${CMAKE_CURRENT_BINARY_DIR}/kolabformat.py
  test.py
  DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/pythonbindings)