From 3b276deb9b52ba8c667c12379c39dc46ea375609 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 10 Nov 2017 15:06:22 +0100 Subject: build: Fix detection of python for swig bindings The cmake build only looked for the libraries but not the interpreter, which caused the build to fail if the library was present, but the interpreter was not installed and executable using the "python" command. The build now looks for the python interpreter as well. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- include/ouroboros/wrap/CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/ouroboros/wrap/CMakeLists.txt b/include/ouroboros/wrap/CMakeLists.txt index 4ffc54a8..43ebd242 100644 --- a/include/ouroboros/wrap/CMakeLists.txt +++ b/include/ouroboros/wrap/CMakeLists.txt @@ -10,8 +10,9 @@ else () include_directories(${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_SWIG_FLAGS "") + find_package(PythonInterp QUIET) find_package(PythonLibs QUIET) - if (NOT PYTHONLIBS_FOUND) + if (NOT PYTHONLIBS_FOUND OR NOT PYTHONINTERP_FOUND) message(STATUS "Python not found: Python bindings will not be built") else () message(STATUS "Python found: Python bindings will be built") @@ -38,12 +39,14 @@ else () # Installation directives if (CMAKE_INSTALL_PREFIX STREQUAL "") execute_process( - COMMAND python -c "from distutils import sysconfig; print(sysconfig.get_python_lib())" + COMMAND ${PYTHON_EXECUTABLE} -c + "from distutils import sysconfig; print(sysconfig.get_python_lib())" OUTPUT_VARIABLE PYTHON_MODULE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) else () execute_process( - COMMAND python -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))" + COMMAND ${PYTHON_EXECUTABLE} -c + "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))" OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) get_filename_component(_ABS_PYTHON_MODULE_PATH -- cgit v1.2.3