blob: c164e0b9fa9e8ade95493503ea1337e713515b03 [file] [log] [blame]
Radek Krejcic61f0b42017-06-07 13:21:41 +02001find_program(PYTHON "python3")
2
3if (PYTHON)
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})
8
9 if(CMAKE_BUILD_TYPE STREQUAL debug)
10 set(DEBUG "--debug")
11 endif()
12
Radek Krejcic2074282017-11-06 15:57:22 +010013 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 Krejcic61f0b42017-06-07 13:21:41 +020021 configure_file(${SETUP_PY_IN} ${SETUP_PY})
Radek Krejcib03ebe42017-07-04 14:00:33 +020022 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/Makefile.in ${CMAKE_CURRENT_SOURCE_DIR}/docs/Makefile)
Radek Krejcic61f0b42017-06-07 13:21:41 +020023 add_custom_target(pyapi ALL COMMAND ${PYTHON} ${SETUP_PY} build -b ${PYAPI_BUILD_DIR} ${DEBUG})
Radek Krejcib03ebe42017-07-04 14:00:33 +020024 add_custom_target(pyapidoc COMMAND make -f ${CMAKE_CURRENT_SOURCE_DIR}/docs/Makefile html)
PavolVicaneb0f88b2018-03-09 13:24:38 +010025 install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} build -b ${PYAPI_BUILD_DIR} install --root=\$ENV{DESTDIR}/ --prefix=${CMAKE_INSTALL_PREFIX})")
Radek Krejcic61f0b42017-06-07 13:21:41 +020026endif()