diff --git a/CMakeLists.txt b/CMakeLists.txt index b0497d9f..fc054f7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -509,8 +509,8 @@ add_subdirectory(third-party) add_subdirectory(src) #add_subdirectory(src/includes) add_subdirectory(examples) -if(0) add_subdirectory(python) +if(0) add_subdirectory(tests) #add_subdirectory(tests/testdata) add_subdirectory(integration-tests) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt new file mode 100644 index 00000000..0a035e7c --- /dev/null +++ b/python/CMakeLists.txt @@ -0,0 +1,33 @@ +# EXTRA_DIST = cnghttp2.pxd nghttp2.pyx + +# XXX consider https://github.com/thewtex/cython-cmake-example + +if(ENABLE_PYTHON_BINDINGS) + # XXX add ALL? Will always be invoked as target is always out-of-date though. + add_custom_target(python + COMMAND ${PYTHON_EXECUTABLE} setup.py build + DEPENDS nghttp2.c + ) + + add_custom_target(python-install + COMMAND ${PYTHON_EXECUTABLE} setup.py install --prefix=${DESTDIR}${CMAKE_INSTALL_PREFIX} + ) + + # XXX cmake does not have an uninstall target, do not bother with this then. + # XXX glob patterns like this will probably not work + #add_custom_target(python-uninstall + # COMMAND ${CMAKE} -E remove -f ${DESTDIR}${CMAKE_INSTALL_FULL_LIBDIR}/python*/site-packages/nghttp2.so + # COMMAND ${CMAKE} -E remove -f ${DESTDIR}${CMAKE_INSTALL_FULL_LIBDIR}/python*/site-packages/python_nghttp2-*.egg + #) + + # XXX cleaner way to advertise the build artifacts? (note nghttp2.c is cleaned automatically) + add_custom_target(python-clean + COMMAND ${PYTHON_EXECUTABLE} setup.py clean --all + ) + + # XXX CYTHON_EXECUTABLE is not set! + add_custom_command(OUTPUT nghttp2.c + COMMAND ${CYTHON_EXECUTABLE} -o nghttp2.c nghttp2.pyx + DEPENDS nghttp2.pyx + ) +endif()