fixed: conditionally use Development.XXX in python find module

the split into Development.Module and Development.Embed was is introduced in cmake 3.18
This commit is contained in:
Arne Morten Kvarving 2023-05-02 08:57:39 +02:00
parent acc1a5145a
commit d903c61166

View File

@ -219,9 +219,17 @@ if (OPM_ENABLE_PYTHON)
# We always need to search for Development as we use
# pybind11_add_module even if don't embed Python
if (NOT OPM_ENABLE_EMBEDDED_PYTHON)
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
if(${CMAKE_VERSION} VERSION_LESS "3.18.0")
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
else()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
endif()
else()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Embed Development.Module)
if(${CMAKE_VERSION} VERSION_LESS "3.18.0")
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
else()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Embed Development.Module)
endif()
get_target_property(_lib_path Python3::Python IMPORTED_LOCATION)
set(PYTHON_LIBRARY ${_lib_path})
set(PYTHON_LIBRARIES {PYTHON_LIBRARY})