From 423ca67fb2d0bccde547aaa5d8c141e4f50c7422 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Sat, 13 Feb 2021 16:34:26 +0000 Subject: [PATCH] cmake 3.19.4 changes to find Python 3 libraries and include files When compiling on Mac Big Sur the previous (deprecated) find_package fails to find Python3 Libraries and Include files --- CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ee30d4cb..717ba67b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -391,8 +391,15 @@ add_subdirectory(renderdoc) if(ENABLE_QRENDERDOC OR ENABLE_PYRENDERDOC) # Make sure Python 3 is found set(Python_ADDITIONAL_VERSIONS 3.8 3.7 3.6 3.5 3.4) - find_package(PythonInterp 3 REQUIRED) - find_package(PythonLibs 3 REQUIRED) + 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}) + else() + find_package(PythonInterp 3 REQUIRED) + find_package(PythonLibs 3 REQUIRED) +endif() # we also need python3-config for swig 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.")