Cater for missing FindPython3 in CMake version < 3.12.0
For these we need to use the old approach. At least we now produce an error if only python2 is found. Needed e.g. for Ubuntu LTS 18.04.
This commit is contained in:
parent
c98f74c206
commit
9a25b78b98
@ -152,8 +152,20 @@ endmacro (install_hook)
|
||||
# OpmnLibMain function. Here only the library dependency is implemented, the
|
||||
# bulk of the python configuration is further down in the file.
|
||||
if (OPM_ENABLE_PYTHON)
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
|
||||
set(PYTHON_LIBRARIES Python3::Python)
|
||||
# We need to be compatible with older CMake versions
|
||||
# that do not offer FindPython3
|
||||
# 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(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)
|
||||
endif()
|
||||
|
||||
if (OPM_ENABLE_EMBEDDED_PYTHON)
|
||||
list(APPEND opm-common_LIBRARIES ${PYTHON_LIBRARIES})
|
||||
|
@ -15,8 +15,12 @@ set (opm-common_DEPS
|
||||
list(APPEND opm-common_DEPS
|
||||
# various runtime library enhancements
|
||||
"Boost 1.44.0 COMPONENTS system unit_test_framework REQUIRED"
|
||||
"Python3 COMPONENTS Interpreter Development"
|
||||
"OpenMP QUIET"
|
||||
)
|
||||
|
||||
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0")
|
||||
list(APPEND opm-common_DEPS
|
||||
# Needed for the imported target Python3::Python
|
||||
"Python3 COMPONENTS Interpreter Development"
|
||||
)
|
||||
endif()
|
||||
find_package_deps(opm-common)
|
||||
|
Loading…
Reference in New Issue
Block a user