From: Brad King Date: Mon, 24 Jul 2017 09:14:48 +0000 (+0200) Subject: Sanitize PYTHONLIBS_VERSION_STRING before passing it to 'FIND_PACKAGE (PythonInterp). X-Git-Tag: 0.6.29~27^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F216%2Fhead;p=thirdparty%2Flibsolv.git Sanitize PYTHONLIBS_VERSION_STRING before passing it to 'FIND_PACKAGE (PythonInterp). Obtained from libsolv_0.6.28-2 in Debian. Origin: https://gitlab.kitware.com/cmake/cmake/merge_requests/1047#note_288680 Bug-Debian: https://bugs.debian.org/867514 Author: Brad King Reviewed-by: gregor herrmann Last-Update: 2017-07-22 --- diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index a83695ff..64ef5287 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -6,7 +6,12 @@ IF (ENABLE_PYTHON3 AND NOT DEFINED PythonLibs_FIND_VERSION) ENDIF (ENABLE_PYTHON3 AND NOT DEFINED PythonLibs_FIND_VERSION) FIND_PACKAGE (PythonLibs REQUIRED) -FIND_PACKAGE (PythonInterp ${PYTHONLIBS_VERSION_STRING} REQUIRED) +IF(PYTHONLIBS_VERSION_STRING MATCHES "^([0-9.]+)") + SET(python_version "${CMAKE_MATCH_1}") +ELSE() + MESSAGE(FATAL_ERROR "PythonLibs version format unknown '${PYTHONLIBS_VERSION_STRING}'") +ENDIF() +FIND_PACKAGE (PythonInterp ${python_version} REQUIRED) EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "from sys import stdout; from distutils import sysconfig; stdout.write(sysconfig.get_python_lib(True))" OUTPUT_VARIABLE PYTHON_INSTALL_DIR)