Skip to content

Commit

Permalink
Introduce wrappers/python into cmake build framework
Browse files Browse the repository at this point in the history
Signed-off-by: Yaroslav Halchenko <[email protected]>
  • Loading branch information
yarikoptic authored and JoshBlake committed Dec 17, 2010
1 parent 08b212f commit d94c8c0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ OPTION(BUILD_FAKENECT "Build fakenect mock library" ON)
OPTION(BUILD_C_SYNC "Build c synchronous library" ON)
OPTION(BUILD_CV "Build OpenCV wrapper" OFF)
OPTION(BUILD_AS3_SERVER "Build the Actionscript 3 Server Example" OFF)
OPTION(BUILD_PYTHON "Build Python extension" OFF)
IF(PROJECT_OS_LINUX)
OPTION(BUILD_CPACK "Build an RPM or DEB using CPack" OFF)
ENDIF(PROJECT_OS_LINUX)
Expand Down Expand Up @@ -127,6 +128,10 @@ IF(BUILD_AS3_SERVER)
add_subdirectory(wrappers/actionscript)
ENDIF()

IF(BUILD_PYTHON)
add_subdirectory (wrappers/python)
ENDIF()

######################################################################################
# Extras
######################################################################################
Expand Down
34 changes: 34 additions & 0 deletions wrappers/python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
######################################################################################
# Python extension builder
######################################################################################

include(FindPythonInterp)
include(FindPythonLibs)

find_program(CYTHON_EXECUTABLE cython)

# Figure out installation path
execute_process(COMMAND
${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)

# How to Cython the .pyx file
add_custom_command(OUTPUT freenect.c
COMMAND ${CYTHON_EXECUTABLE} -o freenect.c "${CMAKE_CURRENT_SOURCE_DIR}/freenect.pyx")
list(APPEND ADDITIONAL_MAKE_CLEAN_FILES freenect.c)

# Compile the extension
add_library(cython_freenect MODULE freenect.c)
set_target_properties(cython_freenect PROPERTIES
PREFIX ""
OUTPUT_NAME "freenect"
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(cython_freenect freenect_sync)
include_directories(${PYTHON_INCLUDE_PATH} ../c_sync/)

# Install the extension
install(TARGETS cython_freenect
DESTINATION ${PYTHON_SITE_PACKAGES})

# TODO: decide on what to do with demo_ scripts and were to install
# them

0 comments on commit d94c8c0

Please sign in to comment.