Created attachment 457060 [details] Minimal CMakeList.txt to reproduce behavior If you build the attached CMakeLists.txt with: cmake . CMake finds the correct Python executable (/usr/bin/python2.7): -- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.12", minimum required is "2.7") If you build it with: cmake -DCMAKE_BUILD_TYPE=Gentoo . CMake finds /usr/bin/python, which I eselected to python3.4: -- Found PythonInterp: /usr/bin/python (found suitable version "3.4.5", minimum required is "2.7")
This is intentional behaviour. When we build a package against python, we need to be absolutely certain that we are building against the correct version given the selected PYTHON_TARGET. From FindPythonInterp.cmake: >if (CMAKE_GENTOO_BUILD OR CMAKE_BUILD_TYPE STREQUAL Gentoo) > set(_Python_NAMES python) >endif() When a Gentoo build is active (intended only to be the case when building via a package manager), we throw away whatever cmake would have found and force /usr/bin/python instead. The python eclass then exports EPYTHON="pythonX.Y" causing /usr/bin/python to point to the correct version given the active PYTHON_TARGET.