diff options
-rw-r--r-- | CMakeLists.txt | 28 | ||||
-rw-r--r-- | pyk8055/CMakeLists.txt | 12 | ||||
-rw-r--r-- | pyk8055/Makefile | 37 | ||||
-rw-r--r-- | pyk8055/setup.py | 38 |
4 files changed, 59 insertions, 56 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d2e3eb5..df24e7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,14 @@ IF(wxWidgets_FOUND) ADD_SUBDIRECTORY(k8055gui) ENDIF() # +FIND_PACKAGE(SWIG) +FIND_PACKAGE(PythonLibs) +FIND_PACKAGE(PythonInterp) +IF(SWIG_FOUND AND PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND) + SET(BUILD_PYTHON TRUE) + ADD_SUBDIRECTORY(pyk8055) +ENDIF() +# # BUILD SUMMARY # COLOR_MESSAGE("\n${_escape}[1;36mBuild Summary${_escape}[0m\n--------------------") @@ -68,4 +76,24 @@ IF(wxWidgets_FOUND) ELSE() COLOR_MESSAGE("* ${_escape}[1;35mwxwidget${_escape}[0m : ${_escape}[1;31mmissing${_escape}[0m unable to build k8055gui") ENDIF() +IF(SWIG_FOUND) + COLOR_MESSAGE("* ${_escape}[1;35mSWIG${_escape}[0m : ${_escape}[1;32mfound${_escape}[0m") +ELSE() + COLOR_MESSAGE("* ${_escape}[1;35mSWIG${_escape}[0m : ${_escape}[1;31mmissing${_escape}[0m") +ENDIF() +IF(PYTHONLIBS_FOUND) + COLOR_MESSAGE("* ${_escape}[1;35mpython libs${_escape}[0m : ${_escape}[1;32mfound${_escape}[0m") +ELSE() + COLOR_MESSAGE("* ${_escape}[1;35mpython libs${_escape}[0m : ${_escape}[1;31mmissing${_escape}[0m") +ENDIF() +IF(PYTHONINTERP_FOUND) + COLOR_MESSAGE("* ${_escape}[1;35mpython interpreter${_escape}[0m : ${_escape}[1;32mfound${_escape}[0m") +ELSE() + COLOR_MESSAGE("* ${_escape}[1;35mpython interpreter${_escape}[0m : ${_escape}[1;31mmissing${_escape}[0m") +ENDIF() +IF(BUILD_PYTHON) + COLOR_MESSAGE("* build pyk8055") +ELSE() + COLOR_MESSAGE("* unable to build pyk8055") +ENDIF() MESSAGE("") diff --git a/pyk8055/CMakeLists.txt b/pyk8055/CMakeLists.txt new file mode 100644 index 0000000..33aa210 --- /dev/null +++ b/pyk8055/CMakeLists.txt @@ -0,0 +1,12 @@ + +INCLUDE(${SWIG_USE_FILE}) +INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + +SET(CMAKE_SWIG_FLAGS "") + +SET_SOURCE_FILES_PROPERTIES(libk8055.i PROPERTIES CPLUSPLUS ON) +SET_SOURCE_FILES_PROPERTIES(libk8055.i PROPERTIES SWIG_FLAGS "-includeall") +SWIG_ADD_MODULE(pyk8055 python libk8055.i ${CMAKE_SOURCE_DIR}/libk8055/libk8055.c) +SWIG_LINK_LIBRARIES(pyk8055 ${PYTHON_LIBRARIES}) + diff --git a/pyk8055/Makefile b/pyk8055/Makefile deleted file mode 100644 index a2069d3..0000000 --- a/pyk8055/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -# $Id: Makefile,v 1.3 2007/04/08 10:54:49 pjetur Exp $ -# -#cc = gcc -#pylibdir = pyk8055 -#libs = -lusb -L/usr/lib -lm - -# We have to build extension "inplace" if We're to -# run samples locally without installing - -all: libk8055.i ../libk8055.c - python setup.py build_ext --inplace - python setup.py build - -# Or in plain language -# swig -python libk8055.i -# cc -fpic -O2 -c ../libk8055.c -o ./libk8055.o -# cc -fpic -O2 -c libk8055_wrap.c -I /usr/include/python2.4/ -o libk8055_wrap.o -# ld -shared libk8055.o libk8055_wrap.o -lusb -o _pyk8055.so -## mv -f pyk8055.py __init__.py - -.PHONY: kdemo - -kdemo: k8055qt.py frmk8055qt.ui frmk8055qt.ui.h - pyuic frmk8055qt.ui -o frmk8055qt.py - -# install will both make build and install -install: - python setup.py install - -# Remove all swig generated files -clean: - python setup.py clean --all - rm -f *.o _pyk8055.so libk8055_wrap.c pyk8055.py pyk8055.pyc - -uninstall: - python setup.py uninstall - #rm -f /usr/lib/python-2.4/site-packages/pyk8055.py /usr/lib/python-2.4/site-packages/_pyk8055.so diff --git a/pyk8055/setup.py b/pyk8055/setup.py index b1a1c85..9b68581 100644 --- a/pyk8055/setup.py +++ b/pyk8055/setup.py @@ -5,27 +5,27 @@ from distutils.core import setup, Extension __revision__ = "$Id: setup.py,v 1.3 2007/03/28 10:17:57 pjetur Exp $" -if os.environ.has_key('VERSION'): - version=os.environ['VERSION'] +if 'VERSION' in os.environ: + version=os.environ['VERSION'] else: - from subprocess import * - try: - version = Popen(["grep ^VERSION ../Makefile | cut -d '=' -f 2 | tr -d '\n'"], stdout=PIPE, shell=True).communicate()[0] - except: - version='?.?' + from subprocess import * + try: + version = Popen(["grep ^VERSION ../Makefile | cut -d '=' -f 2 | tr -d '\n'"], stdout=PIPE, shell=True).communicate()[0] + except: + version='?.?' build_modules = [Extension('_pyk8055', - define_macros = [('VERSION', "\"%s\"" % str(version))], - libraries=["usb"], - sources=['libk8055.i',"../libk8055.c"])] - + define_macros = [('VERSION', "\"%s\"" % str(version))], + libraries=["usb"], + sources=['libk8055.i',"../libk8055/libk8055.c"])] + setup( - name='pyk8055', - version=version, - author='Pjetur G. Hjaltason', - author_email='pjetur@pjetur.net', - description='K8055 library wrapper', - url='http://libk8055.sourceforge.net/', - ext_modules =build_modules, - py_modules=['pyk8055'] + name='pyk8055', + version=version, + author='Pjetur G. Hjaltason', + author_email='pjetur@pjetur.net', + description='K8055 library wrapper', + url='http://libk8055.sourceforge.net/', + ext_modules =build_modules, + py_modules=['pyk8055'] ) |