summaryrefslogtreecommitdiff
path: root/src/python/CMakeLists.txt
blob: 7f0cdd195ce6dd8700cd9c03929301539f4dd6c6 (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
35
36
37
38
39
# 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)

if (KOLAB_PYTHON_INSTALL_DIR)
    set(PYTHON_INSTALL_DIR ${KOLAB_PYTHON_INSTALL_DIR})
else (KOLAB_PYTHON_INSTALL_DIR)
    set(PYTHON_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/pythonbindings)
endif (KOLAB_PYTHON_INSTALL_DIR)

install(TARGETS pythonbindings LIBRARY DESTINATION ${PYTHON_INSTALL_DIR})

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