ogs_add_library(
    ProcessLibBoundaryConditionAndSourceTermPython
    PythonBoundaryCondition.cpp
    PythonBoundaryCondition.h
    PythonBoundaryConditionLocalAssemblerInterface.h
    PythonBoundaryConditionLocalAssembler.h
    PythonBoundaryConditionPythonSideInterface.h
    BHEInflowPythonBoundaryCondition.h
    BHEInflowPythonBoundaryConditionPythonSideInterface.h
    CreatePythonSourceTerm.cpp
    CreatePythonSourceTerm.h
    PythonSourceTerm.cpp
    PythonSourceTerm.h
    PythonSourceTermLocalAssembler.h
    PythonSourceTermPythonSideInterface.h
    Utils/BcAndStLocalAssemblerImpl.h
    Utils/BcOrStData.h
    Utils/CollectAndInterpolateNodalDof.cpp
    Utils/CollectAndInterpolateNodalDof.h
    Utils/CreateLocalAssemblers.h
    Utils/LocalAssemblerFactoryPython.h
    Utils/NsAndWeight.h
)

target_compile_definitions(
    ProcessLibBoundaryConditionAndSourceTermPython
    PUBLIC # Enabled elements
           OGS_MAX_ELEMENT_DIM=${OGS_MAX_ELEMENT_DIM}
           OGS_MAX_ELEMENT_ORDER=${OGS_MAX_ELEMENT_ORDER}
           $<$<BOOL:${OGS_ENABLE_ELEMENT_SIMPLEX}>:OGS_ENABLE_ELEMENT_SIMPLEX>
           $<$<BOOL:${OGS_ENABLE_ELEMENT_CUBOID}>:OGS_ENABLE_ELEMENT_CUBOID>
           $<$<BOOL:${OGS_ENABLE_ELEMENT_PRISM}>:OGS_ENABLE_ELEMENT_PRISM>
           $<$<BOOL:${OGS_ENABLE_ELEMENT_PYRAMID}>: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_PROPERTY:ProcessLib,BINARY_DIR>
)

target_link_libraries(
    ProcessLibBoundaryConditionAndSourceTermPython
    PUBLIC BaseLib MathLib MeshLib NumLib
           $<IF:$<BOOL:${OGS_BUILD_WHEEL}>,pybind11::module,pybind11::embed>
)

if(OGS_BUILD_WHEEL OR (APPLE AND OGS_USE_PETSC))
    target_link_options(
        ProcessLibBoundaryConditionAndSourceTermPython PRIVATE
        $<$<CXX_COMPILER_ID:AppleClang>:-undefined dynamic_lookup>
        $<$<CXX_COMPILER_ID:MSVC>:/FORCE:UNRESOLVED>
    )
endif()

# For the embedded Python module
ogs_add_library(
    ProcessLibBoundaryConditionAndSourceTermPythonModule
    PythonBoundaryConditionModule.cpp
    PythonBoundaryConditionModule.h
    BHEInflowPythonBoundaryConditionModule.cpp
    BHEInflowPythonBoundaryConditionModule.h
    PythonSourceTermModule.cpp
    PythonSourceTermModule.h
)

target_link_libraries(
    ProcessLibBoundaryConditionAndSourceTermPythonModule
    PUBLIC ProcessLibBoundaryConditionAndSourceTermPython
)
