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

[cmake] Find PETSc via PkgConfig.

parent 4f2b2b78
No related branches found
No related tags found
No related merge requests found
......@@ -142,7 +142,8 @@ if(OGS_USE_PETSC)
if(EXISTS ${_petsc_source_file})
set(_petsc_source URL ${_petsc_source_file})
elseif(NOT (OGS_PETSC_CONFIG_OPTIONS OR OGS_BUILD_PETSC))
find_package(PETSc ${ogs.minimum_version.petsc})
find_package(PkgConfig REQUIRED)
pkg_search_module(PETSC REQUIRED PETSc)
endif()
if(NOT PETSC_FOUND)
......@@ -176,12 +177,18 @@ if(OGS_USE_PETSC)
endif()
add_library(petsc SHARED IMPORTED)
target_include_directories(petsc INTERFACE ${PETSC_INCLUDES})
# Get first petsc lib as import location
list(GET PETSC_LIBRARIES 0 _first_petsc_lib)
set_target_properties(
petsc PROPERTIES IMPORTED_LOCATION ${_first_petsc_lib}
)
target_include_directories(petsc INTERFACE ${PETSC_INCLUDES} ${PETSC_INCLUDE_DIRS})
if("PETSc" IN_LIST _EXT_LIBS)
# Get first petsc lib as import location
list(GET PETSC_LIBRARIES 0 _first_petsc_lib)
set_target_properties(
petsc PROPERTIES IMPORTED_LOCATION ${_first_petsc_lib}
)
else()
set_target_properties(
petsc PROPERTIES IMPORTED_LOCATION ${pkgcfg_lib_PETSC_petsc}
)
endif()
target_compile_definitions(petsc INTERFACE USE_PETSC)
endif()
......
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