[build2] fmt library module
Boris Kolpackov
boris at codesynthesis.com
Mon Feb 21 11:02:34 UTC 2022
Lucas Ransan via users <users at build2.org> writes:
> I'm trying to use the {fmt} library with C++20 modules, without
> success.
I am guessing with GCC.
> I added
>
> depends: fmt ~8.1.0
>
> to ./manifest,
>
> cxx.std = experimental
> cxx.features.modules = true
>
> to ./build/root.build,
>
> import fmt;
>
> to ./src/main.cxx, but build2 says it is unable to resolve module fmt.
You also need to import lib{fmt} in your buildfile and link it to your
exe{}. Generally, I would recommend to first make sure everything works
with headers and then try to switch to modules.
> I can see in b -sV output
>
> config fmt@/gcc/fmt-8.1.1/
> enable_modules false
>
> which is weird, considering config.fmt.enable_modules is defined as
> equal to $cxx.features.modules (which is true).
I looked at the fmt 8.1.1 package and its support for modules is
a bit broken (at least at the build system level; there were also
some questions about the way upstream does things at the source
code level). For example, if I force-enable modules (by editing
fmt's root.build), I get the following error:
error: no rule to update fmt/src/mxx{fmt}
info: target fmt/src/mxx{fmt} is not declared in any buildfile
info: perhaps it is a missing source file?
And indeed, there is no fmt/src/fmt.cc in the archive (because the
way the buildfile uses if-else to select different prerequisites
is wrong; it should use the include variable instead).
So, in summary, I think if you would like to start using fmt as
a module and expect a smooth experience, then unfortunately you
will be disappointed, probably still for some time to come. But
if you are keen to help hack it into shape, we can give it a try.
More information about the users
mailing list