Skip to content
Snippets Groups Projects
Commit 1d988d29 authored by Lars Bilke's avatar Lars Bilke Committed by Dmitri Naumov
Browse files

[CMake] Explicitly use Python3 everywhere.

parent d5184523
No related branches found
No related tags found
No related merge requests found
...@@ -255,7 +255,7 @@ option(OGS_CHECK_HEADER_COMPILATION "Check header for standalone compilation." ...@@ -255,7 +255,7 @@ option(OGS_CHECK_HEADER_COMPILATION "Check header for standalone compilation."
OFF) OFF)
option(OGS_USE_PYTHON "Interface with Python" OFF) option(OGS_USE_PYTHON "Interface with Python" OFF)
if(OGS_USE_PYTHON AND NOT Python_FOUND) if(OGS_USE_PYTHON AND NOT Python3_FOUND)
message(FATAL_ERROR "Python not found but required for OGS_USE_PYTHON=ON!") message(FATAL_ERROR "Python not found but required for OGS_USE_PYTHON=ON!")
endif() endif()
...@@ -356,10 +356,10 @@ add_subdirectory(MeshLib) ...@@ -356,10 +356,10 @@ add_subdirectory(MeshLib)
add_subdirectory(MeshGeoToolsLib) add_subdirectory(MeshGeoToolsLib)
add_subdirectory(NumLib) add_subdirectory(NumLib)
if (OGS_BUILD_PROCESS_ComponentTransport if(OGS_BUILD_PROCESS_ComponentTransport
OR OGS_BUILD_PROCESS_RichardsComponentTransport OR OGS_BUILD_PROCESS_RichardsComponentTransport
OR OGS_BUILD_PROCESS_RichardsComponentTransport OR OGS_BUILD_PROCESS_RichardsComponentTransport
OR OGS_BUILD_PROCESS_HeatTransportBHE) OR OGS_BUILD_PROCESS_HeatTransportBHE)
add_subdirectory(ChemistryLib) add_subdirectory(ChemistryLib)
endif() endif()
......
add_library(ProcessLibBoundaryConditionPython add_library(ProcessLibBoundaryConditionPython
PythonBoundaryCondition.cpp PythonBoundaryCondition.h PythonBoundaryCondition.cpp
PythonBoundaryCondition.h
PythonBoundaryConditionLocalAssembler.h PythonBoundaryConditionLocalAssembler.h
PythonBoundaryConditionPythonSideInterface.h PythonBoundaryConditionPythonSideInterface.h
BHEInflowPythonBoundaryCondition.h BHEInflowPythonBoundaryCondition.h
...@@ -18,13 +19,14 @@ target_link_libraries(ProcessLibBoundaryConditionPython ...@@ -18,13 +19,14 @@ target_link_libraries(ProcessLibBoundaryConditionPython
MeshLib MeshLib
NumLib NumLib
logog logog
${Python_LIBRARIES} ${Python3_LIBRARIES}
PRIVATE pybind11::pybind11) PRIVATE pybind11::pybind11)
# For the embedded Python module # For the embedded Python module
add_library(ProcessLibBoundaryConditionPythonModule add_library(ProcessLibBoundaryConditionPythonModule
PythonBoundaryConditionModule.cpp PythonBoundaryConditionModule.h PythonBoundaryConditionModule.cpp PythonBoundaryConditionModule.h
BHEInflowPythonBoundaryConditionModule.cpp BHEInflowPythonBoundaryConditionModule.h) BHEInflowPythonBoundaryConditionModule.cpp
BHEInflowPythonBoundaryConditionModule.h)
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)
install(TARGETS ProcessLibBoundaryConditionPythonModule install(TARGETS ProcessLibBoundaryConditionPythonModule
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
......
...@@ -18,7 +18,7 @@ target_link_libraries(ProcessLibSourceTermPython ...@@ -18,7 +18,7 @@ target_link_libraries(ProcessLibSourceTermPython
MeshLib MeshLib
NumLib NumLib
logog logog
${Python_LIBRARIES} ${Python3_LIBRARIES}
PRIVATE pybind11::pybind11) PRIVATE pybind11::pybind11)
# For the embedded Python module # For the embedded Python module
......
...@@ -67,10 +67,10 @@ endif() ...@@ -67,10 +67,10 @@ endif()
if(OGS_USE_PYTHON) if(OGS_USE_PYTHON)
# pybind11 uses old CMake find functionality, pass variables to use # pybind11 uses old CMake find functionality, pass variables to use
# the same Python installation. # the same Python installation.
find_package(Python COMPONENTS Interpreter Development REQUIRED) set(PYTHON_INCLUDE_DIR ${Python3_INCLUDE_DIRS} CACHE STRING "" FORCE)
set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIRS} CACHE STRING "" FORCE) set(PYTHON_LIBRARIES ${Python3_LIBRARIES} CACHE STRING "" FORCE)
set(PYTHON_LIBRARIES ${Python_LIBRARIES} CACHE STRING "" FORCE) set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE} CACHE FILEPATH "" FORCE)
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE} CACHE FILEPATH "" FORCE) set(PYBIND11_PYTHON_VERSION ${Python3_VERSION})
add_subdirectory(pybind11) add_subdirectory(pybind11)
...@@ -89,9 +89,9 @@ if(OGS_USE_PYTHON) ...@@ -89,9 +89,9 @@ if(OGS_USE_PYTHON)
endif() endif()
include(${VTK_MODULES_DIR}/vtkPython.cmake) include(${VTK_MODULES_DIR}/vtkPython.cmake)
if (NOT "${vtkPython_LIBRARIES}" STREQUAL "${Python_LIBRARIES}") if (NOT "${vtkPython_LIBRARIES}" STREQUAL "${Python3_LIBRARIES}")
message(SEND_ERROR "Mismatch between VTK's and OpenGeoSys' Python " message(SEND_ERROR "Mismatch between VTK's and OpenGeoSys' Python "
"libraries: ${vtkPython_LIBRARIES} vs. ${Python_LIBRARIES}. " "libraries: ${vtkPython_LIBRARIES} vs. ${Python3_LIBRARIES}. "
"This will lead to compilation or linking errors. " "This will lead to compilation or linking errors. "
"You can fix this error by using the same Python version for " "You can fix this error by using the same Python version for "
"OpenGeoSys as VTK is built with.") "OpenGeoSys as VTK is built with.")
......
...@@ -22,7 +22,7 @@ else() ...@@ -22,7 +22,7 @@ else()
message(STATUS "No lcov coverage report generated because lcov or genhtml was not found.") message(STATUS "No lcov coverage report generated because lcov or genhtml was not found.")
endif() endif()
if(Python_EXECUTABLE) if(Python3_EXECUTABLE)
setup_target_for_coverage_gcovr_xml( setup_target_for_coverage_gcovr_xml(
NAME testrunner_coverage_cobertura NAME testrunner_coverage_cobertura
EXECUTABLE ${CMAKE_COMMAND} --build . --target tests EXECUTABLE ${CMAKE_COMMAND} --build . --target tests
......
...@@ -50,7 +50,7 @@ doxygen_add_docs(doc ...@@ -50,7 +50,7 @@ doxygen_add_docs(doc
${PROJECT_SOURCE_DIR}/ ${PROJECT_SOURCE_DIR}/
${PROJECT_BINARY_DIR}/DocAux/dox) ${PROJECT_BINARY_DIR}/DocAux/dox)
if (BASH_TOOL_PATH AND Python_EXECUTABLE) if (BASH_TOOL_PATH AND Python3_EXECUTABLE)
set(doc_use_external_tools TRUE) set(doc_use_external_tools TRUE)
else() else()
set(doc_use_external_tools FALSE) set(doc_use_external_tools FALSE)
......
...@@ -9,7 +9,11 @@ find_program(GPROF_PATH gprof DOC "GNU profiler gprof" QUIET) ...@@ -9,7 +9,11 @@ find_program(GPROF_PATH gprof DOC "GNU profiler gprof" QUIET)
find_program(CPPCHECK_TOOL_PATH cppcheck) find_program(CPPCHECK_TOOL_PATH cppcheck)
find_package(Python COMPONENTS Interpreter Development) if(OGS_USE_PYTHON)
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
else()
find_package(Python3 COMPONENTS Interpreter)
endif()
# Find bash itself ... # Find bash itself ...
find_program(BASH_TOOL_PATH bash find_program(BASH_TOOL_PATH bash
......
...@@ -112,7 +112,7 @@ endif() ...@@ -112,7 +112,7 @@ endif()
if(OGS_USE_PYTHON) if(OGS_USE_PYTHON)
if(WIN32) if(WIN32)
file(GLOB PYTHON_RUNTIME_LIBS "${Python_RUNTIME_LIBRARY_DIRS}/*.dll") file(GLOB PYTHON_RUNTIME_LIBS "${Python3_RUNTIME_LIBRARY_DIRS}/*.dll")
message(STATUS "Install Python: ${PYTHON_RUNTIME_LIBS}") message(STATUS "Install Python: ${PYTHON_RUNTIME_LIBS}")
install(FILES ${PYTHON_RUNTIME_LIBS} DESTINATION bin) install(FILES ${PYTHON_RUNTIME_LIBS} DESTINATION bin)
else() else()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment