From 19f85b39592cf3cc1f15cd976c649fb9a6cfcc21 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Fri, 23 Dec 2022 10:31:12 +0100 Subject: [PATCH] Also search for Alberta with pkgconfig to be DUNE compliant If OPM modules are used as DUNE modules then CMake otherwise complains about missing targets: ``` CMake Error at /usr/lib/x86_64-linux-gnu/cmake/dune-grid/dune-grid-targets.cmake:78 (set_target_properties): The link interface of target "dunealbertagrid1d" contains: PkgConfig::Alberta1d but the target was not found. Possible reasons include: * There is a typo in the target name. * A find_package call is missing for an IMPORTED target. * An ALIAS target is missing. ``` --- cmake/Modules/FindAlberta.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmake/Modules/FindAlberta.cmake b/cmake/Modules/FindAlberta.cmake index e6fcd5853..685c1c6b0 100644 --- a/cmake/Modules/FindAlberta.cmake +++ b/cmake/Modules/FindAlberta.cmake @@ -44,3 +44,17 @@ else() set(ALBERTA_FOUND OFF) set(Alberta_FOUND OFF) endif() + +# PkgConfig targets are required if OPM modules are used as DUNE modules +# (e.g. in Debian's Packaging automatic tests) +find_package(PkgConfig) +if(PkgConfig_FOUND) + set(_opm_alberta_bkup_path ${CMAKE_PREFIX_PATH}) + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${ALBERTA_ROOT}) + + foreach(dim RANGE 1 ${ALBERTA_MAX_WORLD_DIM}) + pkg_check_modules(Alberta${dim}d IMPORTED_TARGET GLOBAL "alberta-grid_${dim}d") + endforeach() + + set(CMAKE_PREFIX_PATH ${_opm_alberta_bkup_path}) +endif()