How do I tell cmake which version of python to use?

I want to use use python 3.7 instead of python 2.7 when building with cmake.

This is the error I get:

enter image description here

How do I tell cmake which python to use?

Text version of my error -

-- Building local IBM Accelerator simulator. -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") -- Found UUID: /usr/include -- Found Python: /usr/bin/python2.7 (found version "2.7.17") found components: Interpreter Development -- Found Python version 2.7.17. Version must be greater than 3.0.0, skipping Python API build. -- Configuring done -- Generating done -- Build files have been written to: /home/cades/dev/envs/xacc/build

Upvotes: 1

Views: 2193

Answers (1)

J-Christophe
J-Christophe

Reputation: 2070

Assuming you are using a recent version of CMake and that you are developing the build system of the project you discussed above, you could do the following:

find_package (Python3 COMPONENTS Interpreter Development)

See https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3

Now, if you are building an existing project, you would have to check if the project support using a newer version of python.

Upvotes: 1

Related Questions