User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
info:cython [2011-12-15 16:36]
sam [Disadvantages]
info:cython [2011-12-15 17:12] (current)
sam [Notes/Tricks] cmake
Line 55: Line 55:
     memcpy(<​void*>​ctypes_buffer,​ &​s_cython,​ sizeof(MyStruct))     memcpy(<​void*>​ctypes_buffer,​ &​s_cython,​ sizeof(MyStruct))
     return s_ctypes     return s_ctypes
 +===== CMake Example =====
 +<code cmake>
 +cmake_minimum_required(VERSION 2.8)
 +# TODO: add --gdb option to cython if in Debug mode? Separate option?
 +add_custom_command(OUTPUT ${FOO_CPP}
 +    COMMAND cython --cplus ${FOO_PYX} -o ${FOO_CPP}
 +set(PYLIB foo)
 +add_library(${PYLIB} SHARED ${FOO_CPP})
 +# Remove lib prefix, which Python doesn'​t use
 +set_target_properties(${PYLIB} PROPERTIES PREFIX ""​)
 +target_link_libraries(${PYLIB} ${PYTHON_LIBRARIES})
 +# ... add other libraries if needed
 </​code>​ </​code>​
info/cython.txt · Last modified: 2011-12-15 17:12 by sam