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/python/swig/CMakeLists.txt

105 lines
3.8 KiB
CMake
Raw Normal View History

2015-08-18 21:05:07 +01:00
2017-05-02 07:38:23 +01:00
# This is a CMake example for Python
2015-08-18 21:05:07 +01:00
2017-09-06 01:09:46 +01:00
INCLUDE(UseSWIG)
2015-08-18 21:05:07 +01:00
2017-05-08 18:51:29 +01:00
include(FindPythonModule)
list (APPEND pl_library ${CMAKE_CURRENT_SOURCE_DIR}/prolog/yapi.yap )
2017-12-11 03:36:21 +00:00
set (PYTHON_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/yap4py/yapi.py ${CMAKE_CURRENT_SOURCE_DIR}/yap4py/__main__.py)
2017-05-14 11:36:09 +01:00
2017-11-09 12:14:41 +00:00
2017-10-11 02:24:15 +01:00
SET_SOURCE_FILES_PROPERTIES(../../swig/yap.i PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(../../swig/yap.i PROPERTIES SWIG_FLAGS "-O;-py3")
2017-11-08 09:29:01 +00:00
SET_SOURCE_FILES_PROPERTIES(../../swiyap.i PROPERTIES SWIG_MODULE_NAME yap4py.yap)
2017-10-11 02:24:15 +01:00
#SET_SOURCE_FILES_PROPERTIES(../../swi/yap.i PROPERTIES OUTPUT_NAME yap)
2017-11-11 22:48:09 +00:00
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py)
2017-10-11 02:24:15 +01:00
set(YAP4PY_PL prolog/yapi.yap)
2017-11-09 12:14:41 +00:00
set(YAP4PY_PY yap4py/__init__.py yap4py/__main__.py yap4py/yapi.py)
2017-05-08 18:51:29 +01:00
2017-11-11 22:48:09 +00:00
configure_file("setup.py.in" setup.py)
2017-05-08 18:51:29 +01:00
configure_file("MANIFEST.in" ${CMAKE_CURRENT_BINARY_DIR}/MANIFEST.in)
2017-11-09 12:14:41 +00:00
configure_file("YAP4PY.md" README.md)
2017-12-11 03:36:21 +00:00
configure_file(yap4py/__init__.py.in yap4py/__init__.py)
2017-05-08 18:51:29 +01:00
2017-10-11 02:24:15 +01:00
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/include
)
2017-05-08 18:51:29 +01:00
2017-10-27 23:06:23 +01:00
2017-05-08 18:51:29 +01:00
2017-10-11 02:24:15 +01:00
SET(SWIG_SOURCES
${CMAKE_SOURCE_DIR}/packages/swig/yap.i
)
# inform we are compiling YAP
2017-05-08 18:51:29 +01:00
# s used in MSYS
2017-10-11 02:24:15 +01:00
2017-05-08 18:51:29 +01:00
# INSTALL ( TARGETS ${SWIG_MODULE_Py2YAP_REAL_NAME}
2017-09-06 01:09:46 +01:00
# RUNTIME DESTINATION ${PYTHON_MODULE_PATH}
# ARCHIVE DESTINATION ${PYTHON_MODULE_PATH}
# LIBRARY DESTINATION ${PYTHON_MODULE_PATH}
2017-06-14 12:34:12 +01:00
# )
2017-05-08 18:51:29 +01:00
2017-10-11 02:24:15 +01:00
if (CONDA)
set(bdist bdist_conda)
else()
set(bdist bdist_wheel)
endif()
2017-10-04 09:18:17 +01:00
add_custom_target( YAP4PY ALL
2017-11-09 12:14:41 +00:00
COMMAND ${SWIG_EXECUTABLE} -c++ -python -O -py3 -module "yap" -addextern -I${CMAKE_SOURCE_DIR}/H -I${CMAKE_SOURCE_DIR}/H/generated -I${CMAKE_SOURCE_DIR}/include
-I${CMAKE_SOURCE_DIR}/OPTYap -I${CMAKE_SOURCE_DIR}/os -I${CMAKE_SOURCE_DIR}/utf8proc -I.././.. -I${CMAKE_SOURCE_DIR}/CXX -I${CMAKE_SOURCE_DIR}/packages/python
-outdir ${CMAKE_CURRENT_BINARY_DIR}/yap4py -I${GMP_INCLUDE_DIRS} -DX_API="" -o ${CMAKE_CURRENT_BINARY_DIR}/yap4py/yap_wrap.cxx -oh ${CMAKE_CURRENT_BINARY_DIR}/yap4py/yap_wrap.hh ${SWIG_SOURCES}
2017-10-11 02:24:15 +01:00
COMMAND ${PYTHON_EXECUTABLE} setup.py sdist ${bdist}
2017-10-04 09:18:17 +01:00
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
2017-11-09 12:14:41 +00:00
DEPENDS ${SWIG_SOURCES} Py4YAP YAP++ yap4py/yapi.cpp YAP4PY_PY
2017-11-08 09:29:01 +00:00
)
2017-05-27 22:54:00 +01:00
2017-11-09 12:14:41 +00:00
add_custom_command( OUTPUT yap4py/yapi.cpp
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/CXX/yapi.cpp ${CMAKE_CURRENT_BINARY_DIR}/yap4py
DEPENDS ${CMAKE_SOURCE_DIR}/CXX/yapi.cpp
)
add_custom_command( OUTPUT YAP4PY_PY
COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/yap4py
DEPENDS ${PYTHON_SOURCES}
)
2017-11-08 09:29:01 +00:00
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --ignore-installed .
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})"
2017-12-05 15:14:57 +00:00
DEPENDS Py4YAP ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${YAP_INSTALL_DLLDIR} )
2017-05-27 22:54:00 +01:00
2017-05-08 18:51:29 +01:00
2017-11-08 09:29:01 +00:00
install(FILES ${YAP4PY_PL} DESTINATION ${libpl} )
add_to_group( YAP4PY_PL pl_library )
2017-10-04 09:18:17 +01:00
if (WITH_DOCS AND DOXYGEN_FOUND)
2017-05-02 07:38:23 +01:00
2017-10-04 09:18:17 +01:00
set(CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
2017-05-02 07:38:23 +01:00
2017-10-04 09:18:17 +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}
)
2017-05-02 07:38:23 +01:00
2017-10-04 09:18:17 +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/xm11l/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)
2017-05-02 07:38:23 +01:00
2017-10-04 09:18:17 +01:00
ENDIF ()