From cda071d96d174be594e037060b6c298460af3315 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov Date: Tue, 17 Sep 2024 13:46:08 +0200 Subject: [PATCH] [PL,cmake] Better linking of Python-related libs. --- Applications/ApplicationsLib/CMakeLists.txt | 4 ++-- .../PartitionMesh/CMakeLists.txt | 1 - .../Python/CMakeLists.txt | 16 +++------------- ProcessLib/CMakeLists.txt | 2 +- ProcessLib/HeatTransportBHE/CMakeLists.txt | 2 +- 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/Applications/ApplicationsLib/CMakeLists.txt b/Applications/ApplicationsLib/CMakeLists.txt index 0b1b31de32b..98181bde224 100644 --- a/Applications/ApplicationsLib/CMakeLists.txt +++ b/Applications/ApplicationsLib/CMakeLists.txt @@ -12,13 +12,14 @@ target_link_libraries( GeoLib NumLib $<$,$>:VTK::ParallelMPI> + $<$>,$>:ogs_embedded_python> PRIVATE CMakeInfoLib MathLib MeshLib MeshGeoToolsLib MeshToolsLib - pybind11::pybind11 $<$:PkgConfig::PETSC> + pybind11::module ) if(OGS_BUILD_CLI OR OGS_BUILD_UTILS OR OGS_BUILD_TESTING) @@ -46,7 +47,6 @@ target_compile_definitions( # see https://pybind11.readthedocs.io/en/stable/faq.html#someclass-declared-with-greater-visibility-than-the-type-of-its-field-someclass-member-wattributes # ~~~ if(NOT OGS_BUILD_WHEEL AND OGS_BUILD_CLI) - target_link_libraries(ApplicationsLib PRIVATE ogs_embedded_python) set_target_properties( ApplicationsLib PROPERTIES CXX_VISIBILITY_PRESET hidden ) diff --git a/Applications/Utils/ModelPreparation/PartitionMesh/CMakeLists.txt b/Applications/Utils/ModelPreparation/PartitionMesh/CMakeLists.txt index 67a4ebe663c..1d70a87a482 100644 --- a/Applications/Utils/ModelPreparation/PartitionMesh/CMakeLists.txt +++ b/Applications/Utils/ModelPreparation/PartitionMesh/CMakeLists.txt @@ -5,7 +5,6 @@ if(OGS_USE_MPI) target_link_libraries( binaryToPVTU GitInfoLib - ProcessLib MeshLib MeshToolsLib tclap diff --git a/ProcessLib/BoundaryConditionAndSourceTerm/Python/CMakeLists.txt b/ProcessLib/BoundaryConditionAndSourceTerm/Python/CMakeLists.txt index cbbdf0142a1..2e7d9451dd6 100644 --- a/ProcessLib/BoundaryConditionAndSourceTerm/Python/CMakeLists.txt +++ b/ProcessLib/BoundaryConditionAndSourceTerm/Python/CMakeLists.txt @@ -33,25 +33,15 @@ target_compile_definitions( $<$:OGS_ENABLE_ELEMENT_PYRAMID> ) -# TODO there is an ugly cyclic dependency between ProcessLib and the Python BCs -# and STs. We need to include ProcessLib's build dir such that ProcessLib's -# export header, which is autogenerated by cmake in the build dir, can be found. -target_include_directories( - ProcessLibBoundaryConditionAndSourceTermPython - PRIVATE $ -) - target_link_libraries( ProcessLibBoundaryConditionAndSourceTermPython - PUBLIC BaseLib MathLib MeshLib NumLib - $,pybind11::module,pybind11::embed> + PUBLIC BaseLib MathLib MeshLib NumLib pybind11::module ) -if(BUILD_SHARED_LIBS AND (MSVC OR APPLE)) +if(BUILD_SHARED_LIBS AND MSVC) target_link_options( ProcessLibBoundaryConditionAndSourceTermPython PRIVATE - $<$:-undefined dynamic_lookup> - $<$:/FORCE:UNRESOLVED> + /FORCE:UNRESOLVED ) endif() diff --git a/ProcessLib/CMakeLists.txt b/ProcessLib/CMakeLists.txt index 976ea7649ab..e6a88815419 100644 --- a/ProcessLib/CMakeLists.txt +++ b/ProcessLib/CMakeLists.txt @@ -55,8 +55,8 @@ target_link_libraries( NumLib Boost::boost range-v3 - $<$:ProcessLibBoundaryConditionAndSourceTermPython> $<$:petsc> + ProcessLibBoundaryConditionAndSourceTermPython PRIVATE ParameterLib GitInfoLib $<$:InSituLib> ) diff --git a/ProcessLib/HeatTransportBHE/CMakeLists.txt b/ProcessLib/HeatTransportBHE/CMakeLists.txt index 7a8f77a9128..df8a09bb3a7 100644 --- a/ProcessLib/HeatTransportBHE/CMakeLists.txt +++ b/ProcessLib/HeatTransportBHE/CMakeLists.txt @@ -8,7 +8,7 @@ ogs_add_library(HeatTransportBHE ${SOURCES}) target_link_libraries( HeatTransportBHE PUBLIC ProcessLib PRIVATE ParameterLib - $<$:pybind11::pybind11> + $<$:pybind11::module> ) target_precompile_headers(HeatTransportBHE PRIVATE [["BaseLib/Error.h"]]