]> code.ossystems Code Review - openembedded-core.git/commitdiff
cmake: fix Python executable with cmake
authorMartin Kelly <mkelly@xevo.com>
Thu, 2 Apr 2020 20:56:32 +0000 (13:56 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 3 Apr 2020 13:49:13 +0000 (14:49 +0100)
Currently, CMake has two ways of finding Python executables:
FindPythonInterp and FindPython/FindPython3. FindPythonInterp is
deprecated and may be removed at some point. Currently, python3native
sets PYTHON_EXECUTABLE, which FindPythonInterp uses. This is a problem
for a few reasons:

- Setting PYTHON_EXECUTABLE as an environment variable doesn't work, as
  CMake needs it to be set as an explicit CMake option via -D.
- Projects using the newer FindPython/FindPython3 don't pickup the right
  Python, as the newer routines use Python_EXECUTABLE and
  Python3_EXECUTABLE.

Fix this by setting PYTHON_EXECUTABLE, Python_EXECUTABLE, and
Python3_EXECUTABLE using -D options to EXTRA_OECMAKE.

The CMake routines are documented below:
https://cmake.org/cmake/help/latest/module/FindPythonInterp.html
https://cmake.org/cmake/help/latest/module/FindPython.html
https://cmake.org/cmake/help/latest/module/FindPython3.html

Signed-off-by: Martin Kelly <mkelly@xevo.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/cmake.bbclass
meta/classes/python3native.bbclass

index d91cf20130934deb2b254757509d9221956c35f8..94ed8061bb2902ca4baf57f7e7f41f9c1f419edc 100644 (file)
@@ -175,6 +175,9 @@ cmake_do_configure() {
          -DCMAKE_INSTALL_LIBDIR:PATH=${@os.path.relpath(d.getVar('libdir'), d.getVar('prefix') + '/')} \
          -DCMAKE_INSTALL_INCLUDEDIR:PATH=${@os.path.relpath(d.getVar('includedir'), d.getVar('prefix') + '/')} \
          -DCMAKE_INSTALL_DATAROOTDIR:PATH=${@os.path.relpath(d.getVar('datadir'), d.getVar('prefix') + '/')} \
+         -DPYTHON_EXECUTABLE:PATH=${PYTHON} \
+         -DPython_EXECUTABLE:PATH=${PYTHON} \
+         -DPython3_EXECUTABLE:PATH=${PYTHON} \
          -DLIB_SUFFIX=${@d.getVar('baselib').replace('lib', '')} \
          -DCMAKE_INSTALL_SO_NO_EXE=0 \
          -DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \
index 182c11aa2e2677ba19983d0d049b5f2f26b0de13..d98fb4c7583166c3f3fc0185d5a07e9a90483d28 100644 (file)
@@ -1,8 +1,6 @@
 inherit python3-dir
 
 PYTHON="${STAGING_BINDIR_NATIVE}/python3-native/python3"
-# PYTHON_EXECUTABLE is used by cmake
-PYTHON_EXECUTABLE="${PYTHON}"
 EXTRANATIVEPATH += "python3-native"
 DEPENDS_append = " python3-native "