PythonLibs and multiple Python versions error
CMake version: 3.7.2
I need to generate Python bindings in my C project for both 2.7 and 3.x. When I use find_package
for the first time requiring to find Python 2.7 (find_package(PythonLibs 2.7 REQUIRED)
) it goes fine. Then, when I want to get data for Python 3.x (find_package(PythonLibs 3 REQUIRED)
) it fails with message that only 2.7.12 version was found. However, when I run them in the reversed order, the behaviour is symmetric - I can get data for Python 3.x, but not for Python 2.7.
After some digging, I found that it's necessary to set PYTHON_INCLUDE_DIR
to PYTHON_INCLUDE_DIR-NOTFOUND
and PYTHON_LIBRARY
to PYTHON_LIBRARY-NOTFOUND
before find_package
is called for the second time.
My question is: am I doing something fundamentally wrong or these two variables could be set at the beginning of FindPythonLibs.cmake
?