From f7ed9dd371f9387ed5b715a4f316eea9f85de48d Mon Sep 17 00:00:00 2001 From: Yegor Yefremov Date: Mon, 23 Jun 2025 14:44:13 +0200 Subject: [PATCH] python/CMakeLists.txt: rework Python development files detection Both the FindPythonInterp and FindPythonLibs modules were removed. Use find_package(Python3 COMPONENTS Interpreter Development) to find both the interpreter and the library. The old modules have been deprecated since CMake 3.12. Resolves the following warning: CMake Warning (dev) at python/CMakeLists.txt:11 (find_package): Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules are removed. Run "cmake --help-policy CMP0148" for policy details. Use the cmake_policy command to set the policy and suppress this warning. --- python/CMakeLists.txt | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index d496c3f..d312fae 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -8,12 +8,11 @@ else () set(SWIG_FOUND TRUE) endif () endif () -find_package(PythonInterp REQUIRED) -find_package(PythonLibs REQUIRED) +find_package(Python3 COMPONENTS Interpreter Development) include(UseSWIG) include_directories(BEFORE ${PROJECT_SOURCE_DIR}/src) -include_directories(${PYTHON_INCLUDE_DIRS}) +include_directories(${Python3_INCLUDE_DIRS}) link_directories(${CMAKE_CURRENT_BINARY_DIR}/../src) if (DOCUMENTATION) @@ -32,7 +31,7 @@ endif () set_target_properties(pyftdi1 PROPERTIES NO_SONAME ON) -execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print( sysconfig.get_path( 'platlib', vars={'platbase': '${CMAKE_INSTALL_PREFIX}'} ) )" +execute_process(COMMAND ${Python3_EXECUTABLE} -c "import sysconfig; print( sysconfig.get_path( 'platlib', vars={'platbase': '${CMAKE_INSTALL_PREFIX}'} ) )" OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -55,7 +54,7 @@ if (DOCUMENTATION) # generate .i from doxygen .xml add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ftdi1_doc.i - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n ${PROJECT_BINARY_DIR}/doc/xml/ftdi_8c.xml ${CMAKE_CURRENT_BINARY_DIR}/ftdi1_doc.i COMMENT "Generating ftdi1_doc.i from ftdi_8c.xml" -- 1.7.1