diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index e4c493583ab4d477f3e26f270a3e5766f58f957a..96e8b4f6f5ccd496dc470ec50868164a10660b27 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -48,6 +48,13 @@ if(OGS_BUILD_SWMM) endif() if(OGS_USE_PYTHON) + # pybind11 uses old CMake find functionality, pass variables to use + # the same Python installation. + find_package(Python COMPONENTS Interpreter Development REQUIRED) + set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIRS} CACHE STRING "" FORCE) + set(PYTHON_LIBRARIES ${Python_LIBRARIES} CACHE STRING "" FORCE) + set(PYTHON_EXECUTABLE ${Python_EXECUTABLE} CACHE FILEPATH "" FORCE) + add_subdirectory(pybind11) function(check_python_version_compatibility) @@ -56,19 +63,18 @@ if(OGS_USE_PYTHON) endif() include(${VTK_DIR}/VTKConfig.cmake) - if(NOT ${VTK_WRAP_PYTHON}) return() endif() + if(NOT EXISTS ${VTK_MODULES_DIR}/vtkPython.cmake) return() endif() include(${VTK_MODULES_DIR}/vtkPython.cmake) - - if (NOT "${vtkPython_LIBRARIES}" STREQUAL "${PYTHON_LIBRARIES}") + if (NOT "${vtkPython_LIBRARIES}" STREQUAL "${Python_LIBRARIES}") message(SEND_ERROR "Mismatch between VTK's and OpenGeoSys' Python " - "libraries: ${vtkPython_LIBRARIES} vs. ${PYTHON_LIBRARIES}. " + "libraries: ${vtkPython_LIBRARIES} vs. ${Python_LIBRARIES}. " "This will lead to compilation or linking errors. " "You can fix this error by using the same Python version for " "OpenGeoSys as VTK is built with.") @@ -76,6 +82,7 @@ if(OGS_USE_PYTHON) endfunction() check_python_version_compatibility() + endif() if(OGS_BUILD_UTILS)