find_package(PythonInterp... deprecated, change to python with comp

This commit is contained in:
Christopher Lackner 2023-08-29 10:52:22 +02:00
parent 22b45dde67
commit f873de3e3b
4 changed files with 13 additions and 19 deletions

View File

@ -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)

View File

@ -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@")

View File

@ -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
)

View File

@ -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})