WIP: Fix pkg config
Improve generation of pkg-config
files. This allows (or will allow) to use DUNE without the DUNE build-system and in particular without cmake
, just using the information provided by pkg-config
.
See #188
Feature
- both dune- and external-dependencies are added to
dune-common.pc
-
cmake
helper functions assist in collecting these dependencies - for external dependecies we either use their existing
pc
fiels or write our own ones (containing the information extracted from the cmake target) - helper functions write the
pc
files to keep the necessary effort in other modules as small as possible (see dune-geometry!155 and dune-istl!416) - several external dependencies are already fully supported
Possible Features
The current changes offer the possibility to use the pkg-config
files in DUNE modules further down the stack and avoid rerunning test already performed in one of the dependencies.
Open Questions
- there are still some packages that a tricky to implement. In particular
suitesparse
still needs some discussion. - we might transition several tests to use
pkg-config
and by this reduce thecmake
code we have to maintain. - how do we properly handle
config.h
, although this is a general question and not specific topkg-config
.
cmake
Using DUNE without With these new features it is now possible to use DUNE without the DUNE build-system and in particular without cmake
, just using the information provided by pkg-config
.
An example can be found in infrastructure/pkg-config-test, which will serve us as test-infrastructure.
The user has to set the PKG_CONFIG_PATH
and can then find the necessary DUNE flags.
> export PKG_CONFIG_PATH="[INSTALLDIR]/lib/pkg-config:[INSTALLDIR]/lib/pkg-config/dune:$PKG_CONFIG_PATH"
The he/she can use basically any type of build-system.
Here follow three examples:
Plain Makefile
CXXFLAGS = -g -Wall $(shell pkg-config --cflags dune-istl)
LDFLAGS = -g -Wall $(shell pkg-config --libs-only-L dune-istl)
LDLIBS = $(shell pkg-config --libs-only-l --libs-only-other dune-istl)
CC=g++
CXX=g++
all: myduneprogram
Meson
project('myduneprogram', 'cpp')
dune_istl = dependency('dune-istl')
executable('myduneprogram', ['src/myduneprogram.cc'], dependencies: dune_istl)
Plain CMake
cmake_minimum_required(VERSION 3.13)
project(myduneprogram LANGUAGES CXX)
include(FindPkgConfig)
pkg_check_modules(dune_istl REQUIRED IMPORTED_TARGET dune-istl)
add_executable(myduneprogram src/myduneprogram.cc)
target_link_libraries(myduneprogram PRIVATE PkgConfig::dune_istl)
target_include_directories(myduneprogam PRIVATE ${CMAKE_BINARY_DIR})