[cmake-developers] Issues with overriding Python version, possible bug?

Brad King brad.king at kitware.com
Mon May 1 08:54:43 EDT 2017


On 04/29/2017 04:47 PM, Alan W. Irwin wrote:
> looks for Python 3, but if that does not exist it looks for Python 2.
> 
> find_package(PythonInterp 3)
> find_package(PythonInterp 2)
> 
> So far so good, but I am sure there will be some of our users that
> prefer Python 2 even when Python 3 is installed on their system.

You should use your own variable for that.  The version-named executables
are searched based on PythonInterp_FIND_VERSION which comes from the
version number passed to find_package.  The order of find_package calls
and the version numbers passed to them is controlled by your project,
so if you want a switch for this it should be in your project.

Or, you can tell the users to pass `-DPYTHON_EXECUTABLE=/path/to/python2`
to specify the desired python executable.

> way (e.g., by setting Python_ADDITIONAL_VERSIONS) to specify the
> Python version they prefer.

That variable is only for aiding the search for future python versions
not released as of the running version of CMake, e.g. 3.12.

-Brad



More information about the cmake-developers mailing list