cmake: add python stub

Might not be the best approach, maybe use thewtex/cython-cmake-example?
This commit is contained in:
Peter Wu 2016-02-12 15:24:56 +01:00
parent 55b270587b
commit a2ec695ec9
2 changed files with 34 additions and 1 deletions

View File

@ -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)

33
python/CMakeLists.txt Normal file
View File

@ -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()