From 3f03877f5a838973d0d22f6b45c112228319f4da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 5 May 2021 13:26:56 +0300 Subject: [PATCH] [LLDB] Don't use the local python to set a default for LLDB_PYTHON_RELATIVE_PATH when cross compiling. Differential Revision: https://reviews.llvm.org/D101903 --- lldb/CMakeLists.txt | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt index b5633e21c56a..2bb05c1e220b 100644 --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -31,13 +31,22 @@ if (WIN32) endif() if (LLDB_ENABLE_PYTHON) - execute_process( - COMMAND ${Python3_EXECUTABLE} - -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(True, False, ''))" - OUTPUT_VARIABLE LLDB_PYTHON_DEFAULT_RELATIVE_PATH - OUTPUT_STRIP_TRAILING_WHITESPACE) + if (NOT CMAKE_CROSSCOMPILING) + execute_process( + COMMAND ${Python3_EXECUTABLE} + -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(True, False, ''))" + OUTPUT_VARIABLE LLDB_PYTHON_DEFAULT_RELATIVE_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE) + + file(TO_CMAKE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH} LLDB_PYTHON_DEFAULT_RELATIVE_PATH) + else () + if ("${LLDB_PYTHON_RELATIVE_PATH}" STREQUAL "") + message(FATAL_ERROR + "Crosscompiling LLDB with Python requires manually setting + LLDB_PYTHON_RELATIVE_PATH.") + endif () + endif () - file(TO_CMAKE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH} LLDB_PYTHON_DEFAULT_RELATIVE_PATH) set(LLDB_PYTHON_RELATIVE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH} CACHE STRING "Path where Python modules are installed, relative to install prefix") endif ()