Skip to content
Snippets Groups Projects
Commit 77521f73 authored by Andreas Schenk's avatar Andreas Schenk
Browse files

extended _find_python_binary to make sure the binary matches the library version

parent 699807da
No related branches found
No related tags found
No related merge requests found
...@@ -70,22 +70,44 @@ endmacro() ...@@ -70,22 +70,44 @@ endmacro()
macro(_find_python_bin PYTHON_ROOT VERSION) macro(_find_python_bin PYTHON_ROOT VERSION)
string(REPLACE "." "" _VERSION_NO_DOTS ${VERSION}) string(REPLACE "." "" _VERSION_NO_DOTS ${VERSION})
if(PYTHON_ROOT) foreach(_NAME "python" "python${_VERSION_NO_DOTS}" "python${VERSION}")
find_program(PYTHON_BINARY if(PYTHON_ROOT)
NAMES "python" "python${_VERSION_NO_DOTS}" "python${VERSION}" find_program(PYTHON_BINARY
HINTS "${PYTHON_ROOT}" NAMES ${_NAME}
PATH_SUFFIXES bin HINTS "${PYTHON_ROOT}"
NO_SYSTEM_ENVIRONMENT_PATH NO_DEFAULT_PATH PATH_SUFFIXES bin
) NO_SYSTEM_ENVIRONMENT_PATH NO_DEFAULT_PATH)
else() if(PYTHON_BINARY)
find_program(PYTHON_BINARY execute_process(COMMAND ${PYTHON_BINARY} -V
NAMES "python" "python${_VERSION_NO_DOTS}" "python${VERSION}" OUTPUT_VARIABLE PY_VERSION
HINTS "${CMAKE_PREFIX_PATH}" ERROR_VARIABLE PY_VERSION)
PATH_SUFFIXES bin if(PY_VERSION MATCHES ${VERSION})
) break()
endif() else()
unset(PYTHON_BINARY CACHE)
endif()
endif()
else()
find_program(PYTHON_BINARY
NAMES $_NAME
HINTS "${CMAKE_PREFIX_PATH}"
PATH_SUFFIXES bin)
if(PYTHON_BINARY)
execute_process(COMMAND ${PYTHON_BINARY} -V
OUTPUT_VARIABLE PY_VERSION
ERROR_VARIABLE PY_VERSION)
if(${PY_VERSION} matches ${VERSION})
break()
else()
unset(PYTHON_BINARY CACHE)
endif()
endif()
endif()
endforeach()
endmacro() endmacro()
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# check for python lib # check for python lib
# #
...@@ -114,7 +136,7 @@ macro(check_for_python_binary) ...@@ -114,7 +136,7 @@ macro(check_for_python_binary)
foreach(_VERSION ${PYTHON_VERSIONS}) foreach(_VERSION ${PYTHON_VERSIONS})
if(${PYTHON_MIN_VERSION} VERSION_LESS ${_VERSION}) if(${PYTHON_MIN_VERSION} VERSION_LESS ${_VERSION})
_find_python_bin("${PYTHON_ROOT}" "${_VERSION}") _find_python_bin("${PYTHON_ROOT}" "${_VERSION}")
if(PYTHON_LIBRARIES) if(PYTHON_BINARY)
set(PYTHON_VERSION "${_VERSION}") set(PYTHON_VERSION "${_VERSION}")
break() break()
endif() endif()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment