From 55febc88c4e3cab9b0dd6c07cfe1c60bf7a17f84 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 1 Sep 2020 17:39:05 +0100 Subject: [PATCH] Check shiboken2's python version matches python version we're linking to * We also reverse Python_ADDITIONAL_VERSIONS so it finds the newest one. It doesn't seem like there's a way in general to make these match, so we hope that searching from newest to oldest will find the same in both - or at least it makes it easier for the user to fix by installing the newest in both. --- CMakeLists.txt | 2 +- qrenderdoc/CMakeLists.txt | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 47adb4511..7ee30d4cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -390,7 +390,7 @@ add_subdirectory(renderdoc) # are handled in common if(ENABLE_QRENDERDOC OR ENABLE_PYRENDERDOC) # Make sure Python 3 is found - set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7 3.8) + set(Python_ADDITIONAL_VERSIONS 3.8 3.7 3.6 3.5 3.4) find_package(PythonInterp 3 REQUIRED) find_package(PythonLibs 3 REQUIRED) # we also need python3-config for swig diff --git a/qrenderdoc/CMakeLists.txt b/qrenderdoc/CMakeLists.txt index b72f96af8..77a998094 100644 --- a/qrenderdoc/CMakeLists.txt +++ b/qrenderdoc/CMakeLists.txt @@ -215,9 +215,17 @@ if(NOT BUILD_VERSION_DIST_CONTACT STREQUAL "") "DEFINES+=DISTRIBUTION_CONTACT='\\\\\"${BUILD_VERSION_DIST_CONTACT}\\\\\"'\n") endif() -if(PySide2_FOUND AND Shiboken2_FOUND) +option(QRENDERDOC_ENABLE_PYSIDE2 "Enable PySide2 if found" ON) + +if(NOT QRENDERDOC_ENABLE_PYSIDE2) + message(STATUS "PySide2 integration disabled") +elseif(PySide2_FOUND AND Shiboken2_FOUND) message(STATUS "Building with PySide2 ${PySide2_VERSION} from ${PySide2_DIR}") + if(NOT PYTHONLIBS_VERSION_STRING MATCHES "${SHIBOKEN_PYTHON_VERSION_MAJOR}.${SHIBOKEN_PYTHON_VERSION_MINOR}") + message(FATAL_ERROR "Shiboken2 that we found was linked against python ${SHIBOKEN_PYTHON_VERSION_MAJOR}.${SHIBOKEN_PYTHON_VERSION_MINOR} but the python library we're linking against is ${PYTHONLIBS_VERSION_STRING}. Ensure these versions are identical or disable PySide2 compilation with QRENDERDOC_ENABLE_PYSIDE2.") + endif() + get_target_property(SHIBOKEN2_INCLUDE_DIRS Shiboken2::libshiboken INTERFACE_INCLUDE_DIRECTORIES) get_target_property(PYSIDE2_INCLUDE_DIRS PySide2::pyside2 INTERFACE_INCLUDE_DIRECTORIES)