This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/swig/python/CMakeLists.txt

103 lines
3.9 KiB
CMake
Raw Normal View History

2015-08-18 21:05:07 +01:00
2016-04-05 08:11:05 +01:00
# This is a CMake example for Python
2015-08-18 21:05:07 +01:00
2016-04-05 08:11:05 +01:00
INCLUDE(${SWIG_USE_FILE})
2015-08-18 21:05:07 +01:00
2016-12-10 07:01:10 +00:00
GET_PROPERTY(OBJECTS TARGET core PROPERTY SOURCES)
GET_PROPERTY(OBJECTS TARGET libYAPOs PROPERTY SOURCES)
GET_PROPERTY(OBJECTS TARGET libOPTYap PROPERTY SOURCES)
# list( APPEND OBJECTS GET_PROPERTY(sourcefiles TARGET myddas PROPERTY SOURCES))
# list( APPEND OBJECTS GET_PROPERTY(sourcefiles TARGET Yapsqlite3 PROPERTY SOURCES))
# list( APPEND OBJECTS GET_PROPERTY(sourcefiles TARGET libswi PROPERTY SOURCES))
# list( APPEND OBJECTS GET_PROPERTY(sourcefiles TARGET myddas PROPERTY SOURCES))
# list( APPEND OBJECTS GET_PROPERTY(sourcefiles TARGET utf8proc PROPERTY SOURCES))
# list( APPEND OBJECTS GET_PROPERTY(sourcefiles TARGET Yap++ PROPERTY SOURCES))
2016-08-22 04:01:38 +01:00
2016-04-12 16:05:20 +01:00
if (PYTHONLIBS_FOUND)
2015-08-18 21:05:07 +01:00
2016-12-10 07:01:10 +00:00
include(FindPythonModule)
2016-08-22 04:01:38 +01:00
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/CXX)
2016-04-05 08:11:05 +01:00
2016-08-23 03:45:57 +01:00
SET(CMAKE_SWIG_FLAGS "-py3")
2016-04-05 08:11:05 +01:00
2016-08-22 04:01:38 +01:00
SET_SOURCE_FILES_PROPERTIES(../yap.i PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(../yap.i PROPERTIES SWIG_FLAGS "-includeall")
2016-12-10 07:01:10 +00:00
SET_SOURCE_FILES_PROPERTIES(../yap.i PROPERTIES SWIG_FLAGS "-py3")
SET_SOURCE_FILES_PROPERTIES(../yap.i PROPERTY SWIG_MODULE_NAME yap )
SET_SOURCE_FILES_PROPERTIES(../yap.i PROPERTY OUTPUT_NAME yap )
2016-07-31 17:37:37 +01:00
2016-12-10 07:01:10 +00:00
#configure_file ("setup.py.cmake" "setup.py" )
#configure_file ("../yap.i" "yap.i" )
2016-07-31 17:37:37 +01:00
2016-12-10 07:01:10 +00:00
SET( CMAKE_SWIG_OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/yap" )
2016-07-31 17:37:37 +01:00
2016-12-10 07:01:10 +00:00
SWIG_ADD_MODULE(Py2YAP python ../yap.i )
SWIG_LINK_LIBRARIES(Py2YAP ${PYTHON_LIBRARIES} Yap++ YAPPython libYap)
set_target_properties ( ${SWIG_MODULE_Py2YAP_REAL_NAME} PROPERTIES
NO_SONAME ON OUTPUT_NAME _yap LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/yap" )
2016-08-23 01:18:33 +01:00
2016-04-05 08:11:05 +01:00
2016-12-10 07:01:10 +00:00
execute_process ( COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print( sysconfig.get_path( 'platlib' ) )"
OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE )
get_filename_component ( ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE )
file ( RELATIVE_PATH _REL_PYTHON_MOULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH} )
2016-04-12 16:05:20 +01:00
2016-12-10 07:01:10 +00:00
set ( PYTHON_MODULE_PATH
${_ABS_PYTHON_MODULE_PATH}
)
2016-04-12 16:05:20 +01:00
2016-12-10 07:01:10 +00:00
# set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
2016-07-31 17:37:37 +01:00
2016-12-10 07:01:10 +00:00
# add_custom_target ( py2yap ALL
# COMMAND ${PYTHON_EXECUTABLE} setup.py bdist
# DEPENDS ../yap.i YAPPython )
2016-07-31 17:37:37 +01:00
2016-12-10 07:01:10 +00:00
# install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} install
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
2016-04-12 16:05:20 +01:00
2016-12-10 07:01:10 +00:00
INSTALL ( FILES ${CMAKE_CURRENT_BINARY_DIR}/yap/_yap.so DESTINATION ${PYTHON_MODULE_PATH} )
INSTALL ( FILES ${CMAKE_CURRENT_BINARY_DIR}/yap/yap.py DESTINATION ${PYTHON_MODULE_PATH} )
2016-04-12 16:05:20 +01:00
2016-08-22 04:01:38 +01:00
if ( DOCUMENTATION AND DOXYGEN_FOUND )
2016-04-12 16:05:20 +01:00
2016-08-22 04:01:38 +01:00
set(CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
2016-04-12 16:05:20 +01:00
2016-08-22 04:01:38 +01:00
# Run doxygen to only generate the xml
add_custom_command ( OUTPUT ${CMAKE_BINARY_DIR}/doc/xml/ftdi_8c.xml
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/doc
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile.xml
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS ${c_headers};${c_sources};${cpp_sources};${cpp_headers}
)
2016-04-12 16:05:20 +01:00
2016-08-22 04:01:38 +01:00
# generate .i from doxygen .xml
add_custom_command ( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ftdi1_doc.i
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
${CMAKE_BINARY_DIR}/doc/xml/ftdi_8c.xml
${CMAKE_CURRENT_BINARY_DIR}/ftdi1_doc.i
DEPENDS ${CMAKE_BINARY_DIR}/doc/xml/ftdi_8c.xml
)
add_custom_target ( doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ftdi1_doc.i )
add_dependencies( ${SWIG_MODULE_ftdi1_REAL_NAME} doc_i )
2016-04-12 16:05:20 +01:00
2016-08-22 04:01:38 +01:00
endif ()
2016-04-12 16:05:20 +01:00
2016-12-10 07:01:10 +00:00
install(TARGETS ${SWIG_MODULE_Py2YAP_REAL_NAME}
2016-08-23 01:18:33 +01:00
LIBRARY DESTINATION ${dlls}
ARCHIVE DESTINATION ${dlls}
)
2016-08-22 04:01:38 +01:00
# add_subdirectory ( examples )
else ()
message(STATUS "Not building python bindings")
2016-04-12 16:05:20 +01:00
endif(PYTHONLIBS_FOUND)