Radek Krejci | c61f0b4 | 2017-06-07 13:21:41 +0200 | [diff] [blame] | 1 | find_program(PYTHON "python3") |
| 2 | |
Claus Klein | 2209191 | 2020-01-20 13:45:47 +0100 | [diff] [blame] | 3 | if(PYTHON) |
Radek Krejci | c61f0b4 | 2017-06-07 13:21:41 +0200 | [diff] [blame] | 4 | set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in") |
| 5 | set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py") |
| 6 | set(PYAPI_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/build") |
| 7 | set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${PYAPI_BUILD_DIR}) |
Claus Klein | 2209191 | 2020-01-20 13:45:47 +0100 | [diff] [blame] | 8 | |
| 9 | if(CMAKE_BUILD_TYPE STREQUAL Debug) |
Radek Krejci | c61f0b4 | 2017-06-07 13:21:41 +0200 | [diff] [blame] | 10 | set(DEBUG "--debug") |
| 11 | endif() |
| 12 | |
Radek Krejci | c207428 | 2017-11-06 15:57:22 +0100 | [diff] [blame] | 13 | if(ENABLE_SSH) |
| 14 | set(SSH_DEFINE ",\"-DNC_ENABLED_SSH\"") |
| 15 | endif() |
| 16 | |
| 17 | if(ENABLE_TLS) |
| 18 | set(TLS_DEFINE ",\"-DNC_ENABLED_TLS\"") |
| 19 | endif() |
| 20 | |
Radek Krejci | c61f0b4 | 2017-06-07 13:21:41 +0200 | [diff] [blame] | 21 | configure_file(${SETUP_PY_IN} ${SETUP_PY}) |
Jan Kundrát | c4b3374 | 2020-01-10 18:21:51 +0100 | [diff] [blame] | 22 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/docs/Makefile) |
Claus Klein | 2209191 | 2020-01-20 13:45:47 +0100 | [diff] [blame] | 23 | add_custom_target(pyapi ALL COMMAND ${PYTHON} ${SETUP_PY} build -b ${PYAPI_BUILD_DIR} ${DEBUG}) |
| 24 | add_custom_target(pyapidoc COMMAND make -f ${CMAKE_CURRENT_BINARY_DIR}/docs/Makefile html) |
Radek Krejci | ee14362 | 2018-03-20 14:35:03 +0100 | [diff] [blame] | 25 | execute_process(COMMAND ${PYTHON} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True))" |
| 26 | OUTPUT_VARIABLE PYTHON_MODULE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) |
Jakub Man | 9c3bda9 | 2020-05-20 08:04:38 +0200 | [diff] [blame^] | 27 | install(CODE "execute_process(COMMAND ${PYTHON} \"${SETUP_PY}\" build -b \"${PYAPI_BUILD_DIR}\" install --install-lib=\$ENV{DESTDIR}/\"${PYTHON_MODULE_PATH}\")") |
Radek Krejci | c61f0b4 | 2017-06-07 13:21:41 +0200 | [diff] [blame] | 28 | endif() |