From e9f3f8cc641a773078ca17c5110587d5c3b717f7 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Tue, 18 Jan 2022 18:45:37 +0100 Subject: [PATCH] CMake: Use newer FindPython3 module for CMake version greater than 3.12 FindPythonInterp and FindPythonLibs are deprecated since CMake 3.12. Fixes: QTCREATORBUG-26727 Change-Id: I53400d49ef6888bbeabb063a873c494b11d27e15 Reviewed-by: Reviewed-by: Eike Ziller Reviewed-by: Qt CI Bot --- CMakeLists.txt | 9 ++++++++- share/qtcreator/translations/CMakeLists.txt | 10 +++++++++- src/libs/qtcreatorcdbext/CMakeLists.txt | 11 ++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44ae75f0fc7..b01bc8f530b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,7 +138,14 @@ endif() add_subdirectory(doc) -find_package(PythonInterp) +# TODO: Remove when cmake_minimum_required greater than 3.12 +if (CMAKE_VERSION VERSION_GREATER 3.12) + find_package(Python3 COMPONENTS Interpreter) + set(PYTHONINTERP_FOUND ${Python3_Interpreter_FOUND}) + set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) +else() + find_package(PythonInterp) +endif() if (NOT PYTHONINTERP_FOUND) message("No python interpreter found, skipping \"Dependencies\" install component.") else() diff --git a/share/qtcreator/translations/CMakeLists.txt b/share/qtcreator/translations/CMakeLists.txt index d8ade110bc1..648f885b771 100644 --- a/share/qtcreator/translations/CMakeLists.txt +++ b/share/qtcreator/translations/CMakeLists.txt @@ -1,7 +1,15 @@ set(languages cs da de fr hr ja pl ru sl uk zh_CN zh_TW) set(bad_languages hu) # Fix these before including them in languages! -find_package(PythonInterp) +# TODO: Remove when cmake_minimum_required greater than 3.12 +if (CMAKE_VERSION VERSION_GREATER 3.12) + find_package(Python3 COMPONENTS Interpreter) + set(PYTHONINTERP_FOUND ${Python3_Interpreter_FOUND}) + set(PYTHON_VERSION_STRING ${Python3_VERSION}) + set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) +else() + find_package(PythonInterp) +endif() set(json_wizards_h "") set(custom_wizards_h "") diff --git a/src/libs/qtcreatorcdbext/CMakeLists.txt b/src/libs/qtcreatorcdbext/CMakeLists.txt index 22808c284dd..5b03103bc88 100644 --- a/src/libs/qtcreatorcdbext/CMakeLists.txt +++ b/src/libs/qtcreatorcdbext/CMakeLists.txt @@ -60,7 +60,16 @@ add_qtc_library(qtcreatorcdbext qtc_library_enabled(_library_enabled qtcreatorcdbext) if (_library_enabled) - find_package(PythonLibs 3.8) + # TODO: Remove when cmake_minimum_required greater than 3.12 + if (CMAKE_VERSION VERSION_GREATER 3.12) + find_package(Python3 3.8 COMPONENTS Development) + set(PYTHONLIBS_FOUND ${Python3_Development_FOUND}) + set(PYTHON_LIBRARIES ${Python3_LIBRARIES}) + set(PYTHON_INCLUDE_DIR ${Python3_INCLUDE_DIRS}) + else() + find_package(PythonLibs 3.8) + endif() + if (NOT ${PYTHONLIBS_FOUND}) message(WARNING "PythonLibs (at least version 3.8) not found. qtcreatorcdbext will be built without Python support.") return()