diff --git a/CMakeLists.txt b/CMakeLists.txt index b533465b9c9..ebf5cd92cda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -499,9 +499,13 @@ if(WITH_MGR) # Please specify 3 or 3.[0-7] if you want to build with python3 support. # FindPython thinks they belong to different families. set(MGR_PYTHON_VERSION "2.7" CACHE - STRING "minimal required version of python runtime for running mgr plugins. ") - find_package(Python ${MGR_PYTHON_VERSION} REQUIRED + STRING "required version of python runtime for running mgr plugins. ") + if(NOT MGR_PYTHON_VERSION MATCHES "^[23]$") + set(find_python_exact "EXACT") + endif() + find_package(Python ${MGR_PYTHON_VERSION} ${find_python_exact} REQUIRED COMPONENTS Interpreter Development) + unset(find_python_exact) set(MGR_PYTHON_EXECUTABLE ${Python_EXECUTABLE}) set(MGR_PYTHON_LIBRARIES ${Python_LIBRARIES}) set(MGR_PYTHON_VERSION_MAJOR ${Python_VERSION_MAJOR}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d1334bda844..d945268f41f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -240,8 +240,12 @@ if(WITH_PYTHON3) if(WITH_PYTHON3 MATCHES "^(1|ON|YES|TRUE|Y)$") set(WITH_PYTHON3 "3") endif() - find_package(Python3 ${WITH_PYTHON3} REQUIRED + if(NOT WITH_PYTHON3 STREQUAL "3") + set(find_python3_exact "EXACT") + endif() + find_package(Python3 ${WITH_PYTHON3} ${find_python3_exact} REQUIRED COMPONENTS Interpreter Development) + unset(find_python3_exact) endif() # the major version of the python bindings as a dependency of other