> Boris Kolpackov wrote:
> > Peter Dimov via Boost <bo...@lists.boost.org> writes:
> >
> > > Since the CMake configuration files that are generated by `b2 install`
> > > define CMake targets based on the b2 targets, it's not possible to fix
> > > this just on the boost-install side. If we want Boost::process to
> > > appear as a target in CMake, we need boost_process to appear as a
> > > target in b2, that is, we need libs/process/build/Jamfile to exist.
> > >
> > > The easiest way to fix it - if we decide to do something about it - is
> > > to create dummy compiled libraries for each such header-only library
> > > that isn't really header-only because of dependencies.
> >
> > Wouldn't the proper way to fix this be to teach b2 first-class "binless"
> > library targets (i.e., a library that doesn't actually have .a/.so)?
>
> It might be possible to achieve something like that with alias targets,
> although I haven't tried.
>
B2 alias targets _are_ real targets (in the meta-target sense of the B2
build abstractions). I haven't looked at how the cmake files are generated
though. So not sure what that requires for it to work.
--
-- René Ferdinand Rivera Morell
-- Don't Assume Anything -- No Supone Nada
-- Robot Dreams - http://robot-dreams.net
> On Tue, Nov 2, 2021 at 2:04 PM Peter Dimov via Boost <
> bo...@lists.boost.org> wrote:
>
>> Boris Kolpackov wrote:
>> > Peter Dimov via Boost <bo...@lists.boost.org> writes:
>> >
>> > > Since the CMake configuration files that are generated by `b2 install`
>> > > define CMake targets based on the b2 targets, it's not possible to fix
>> > > this just on the boost-install side. If we want Boost::process to
>> > > appear as a target in CMake, we need boost_process to appear as a
>> > > target in b2, that is, we need libs/process/build/Jamfile to exist.
>> > >
>> > > The easiest way to fix it - if we decide to do something about it - is
>> > > to create dummy compiled libraries for each such header-only library
>> > > that isn't really header-only because of dependencies.
>> >
>> > Wouldn't the proper way to fix this be to teach b2 first-class "binless"
>> > library targets (i.e., a library that doesn't actually have .a/.so)?
>>
>> It might be possible to achieve something like that with alias targets,
>> although I haven't tried.
>>
>
> B2 alias targets _are_ real targets (in the meta-target sense of the B2
> build abstractions). I haven't looked at how the cmake files are generated
> though. So not sure what that requires for it to work.
>
PS. Projects are also real targets, in the same sense. So that might be an
option to hook into also.
I've skimmed through boost-install code and I think this is doable. There's
already a hard-coded list of b2 targets that should map to INTERFACE CMake
targets, it should be possible to extend the logic to any alias target.
One thing to note is that alias targets aren't visible on the level CMake
config module generation (inside boost-install) currently operates. This will
have the effect that if header-only boost_foo depends on header-only boost_bar
which in turn depends on compiled target boost_baz, CMake target Boost::foo
will depend on Boost::baz, not on Boost::bar.
Finally, there's a question of whether this should be done at all. CMake's
FindBoost does not declare any targets for header-only libraries. Conan-
generated CMake configs don't do that either. If a Boost user adds a dependency
to Boost::process in his CML, he is now required to use Boost-generated CMake
configs. This is OK when the build environment is controlled (e.g. closed
source), but probably is not OK for open source libraries that depend on
Boost.
It's not so simple because dependencies are gathered when generating
the build variants (as they may depend on the current properties) and
header-only libraries have none.
I think I'll just remove BOOST_ALL_NO_LIB for now and restore the behavior
of the FindBoost helper targets.
alias boost_foo : boost_bar ;
boost_foo has a dependency: boost_bar.
Maybe I misunderstood your point. There are no build variants for `alias`
targets, but there are no build variants for `INTERFACE` targets either. And
this actually can be used to tell apart header-only libraries and compiled in
the generating rule. `lib` targets do produce variants which refer back to
them, but `alias` targets do not.
A target can have different dependencies depending on the build variant. For
instance, toolset=msvc may depend on Atomic, but toolset=gcc not; or
address-model=32 may depend on foo32.lib, but address-model=64 on foo64.lib.
That's why in boost-install the dependencies are determined when the build
variant is processed (and emitted in the -config-variant-*.cmake file.)
But header-only libraries don't have any such.