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-06-12 18:00:47 +01:00
|
|
|
#INCLUDE(NewUseSWIG)
|
2015-08-18 21:05:07 +01:00
|
|
|
|
2017-05-08 18:51:29 +01:00
|
|
|
include(FindPythonModule)
|
|
|
|
|
2017-06-05 13:06:12 +01:00
|
|
|
set (PROLOG_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/yapi.yap ${CMAKE_CURRENT_SOURCE_DIR}/jupyter.yap)
|
2017-05-14 11:36:09 +01:00
|
|
|
set (PYTHON_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/yapi.py ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${CMAKE_CURRENT_SOURCE_DIR}/__main__.py)
|
|
|
|
|
2017-05-08 18:51:29 +01:00
|
|
|
file(RELATIVE_PATH RELATIVE_SOURCE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
|
|
|
|
|
2017-05-14 11:36:09 +01:00
|
|
|
configure_file("setup.py.in" ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
|
2017-05-08 18:51:29 +01:00
|
|
|
configure_file("MANIFEST.in" ${CMAKE_CURRENT_BINARY_DIR}/MANIFEST.in)
|
2017-05-14 11:36:09 +01:00
|
|
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/YAP4PY.md" ${CMAKE_CURRENT_BINARY_DIR}/README)
|
2017-05-08 18:51:29 +01:00
|
|
|
|
|
|
|
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
|
|
|
|
|
|
|
|
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/CXX")
|
|
|
|
|
|
|
|
SET_SOURCE_FILES_PROPERTIES(../../swig/yap.i PROPERTIES CPLUSPLUS ON)
|
|
|
|
SET_SOURCE_FILES_PROPERTIES(../../swig/yap.i PROPERTIES SWIG_FLAGS "-O;-py3")
|
2017-06-13 22:02:22 +01:00
|
|
|
SET_SOURCE_FILES_PROPERTIES(../../swig/yap.i PROPERTIES SWIG_MODULE_NAME yap)
|
2017-05-08 18:51:29 +01:00
|
|
|
|
2017-06-13 22:02:22 +01:00
|
|
|
if (WIN32)
|
2017-06-13 13:34:17 +01:00
|
|
|
|
2017-07-03 21:18:01 +01:00
|
|
|
set (SYS_DLLS ${GMP_LIBRARIES} c:/msys64/mingw64/bin/libgmp-10.dll)
|
2017-06-13 22:02:22 +01:00
|
|
|
|
|
|
|
endif()
|
2017-06-08 22:16:52 +01:00
|
|
|
|
2017-05-08 18:51:29 +01:00
|
|
|
# inform we are compiling YAP
|
|
|
|
# s used in MSYS
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# INSTALL ( TARGETS ${SWIG_MODULE_Py2YAP_REAL_NAME}
|
2017-06-15 22:40:55 +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-06-13 13:34:17 +01:00
|
|
|
set (python_dlls $<TARGET_FILE:matrix>
|
2017-05-08 18:51:29 +01:00
|
|
|
$<TARGET_FILE:regexp>
|
|
|
|
$<TARGET_FILE:yap_rl>
|
|
|
|
$<TARGET_FILE:tries>
|
|
|
|
$<TARGET_FILE:itries>
|
|
|
|
$<TARGET_FILE:sys>
|
2017-06-15 22:40:55 +01:00
|
|
|
$<TARGET_FILE:yap_random>
|
2017-06-14 12:34:12 +01:00
|
|
|
)
|
2017-05-08 18:51:29 +01:00
|
|
|
if (TARGET real)
|
2017-06-14 12:34:12 +01:00
|
|
|
list(APPEND python_dlls $<TARGET_FILE:real>
|
2017-06-16 11:53:46 +01:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
if (NOT WIN32)
|
|
|
|
list(APPEND python_dlls $<TARGET_FILE:YAP++> $<TARGET_FILE:Py4YAP>
|
2017-06-14 12:34:12 +01:00
|
|
|
)
|
|
|
|
endif()
|
2017-05-02 07:38:23 +01:00
|
|
|
|
2017-06-05 13:06:12 +01:00
|
|
|
set (PL ${pl_library} ${PROLOG_SOURCES} )
|
|
|
|
|
2017-06-12 18:00:47 +01:00
|
|
|
add_custom_target( YAP4PY_SETUP
|
2017-06-15 22:40:55 +01:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/packages/swig/yap.i ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/config.h ${CMAKE_CURRENT_BINARY_DIR}
|
2017-06-13 13:34:17 +01:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/yap4py
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${python_dlls} ${SYS_DLLS} ${CMAKE_BINARY_DIR}/libYap${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${PYTHON_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/yap4py
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${PL} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${pl_boot_library} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/pl
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${pl_os_library} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/os
|
|
|
|
DEPENDS YAP4PY_SETUP_DIRS STARTUP ${python_dlls} ${PYTHON_SOURCES} ${PROLOG_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/setup.py ${SWIG_MODULE_Py2YAP_REAL_NAME} )
|
|
|
|
|
|
|
|
add_custom_target( YAP4PY_SETUP_DIRS
|
2017-06-12 18:00:47 +01:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py
|
2017-06-14 12:34:12 +01:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/pl
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/os
|
2017-06-13 13:34:17 +01:00
|
|
|
)
|
2017-05-02 07:38:23 +01:00
|
|
|
|
2017-07-01 23:25:22 +01:00
|
|
|
add_custom_target( YAP4PY ALL
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} -m pip uninstall -y YAP4PY
|
2017-06-16 11:53:46 +01:00
|
|
|
COMMAND ${SWIG_EXECUTABLE} -python -modern -c++ -py3 -DX_API -I${CMAKE_SOURCE_DIR}/CXX -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/H -I${CMAKE_SOURCE_DIR}/H/generated -I${CMAKE_SOURCE_DIR}/OPTYap -I../../.. -o yap_wrap.cpp yap.i
|
2017-06-14 12:34:12 +01:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE} setup.py sdist bdist_wheel
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
2017-06-05 13:06:12 +01:00
|
|
|
DEPENDS YAP4PY_SETUP)
|
2017-06-13 22:02:22 +01:00
|
|
|
|
2017-05-08 18:51:29 +01:00
|
|
|
|
2017-05-27 22:54:00 +01:00
|
|
|
|
2017-07-01 23:25:22 +01:00
|
|
|
install(CODE "execute_process(
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} -m pip install --force --no-index -f packages/python/swig/dist YAP4PY
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})"
|
2017-06-14 12:34:12 +01:00
|
|
|
DEPENDS Py4YAP ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${dlls} )
|
2017-05-08 18:51:29 +01:00
|
|
|
|
2017-06-05 13:06:12 +01:00
|
|
|
install(FILES ${PROLOG_SOURCES} DESTINATION ${libpl})
|
2017-05-27 22:54:00 +01:00
|
|
|
|
|
|
|
|
2017-05-08 18:51:29 +01:00
|
|
|
|
|
|
|
if (WITH_DOCS AND DOXYGEN_FOUND)
|
2017-05-02 07:38:23 +01:00
|
|
|
|
|
|
|
set(CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
|
|
|
|
|
|
|
|
# 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}
|
2017-05-08 18:51:29 +01:00
|
|
|
DEPENDS ${c_headers};${c_sources};${cpp_sources};${cpp_headers}
|
|
|
|
)
|
2017-05-02 07:38:23 +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
|
2017-05-19 09:56:37 +01:00
|
|
|
${CMAKE_BINARY_DIR}/doc/xm11l/ftdi_8c.xml
|
2017-05-02 07:38:23 +01:00
|
|
|
${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)
|
|
|
|
|
|
|
|
ENDIF ()
|