Set parameters to FindPython3 depending on CMake version

This commit is contained in:
Matthias Hochsteger 2023-08-30 20:25:11 +02:00
parent 24cbbe588e
commit 80098c1e93
2 changed files with 10 additions and 2 deletions

View File

@ -85,7 +85,11 @@ endif()
set(NG_INSTALL_SUFFIX netgen CACHE STRING "Suffix appended to install directories (project name)")
if(USE_PYTHON)
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.18)
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
else()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
endif()
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)

View File

@ -181,7 +181,11 @@ if (USE_PYTHON)
else( PYBIND_INCLUDE_DIR )
message(FATAL_ERROR "Could NOT find pybind11!")
endif( PYBIND_INCLUDE_DIR )
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.18)
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
else()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
endif()
set_vars(NETGEN_CMAKE_ARGS
Python3_INCLUDE_DIRS