Skip to content

Draft: Create a module library in dune_project

Simon Praetorius requested to merge feature/target-include-directories into master

Summary

This MR adds a feature to the dune_project macro to create directly a library for the dune module. This library target can then be referred to by the variable DUNE_PROJECT_TARGET and is used in dune_add_test as default link library.

Since this allows to create a default target for each module that each executables should link against inside that module, we can register properties in this target, like the include directories for the dune module and default compile flags.

Details

The dune_project macro gets some additional (optional) arguments. It can be used as before without any argument to not create a default module library target. This has the consequence that we cannot register include directories in this target and thus have to set them globally.

The dune_project macro has the following interface:

dune_project([<target>] [INTERFACE]
    [OUTPUT_NAME <libname>]
    [EXPORT_NAME <exportname>]
)

with the following optional parameters:

  • INTERFACE: creates an interface library instead of a regular library. This can be used for header-only modules.
  • OUTPUT_NAME: Specifies the name of the library file, e.g. lib<libname>.so or lib<libname>.a. This parameter is directly forwarded to the dune_add_library macro. If no OUTPUT_NAME is given, the target name will be transformed into a proper output name by dune_module_to_output_name, i.e., it will be transformed into a lowercase string where all non-alphanumeric characters are removed.
  • EXPORT_NAME: Specifies the name of the exported target to be used when linking against the library. If no EXPORT_NAME is given, the target name will be transformed into a proper export name by dune_module_to_export_name, i.e., it will be transformed into a lowercase string with any dune- prefix removed removed.

TODO

  • Add CHANGELOG entry
  • Squash the Commits
Edited by Simon Praetorius

Merge request reports

Loading