Open requested to merge precompiled_solverfactory into master
This MR adds a cmake function for precompiling solvers and preconditioners for the solverfactory. The function is called
dune_precompile_solverfactory and accepts the following arguments:
REGISTER_GLOBALLY: Whether to register the library with
NAME: A name for the library target. If omitted it is generated with a hash of the OPERATORS and INCLUDES.
OPERATORS: The operator typenames for that the solvers and preconditioners should be precompiled.
INCLUDES: Files that should be included. E.g. for the definition of the operator types or for the definition of the solvers and preconditioners.
It works as follows:
- The source file of the library defines a global variable that it initialized with a call to
initSolverFactories<Op>()for every operator given in
- The problem is now to enforce the linker to import this symbol (in case of a static library) or to set it as a needed dependency (in case of a shared library). In the first case this can be solved by adding the linker flag
-u <symbolname>, where symbolname is the name of the variable defined in the library. In the latter case the only solution if found is to add
-Wl,--no-as-neededin the linker options.
There are two ways to use this:
- Register the library to the globally. Then all dune targets link to this library.
- Specify a name for the library and use
target_link_libraryto link explicitly. I used this approach in the test.
Note that this does not reduce the compile time of the applications that use the solverfactory. But you can omit the call to
initSolverFactories in the application or remove the includes to
preconditioners.hh (or other headers that define solvers). Both ways reduce the compile time then.
I'm not quite sure whether I used all the cmake things correctly. @simon.praetorius may you have a look?
@tkoch As you mentioned this at the dev-meeting can you check whether this works for you?