This is a small example of using module, as described there: https://quuxplusone.github.io/blog/2019/11/07/modular-hello-world/ but using build2 to handled the compilation steps.
- Install build2https://build2.org/ (you might need the stage version, depends on what you want to do and if it's released yet or not)
- Make sure you have installed at least one compiler which supports modules.
- In this directory: bbuilds with the same compiler you used to installbuild2
- With clang: b config.cxx=clang++
- With gcc: b config.cxx=g++
- With msvc: b config.cxx=cl
- With a specific clang installed with it's version name: b config.cxx=clang++-9
- With a custom compiler (maybe one you built yourself): b config.cxx=path/to/the/cpp/compilerMore about compilation with build2: https://build2.org/doc.xhtml
Beware that not all compilers support all modules features yet. For example at the moment msvc don't support modules partitions (but it's incoming).
A slightly more complex example is in the with_libs directory, where we have a module which is in a separate library from the executable.
In this case, I use a feature provided by build2:  __symexport which automatically handles symbol import/export when building a dynamic library.
I also modified the original example to have the implementation of the hello function in a separate file, while still being part of the module helloworld.