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: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Cristian Adam
2022-01-18 18:45:37 +01:00
parent 657cef6109
commit e9f3f8cc64
3 changed files with 27 additions and 3 deletions

View File

@@ -138,7 +138,14 @@ endif()
add_subdirectory(doc) 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) if (NOT PYTHONINTERP_FOUND)
message("No python interpreter found, skipping \"Dependencies\" install component.") message("No python interpreter found, skipping \"Dependencies\" install component.")
else() else()

View File

@@ -1,7 +1,15 @@
set(languages cs da de fr hr ja pl ru sl uk zh_CN zh_TW) 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! 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(json_wizards_h "")
set(custom_wizards_h "") set(custom_wizards_h "")

View File

@@ -60,7 +60,16 @@ add_qtc_library(qtcreatorcdbext
qtc_library_enabled(_library_enabled qtcreatorcdbext) qtc_library_enabled(_library_enabled qtcreatorcdbext)
if (_library_enabled) 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}) if (NOT ${PYTHONLIBS_FOUND})
message(WARNING "PythonLibs (at least version 3.8) not found. qtcreatorcdbext will be built without Python support.") message(WARNING "PythonLibs (at least version 3.8) not found. qtcreatorcdbext will be built without Python support.")
return() return()