1find_package (PythonLibs ${PYTHONBUILD_VERSION} REQUIRED) 2 3INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) 4 5include_directories( 6 ${CMAKE_CURRENT_SOURCE_DIR}/.. 7 ${PYTHON_INCLUDE_DIRS} 8) 9 10set_source_files_properties (mraa.i PROPERTIES CPLUSPLUS ON) 11set_source_files_properties (mraa.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src") 12swig_add_module (python-mraa python mraa.i ${mraa_LIB_SRCS}) 13swig_link_libraries (python-mraa ${PYTHON_LIBRARIES} ${mraa_LIBS}) 14 15if (DOXYGEN_FOUND) 16 foreach (_file ${DOCCLASSES}) 17 add_dependencies (${SWIG_MODULE_python-mraa_REAL_NAME} ${_file}class_doc_i) 18 endforeach () 19 add_dependencies (${SWIG_MODULE_python-mraa_REAL_NAME} common_hpp_doc_i) 20 21 add_custom_target (pydoc 22 pydoc -w ${CMAKE_CURRENT_BINARY_DIR}/mraa.py ${CMAKE_CURRENT_BINARY_DIR}/ 23 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 24 COMMENT "Generating API documentation with pydoc" VERBATIM 25 ) 26endif () 27 28set_target_properties (${SWIG_MODULE_python-mraa_REAL_NAME} PROPERTIES 29 OUTPUT_NAME _mraa 30 COMPILE_FLAGS "${CMAKE_C_FLAGS} -DSWIGPYTHON=${SWIG_FOUND}" 31) 32 33execute_process ( 34 COMMAND ${PYTHON_EXECUTABLE} -c 35 "import site, sys; sys.stdout.write(site.PREFIXES[-1])" 36 OUTPUT_VARIABLE PYTHON_PREFIX 37) 38file (TO_CMAKE_PATH "${PYTHON_PREFIX}" PYTHON_PREFIX) 39execute_process ( 40 COMMAND ${PYTHON_EXECUTABLE} -c 41 "import site, sys; sys.stdout.write(site.getusersitepackages().replace(site.getuserbase(), site.PREFIXES[-1]))" 42 OUTPUT_VARIABLE PYTHON_SITE_DIR 43) 44file (TO_CMAKE_PATH "${PYTHON_SITE_DIR}" PYTHON_SITE_DIR) 45string (REGEX REPLACE "^${PYTHON_PREFIX}/" "" 46 PYTHON_SITE_DIR "${PYTHON_SITE_DIR}") 47 48install (FILES ${CMAKE_CURRENT_BINARY_DIR}/_mraa.so 49 ${CMAKE_CURRENT_BINARY_DIR}/mraa.py 50 DESTINATION ${PYTHON_SITE_DIR}) 51 52add_subdirectory (docs) 53