From f873de3e3b8d46eac131033829100f4f0a63162f Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Tue, 29 Aug 2023 10:52:22 +0200 Subject: [PATCH] find_package(PythonInterp... deprecated, change to python with comp --- CMakeLists.txt | 13 +++++-------- cmake/NetgenConfig.cmake.in | 4 ++-- cmake/SuperBuild.cmake | 13 +++++-------- ng/CMakeLists.txt | 2 +- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21edc576..80f47e1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,12 +85,9 @@ endif() set(NG_INSTALL_SUFFIX netgen CACHE STRING "Suffix appended to install directories (project name)") if(USE_PYTHON) - find_package(PythonInterp 3 REQUIRED) - if(NOT BUILD_FOR_CONDA) - find_package(PythonLibs 3 REQUIRED) - endif() + find_package(Python3 REQUIRED COMPONENTS Interpreter Development) - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1,0,''))" OUTPUT_VARIABLE PYTHON_PACKAGES_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${Python3_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1,0,''))" OUTPUT_VARIABLE PYTHON_PACKAGES_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) file(TO_CMAKE_PATH ${PYTHON_PACKAGES_INSTALL_DIR} PYTHON_PACKAGES_INSTALL_DIR) endif(USE_PYTHON) @@ -316,11 +313,11 @@ if (USE_PYTHON) add_subdirectory(external_dependencies/pybind11) endif() - target_include_directories(netgen_python INTERFACE ${pybind11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS}) - target_include_directories(nglib PRIVATE ${pybind11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS}) + target_include_directories(netgen_python INTERFACE ${pybind11_INCLUDE_DIR} ${Python3_INCLUDE_DIRS}) + target_include_directories(nglib PRIVATE ${pybind11_INCLUDE_DIR} ${Python3_INCLUDE_DIRS}) if(NOT ${BUILD_FOR_CONDA} OR WIN32) # Don't link python libraries in conda environments - target_link_libraries(netgen_python INTERFACE ${PYTHON_LIBRARIES}) + target_link_libraries(netgen_python INTERFACE ${Python3_LIBRARIES}) endif() if(NG_INSTALL_PYBIND) diff --git a/cmake/NetgenConfig.cmake.in b/cmake/NetgenConfig.cmake.in index ddb8850b..f58d8778 100644 --- a/cmake/NetgenConfig.cmake.in +++ b/cmake/NetgenConfig.cmake.in @@ -39,8 +39,8 @@ set(NETGEN_OCC_LIBRARIES "@OCC_LIBRARIES@") set(NETGEN_OCC_LIBRARY_DIR "@OpenCASCADE_LIBRARY_DIR@") set(NETGEN_OPENGL_LIBRARIES "@OPENGL_LIBRARIES@") set(NETGEN_PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@") -set(NETGEN_PYTHON_INCLUDE_DIRS "@PYTHON_INCLUDE_DIRS@") -set(NETGEN_PYTHON_LIBRARIES "@PYTHON_LIBRARIES@") +set(NETGEN_PYTHON_INCLUDE_DIRS "@Python3_INCLUDE_DIRS@") +set(NETGEN_PYTHON_LIBRARIES "@Python3_LIBRARIES@") set(NETGEN_TCL_INCLUDE_PATH "@TCL_INCLUDE_PATH@") set(NETGEN_TCL_LIBRARY "@TCL_STUB_LIBRARY@") set(NETGEN_TK_DND_LIBRARY "@TK_DND_LIBRARY@") diff --git a/cmake/SuperBuild.cmake b/cmake/SuperBuild.cmake index 091b2477..8c1c0a69 100644 --- a/cmake/SuperBuild.cmake +++ b/cmake/SuperBuild.cmake @@ -181,16 +181,13 @@ if (USE_PYTHON) else( PYBIND_INCLUDE_DIR ) message(FATAL_ERROR "Could NOT find pybind11!") endif( PYBIND_INCLUDE_DIR ) - find_package(PythonInterp 3 REQUIRED) - if(NOT BUILD_FOR_CONDA) - find_package(PythonLibs 3 REQUIRED) - endif() + find_package(Python3 REQUIRED COMPONENTS Interpreter Development) set_vars(NETGEN_CMAKE_ARGS - PYTHON_INCLUDE_DIRS - PYTHON_LIBRARIES - PYTHON_EXECUTABLE - PYTHON_VERSION + Python3_INCLUDE_DIRS + Python3_LIBRARIES + Python3_EXECUTABLE + Python3_VERSION PYBIND_INCLUDE_DIR NG_INSTALL_PYBIND ) diff --git a/ng/CMakeLists.txt b/ng/CMakeLists.txt index 3ad3d8be..710a780c 100644 --- a/ng/CMakeLists.txt +++ b/ng/CMakeLists.txt @@ -28,7 +28,7 @@ if(USE_GUI) if(APPLE) set_target_properties(netgen PROPERTIES OUTPUT_NAME netgen) endif(APPLE) - target_link_libraries( netgen ${PYTHON_LIBRARIES} ${TCL_LIBRARY} ${TK_LIBRARY}) + target_link_libraries( netgen ${Python3_LIBRARIES} ${TCL_LIBRARY} ${TK_LIBRARY}) endif(NOT BUILD_FOR_CONDA) install(TARGETS nggui ${NG_INSTALL_DIR})