Skip to content

FindPython: how to override Python_EXECUTABLE from user perspective?

Please consider the following test case:

cmake_minimum_required(VERSION 3.12)
project(test)
find_package(Python REQUIRED)

This finds the newest Python installed on my system. However, I can't find a way to force a particular version via cache variables (i.e. as an user, without modifying CMakeLists.txt).

In the old FindPythonInterp module, this was trivial: it was sufficient to pass -DPYTHON_EXECUTABLE=.... However, the new module seems to ignore override of -DPython_EXECUTABLE=... and force 3.7 nevertheless.

Is such user override possible? And if not, can the module be fixed?

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information