From cd780da690b6d1bf3ff98d26c7427176f99657d4 Mon Sep 17 00:00:00 2001 From: Lars Bilke <lars.bilke@ufz.de> Date: Fri, 2 Jun 2023 09:52:12 +0200 Subject: [PATCH] [Python] Compile OGSMesh into own helper lib, fixes linkage. --- Applications/Python/ogs.mesh/CMakeLists.txt | 18 +++++++++++------- .../Python/ogs.simulator/CMakeLists.txt | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Applications/Python/ogs.mesh/CMakeLists.txt b/Applications/Python/ogs.mesh/CMakeLists.txt index 4cdc635a427..5b5704a8dac 100644 --- a/Applications/Python/ogs.mesh/CMakeLists.txt +++ b/Applications/Python/ogs.mesh/CMakeLists.txt @@ -1,6 +1,12 @@ -# Create OpenGeoSys python module -# https://pybind11.readthedocs.io/en/stable/compiling.html#building-with-cmake -pybind11_add_module(mesh MODULE ogs_mesh_python_module.cpp OGSMesh.cpp) +# Helper library which provides a better view on the mesh data. This allows to +# be used by several modules, e.g. this and the simulator module. +add_library(_python_mesh STATIC OGSMesh.cpp) +target_link_libraries( + _python_mesh PUBLIC MeshLib BaseLib GitInfoLib pybind11::pybind11 +) + +# The actual Python module should only contain the binding code. +pybind11_add_module(mesh MODULE ogs_mesh_python_module.cpp) # lld linker strips out PyInit_OpenGeoSys symbol. Use standard linker. get_target_property(_link_options mesh LINK_OPTIONS) @@ -9,9 +15,7 @@ if(_link_options) set_target_properties(mesh PROPERTIES LINK_OPTIONS "${_link_options}") endif() -target_link_libraries( - mesh PRIVATE MeshLib BaseLib CMakeInfoLib GitInfoLib tclap -) +target_link_libraries(mesh PRIVATE _python_mesh) -# Install into Python module root dir (enables 'import ogs.simulator') +# Install into Python module root dir (enables 'import ogs.mesh') install(TARGETS mesh LIBRARY DESTINATION ogs) diff --git a/Applications/Python/ogs.simulator/CMakeLists.txt b/Applications/Python/ogs.simulator/CMakeLists.txt index daf04fcd5e2..c87b10ad6ea 100644 --- a/Applications/Python/ogs.simulator/CMakeLists.txt +++ b/Applications/Python/ogs.simulator/CMakeLists.txt @@ -14,6 +14,7 @@ endif() target_link_libraries( simulator PRIVATE ApplicationsLib BaseLib CMakeInfoLib GitInfoLib tclap + _python_mesh ) target_include_directories(simulator PRIVATE ../../CLI) -- GitLab