diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-07-16 18:27:12 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-07-16 18:27:12 +0000 |
commit | 78de1e608bd04dd45507a31d0bb721c21490acd7 (patch) | |
tree | 9353109cf9d6ae50f64366552d97339a65f1b17c | |
parent | 6e87fa2bac17241d8d19811d951486404da44cdb (diff) |
[CMake] Fail when Python interpreter doesn't match Python libraries version
Because of how CMake finds the Python libraries and interpreter, it's
possible to end up with a discrepancy between the two. For example,
you'd end up using a Python 3 interpreter to run the test suite while
LLDB was built and linked against Python 2.
This patch adds a fatal error to CMake so we find out at configuration
time, instead of finding out at test time.
Differential revision: https://reviews.llvm.org/D64812
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@366243 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | cmake/modules/LLDBConfig.cmake | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/cmake/modules/LLDBConfig.cmake b/cmake/modules/LLDBConfig.cmake index ef9356591..26a1c7a72 100644 --- a/cmake/modules/LLDBConfig.cmake +++ b/cmake/modules/LLDBConfig.cmake @@ -185,7 +185,6 @@ function(find_python_libs_windows) endfunction(find_python_libs_windows) if (NOT LLDB_DISABLE_PYTHON) - if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") find_python_libs_windows() @@ -194,8 +193,12 @@ if (NOT LLDB_DISABLE_PYTHON) add_definitions( -DLLDB_PYTHON_HOME="${LLDB_PYTHON_HOME}" ) endif() else() - find_package(PythonInterp) - find_package(PythonLibs) + find_package(PythonInterp REQUIRED) + find_package(PythonLibs REQUIRED) + endif() + + if (NOT PYTHON_VERSION_STRING VERSION_EQUAL PYTHONLIBS_VERSION_STRING) + message(FATAL_ERROR "Found incompatible Python interpreter (${PYTHON_VERSION_STRING}) and Python libraries (${PYTHONLIBS_VERSION_STRING})") endif() if (PYTHON_INCLUDE_DIR) |