From 7c62b80d89037db26245338eee509e36902bfb1e Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 24 Feb 2021 13:28:14 +0000 Subject: [PATCH] Search explicitly for python3 with new python search * This prevents the build from silently trying to use python2. We also require development files which were previously optional. --- CMakeLists.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5d27168a..c56b0e24a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -392,15 +392,18 @@ if(ENABLE_QRENDERDOC OR ENABLE_PYRENDERDOC) # Make sure Python 3 is found set(Python_ADDITIONAL_VERSIONS 3.9 3.8 3.7 3.6 3.5 3.4) if(NOT ${CMAKE_VERSION} VERSION_LESS "3.12") - find_package(Python COMPONENTS Interpreter Development) - set(PYTHON_EXECUTABLE ${Python_EXECUTABLE}) - set(PYTHON_LIBRARY ${Python_LIBRARIES}) - set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIRS}) + find_package(Python3 COMPONENTS Interpreter Development REQUIRED) + set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) + set(PYTHON_LIBRARY ${Python3_LIBRARIES}) + set(PYTHON_INCLUDE_DIR ${Python3_INCLUDE_DIRS}) else() find_package(PythonInterp 3 REQUIRED) find_package(PythonLibs 3 REQUIRED) -endif() - # we also need python3-config for swig + endif() + + # we also need python3-config for swig, but it's only for the examples + # so it doesn't matter which one we find as long as we find something! + # Importantly it doesn't have to match the version we link against if(NOT EXISTS "${PYTHON_EXECUTABLE}-config" AND NOT EXISTS "${PYTHON_EXECUTABLE}.${PYTHON_VERSION_MINOR}-config") message(FATAL_ERROR "We require ${PYTHON_EXECUTABLE}-config or ${PYTHON_EXECUTABLE}.${PYTHON_VERSION_MINOR}-config to build swig, please install the python dev package for your system.") endif()