Resolve dune dependencies before or after DUNE_CUSTOM_PKG_CONFIG_SECTION?

The recent MR !1249 (merged) on the build system raised the question on whether the dependencies (this line) should be resolved before or after the DUNE_CUSTOM_PKG_CONFIG_SECTION variable is expanded and before or after setup of project variables. These are the options and the consequences I can foresee ATM:

  • After project variables and before DUNE_CUSTOM_PKG_CONFIG_SECTION: this is the current situation and leads to some generic variables prefixed with PACKAGE_* to be overwritten by other modules, hence, leading to bugs like this one: staging/dune-functions!477 (comment 137589).
  • Before project variables and before DUNE_CUSTOM_PKG_CONFIG_SECTION: It might be possible, but I don't know what are the consequences.
  • After project variables and after DUNE_CUSTOM_PKG_CONFIG_SECTION: In theory, this is possible, but I think we need to do this before the target files. Under certain conditions, this file checks that imported targets are fully set up and its dependencies are already fulfilled. This seems to not the case now, but it may come up in the future modifications to the module targets.