Skip to content
Snippets Groups Projects
Verified Commit e5cee8dc authored by Lars Bilke's avatar Lars Bilke
Browse files

[cm] petsc imported target.

Simplifies handling in CMake. Just link to petsc-target.
parent b3155fd3
No related branches found
No related tags found
No related merge requests found
......@@ -16,16 +16,14 @@ target_link_libraries(
ProcessLib
spdlog::spdlog
$<$<BOOL:${OGS_USE_PYTHON}>:pybind11::pybind11>
$<$<BOOL:${OGS_USE_PETSC}>:petsc>
)
if(OGS_USE_LIS)
target_include_directories(ApplicationsLib PUBLIC ${LIS_INCLUDE_DIR})
endif()
target_compile_definitions(
ApplicationsLib PUBLIC $<$<BOOL:${USE_LIS}>:USE_LIS>
$<$<BOOL:${OGS_USE_PETSC}>:USE_PETSC>
)
target_compile_definitions(ApplicationsLib PUBLIC $<$<BOOL:${USE_LIS}>:USE_LIS>)
# Set cpp definitions if the cmake option is enabled for the given process.
foreach(process ${_processes_list})
......
......@@ -61,13 +61,11 @@ target_link_libraries(
$<$<TARGET_EXISTS:ogs_embedded_python>:ogs_embedded_python>
$<$<TARGET_EXISTS:MPI::MPI_CXX>:MPI::MPI_CXX>
$<$<TARGET_EXISTS:InSituLib>:InSituLib>
$<$<TARGET_EXISTS:petsc>:petsc>
tclap
)
target_compile_definitions(
ogs PRIVATE $<$<BOOL:${USE_INSITU}>:USE_INSITU>
$<$<BOOL:${OGS_USE_PETSC}>:USE_PETSC>
)
target_compile_definitions(ogs PRIVATE $<$<BOOL:${USE_INSITU}>:USE_INSITU>)
# ---- Tests ----
add_test(NAME ogs_no_args COMMAND ogs)
......
......@@ -16,10 +16,10 @@ target_link_libraries(
$<$<BOOL:${MSVC}>:WinMM> # needed for timeGetTime
$<$<BOOL:${OGS_BUILD_GUI}>:Qt5::Xml>
$<$<BOOL:${OGS_BUILD_GUI}>:Qt5::XmlPatterns>
$<$<BOOL:${OGS_USE_PETSC}>:petsc>
PRIVATE xmlpatch
)
target_compile_definitions(
BaseLib PUBLIC $<$<BOOL:${OGS_FATAL_ABORT}>:OGS_FATAL_ABORT>
PRIVATE $<$<BOOL:${OGS_USE_PETSC}>:USE_PETSC>
)
......@@ -22,10 +22,6 @@ endif()
# Create the library
ogs_add_library(MathLib ${SOURCES})
target_include_directories(
MathLib PUBLIC ${CMAKE_CURRENT_BINARY_DIR}
$<$<BOOL:${OGS_USE_PETSC}>:${PETSC_INCLUDE_DIRS}>
)
set_target_properties(MathLib PROPERTIES LINKER_LANGUAGE CXX)
......@@ -36,13 +32,11 @@ target_link_libraries(
$<$<TARGET_EXISTS:LAPACK::LAPACK>:LAPACK::LAPACK>
$<$<BOOL:${OGS_USE_LIS}>:${LIS_LIBRARIES}>
$<$<BOOL:${OGS_USE_CVODE}>:CVODE::CVODE>
$<$<BOOL:${OGS_USE_PETSC}>:petsc>
Eigen3::Eigen
PRIVATE spdlog::spdlog
)
if(OGS_USE_PETSC)
target_link_libraries(MathLib PUBLIC ${PETSC_LIBRARIES})
endif()
if(OGS_USE_LIS)
target_include_directories(MathLib PUBLIC ${LIS_INCLUDE_DIR})
endif()
......@@ -55,7 +49,6 @@ target_compile_definitions(
MathLib
PUBLIC
$<$<BOOL:${USE_LIS}>:USE_LIS>
$<$<BOOL:${OGS_USE_PETSC}>:USE_PETSC>
$<$<BOOL:${OGS_USE_CVODE}>:CVODE_FOUND>
$<$<BOOL:${EIGEN_NO_DEBUG}>:EIGEN_NO_DEBUG>
$<$<BOOL:${EIGEN_DONT_VECTORIZE}>:EIGEN_DONT_VECTORIZE>
......
......@@ -41,6 +41,7 @@ target_link_libraries(
${VTK_LIBRARIES}
$<$<TARGET_EXISTS:OgsXdmf>:OgsXdmf>
$<$<TARGET_EXISTS:MPI::MPI_CXX>:MPI::MPI_CXX>
$<$<TARGET_EXISTS:petsc>:petsc>
PRIVATE spdlog::spdlog
)
......@@ -49,7 +50,6 @@ target_include_directories(MeshLib PUBLIC ${VTK_INCLUDE_DIRS})
target_compile_definitions(
MeshLib
PUBLIC
$<$<BOOL:${OGS_USE_PETSC}>:USE_PETSC>
$<$<AND:$<BOOL:$ENV{VTK_USE_64BIT_IDS}>,$<NOT:$<BOOL:VTK_ADDED>>>:VTK_USE_64BIT_IDS>
PRIVATE $<$<BOOL:${OGS_USE_XDMF}>:OGS_USE_XDMF>
)
......@@ -15,12 +15,9 @@ append_source_files(SOURCES Extrapolation)
# Create the library
ogs_add_library(NumLib ${SOURCES})
if(OGS_USE_PETSC)
target_compile_definitions(NumLib PUBLIC USE_PETSC)
endif()
set_target_properties(NumLib PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(
NumLib PUBLIC BaseLib GeoLib MathLib MeshLib PRIVATE MeshGeoToolsLib
spdlog::spdlog
NumLib PUBLIC BaseLib GeoLib MathLib MeshLib $<$<TARGET_EXISTS:petsc>:petsc>
PRIVATE MeshGeoToolsLib spdlog::spdlog
)
......@@ -33,6 +33,7 @@ target_link_libraries(
NumLib
$<$<TARGET_EXISTS:ProcessLibBoundaryConditionPython>:ProcessLibBoundaryConditionPython>
$<$<TARGET_EXISTS:ProcessLibSourceTermPython>:ProcessLibSourceTermPython>
$<$<TARGET_EXISTS:petsc>:petsc>
nlohmann_json
PRIVATE ParameterLib GitInfoLib spdlog::spdlog
$<$<TARGET_EXISTS:InSituLib>:InSituLib>
......@@ -40,8 +41,7 @@ target_link_libraries(
target_compile_definitions(
ProcessLib
PUBLIC $<$<BOOL:${OGS_USE_PETSC}>:USE_PETSC>
$<$<BOOL:${OGS_USE_XDMF}>:OGS_USE_XDMF>
PUBLIC $<$<BOOL:${OGS_USE_XDMF}>:OGS_USE_XDMF>
# Enabled elements
OGS_MAX_ELEMENT_DIM=${OGS_MAX_ELEMENT_DIM}
OGS_MAX_ELEMENT_ORDER=${OGS_MAX_ELEMENT_ORDER}
......
......@@ -80,12 +80,9 @@ target_link_libraries(
$<$<TARGET_EXISTS:MPI::MPI_CXX>:MPI::MPI_CXX>
$<$<TARGET_EXISTS:SwmmInterface>:SwmmInterface>
$<$<TARGET_EXISTS:InSituLib>:InSituLib>
$<$<TARGET_EXISTS:petsc>:petsc>
)
if(OGS_USE_PETSC)
target_link_libraries(testrunner PRIVATE ${PETSC_LIBRARIES})
endif()
if(OGS_BUILD_GUI)
target_compile_definitions(testrunner PUBLIC OGS_BUILD_GUI)
target_link_libraries(
......
......@@ -133,7 +133,10 @@ if(OGS_USE_PETSC)
find_package(PETSc ${ogs.minimum_version.petsc} REQUIRED)
include_directories(SYSTEM ${PETSC_INCLUDES})
add_library(petsc SHARED IMPORTED)
target_include_directories(petsc INTERFACE ${PETSC_INCLUDES})
set_target_properties(petsc PROPERTIES IMPORTED_LOCATION ${PETSC_LIBRARIES})
target_compile_definitions(petsc INTERFACE USE_PETSC)
endif()
# Check MPI package
......
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