[cmake] Use targets to communicate dependencies
What this MR does / why does DuMux need it:
This MR implements the dumux targets in a more explicit way to follow modern CMake practices (following this suggestion). In particular, it avoids relying on the dune_enable_all_packages magic, and instead communicates the dependencies explicitly.
- Create a DuMuX libraries explicitly with
dune_add_library. This is analogous to CMake'sadd_librarybut it also integrates with the dune build system to automatically generate configuration file for downstream projects. - Add source files to libraries with native CMake
target_sources. This follows a regular CMake pattern instead of the outdateddune_library_add_sourcesfrom DUNE. - Express target dependencies explicitly with
target_link_librariesanddune_target_enable_all_packagesinstead of relying on the dune build system to link against everything. - Make module target
dumuxvisible to the whole project withlink_libraries.
The primary motivation for this MR is to address a new warning appearing in dune-common 2.11. However, similar to the core modules, this pattern also moves DuMuX towards a build system that may provide a CMake experience in downstream modules without the dune build system. In the future, when the dune build system is ready, people should ideally only consume the DuMuX::DuMuX target after finding the dumux CMake project without having anything to do with dune and its CMake.
Notes for the reviewer
- I do not know if step 4-th is actually needed. Usually, this is used by tests, but maybe you already link explicitly, I didn't check. This simply reproduces the previous behavior.
- Current pipeline fail seems to be unrelated to this MR.
- The formatting guidelines say that I should "Use named arguments only", I do not understand what exactly this means.
- I seem to not be able to run the lecture pipeline.
- The check lists ask for a test. I assume that CI acts as a test here, right?
- The CHANGELOG entry depends whether you want to advertise the new
DuMuX::DuMuXtarget (only present if dune-common(>=2.10)), or if you want to wait until you have full support.
Before you request a review from someone, make sure to revise the following points:
-
does the new code follow the style guide? -
do the test pipelines pass? (see guide on how to run pipelines for a merge request) -
is the code you changed and/or the new code you wrote covered in the test suite? (if not, extend the existing tests or write new ones) -
does your change affect public interfaces or behavior, or, does it introduce a new feature? If so, document the change in CHANGELOG.md. -
is the list of the header includes complete? ("include what you use") -
all files have to end with a \ncharacter. Make sure there is no\ No newline at end of filecomment in "Changes" of this MR.