Only search for Python libs if OPM_ENABLE_EMBEDDED_PYTHON is ON.

Apparently it is not needed in the other cases.
Fixes an issue that arose from #2344 and restores the old behaviour
concerning the libraries.
This commit is contained in:
Markus Blatt
2021-03-15 10:19:10 +01:00
parent af3c825588
commit 0455c48d2f

View File

@@ -157,24 +157,28 @@ if (OPM_ENABLE_PYTHON)
# e.g. Ubuntu LTS 18.04 uses cmake 3.10
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
find_package(PythonInterp REQUIRED)
find_package(PythonLibs REQUIRED)
if (OPM_ENABLE_EMBEDDED_PYTHON)
find_package(PythonLibs REQUIRED)
list(APPEND opm-common_LIBRARIES ${PYTHON_LIBRARIES})
endif()
if(PYTHON_VERSION_MAJOR LESS 3)
message(SEND_ERROR "OPM requires version 3 of Python but only version ${PYTHON_VERSION_STRING} was found")
endif()
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
else()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
if (OPM_ENABLE_EMBEDDED_PYTHON)
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
set(PYTHON_LIBRARIES Python3::Python)
get_target_property(_lib_path Python3::Python IMPORTED_LOCATION)
set(PYTHON_LIBRARY ${_lib_path})
list(APPEND opm-common_LIBRARIES ${PYTHON_LIBRARIES})
else()
find_package(Python3 REQUIRED COMPONENTS Interpreter)
endif()
# Compatibility settings for PythonInterp and PythonLibs
# used e.g. in FindCwrap
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
set(PYTHON_LIBRARIES Python3::Python)
get_target_property(_lib_path Python3::Python IMPORTED_LOCATION)
set(PYTHON_LIBRARY ${_lib_path})
endif()
if (OPM_ENABLE_EMBEDDED_PYTHON)
list(APPEND opm-common_LIBRARIES ${PYTHON_LIBRARIES})
endif()
endif()