From 2a0757bf0b3f19add59a8a4590d16e8a1e33e981 Mon Sep 17 00:00:00 2001 From: Marco Biasini <marco.biasini@unibas.ch> Date: Sun, 3 Jun 2012 11:18:38 +0200 Subject: [PATCH] make sure found python lib/binaries match --- cmake_support/FindPython.cmake | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmake_support/FindPython.cmake b/cmake_support/FindPython.cmake index 1548454db..c3b6f7dfd 100644 --- a/cmake_support/FindPython.cmake +++ b/cmake_support/FindPython.cmake @@ -118,8 +118,11 @@ macro(check_for_python_binary) foreach(_VERSION ${PYTHON_VERSIONS}) if(${PYTHON_MIN_VERSION} VERSION_LESS ${_VERSION}) _find_python_bin("${PYTHON_ROOT}" "${_VERSION}") - if(PYTHON_LIBRARIES) + if(PYTHON_BINARY) set(PYTHON_VERSION "${_VERSION}") + # disallow all versions except for the one we just found. This makes + # sure we don't mismatch the python binary and the libraries. + set(PYTHON_VERSIONS "${_VERSION}") break() endif() endif() @@ -141,11 +144,13 @@ if(APPLE AND NOT PYTHON_IGNORE_FRAMEWORKS) check_for_python_framework() endif() +# first check for python binary. +check_for_python_binary() + if(NOT PYTHON_FRAMEWORK_FOUND) check_for_python_lib() endif() -check_for_python_binary() mark_as_advanced( PYTHON_LIBRARIES PYTHON_INCLUDE_PATH @@ -166,6 +171,8 @@ if(PYTHON_LIBRARIES) endif() if (PYTHON_BINARY) + set(PYTHON_VERSION "${PYTHON_VERSION}" + CACHE STRING "Python Version" FORCE) set(PYTHON_BINARY "${PYTHON_BINARY}" CACHE FILEPATH "Python Binary" FORCE) endif() -- GitLab