From b4e9659ae72be31fb4b345efeaf0f66607ed73fa Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 4 Aug 2009 14:18:00 +0200 Subject: binding: Added python bindings support using swig. --- bindings/python/CMakeLists.txt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 bindings/python/CMakeLists.txt (limited to 'bindings/python') diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt new file mode 100644 index 00000000..4d410339 --- /dev/null +++ b/bindings/python/CMakeLists.txt @@ -0,0 +1,26 @@ +project(libssh-python CXX) + +set(SWIG_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ssh_python.cpp") + +find_package(PythonInterp REQUIRED) +execute_process( + COMMAND + ${PYTHON_EXECUTABLE} -c "from sys import stdout; from distutils import sysconfig; stdout.write(sysconfig.get_python_lib())" + OUTPUT_VARIABLE + PYTHON_LIB_DIR +) + +if (NOT PYTHON_SITEDIR) + set(PYTHON_SITEDIR ${PYTHON_LIB_DIR}) +endif (NOT PYTHON_SITEDIR) + +include_directories(${LIBSSH_PUBLIC_INCLUDE_DIRS} ${PYTHON_INCLUDE_PATH}) + +set_source_files_properties(${SWIG_INPUT} PROPERTIES CPLUSPLUS ON) +# Py_True and Py_False are a bit tricky +set_source_files_properties(${swig_generated_file_fullname} PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing") +swig_add_module(ssh python ${SWIG_INPUT}) +swig_link_libraries(ssh ${LIBSSH_SHARED_LIBRARY} ${PYTHON_LIBRARIES}) + +install(TARGETS ${SWIG_MODULE_ssh_REAL_NAME} LIBRARY DESTINATION ${PYTHON_SITEDIR}) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ssh.py DESTINATION ${PYTHON_SITEDIR}) -- cgit v1.2.3