Boost logo

Boost :

From: Ruben Perez (rubenperez038_at_[hidden])
Date: 2025-01-13 19:37:35


On Mon, 13 Jan 2025 at 20:14, Peter Dimov <pdimov_at_[hidden]> wrote:
>
> Ruben Perez wrote:
> > On Mon, 13 Jan 2025, 19:20 Peter Dimov via Boost, <boost_at_[hidden]
> > <mailto:boost_at_[hidden]> > wrote:
> >
> >
> > Ruben Perez wrote:
> > > [1] https://anarthal.github.io/cppblog/modules3
> >
> > > In particular, CMake under Windows doesn’t support the usual Visual
> > Studio generators when building modules.
> >
> > https://cmake.org/cmake/help/latest/manual/cmake-
> > cxxmodules.7.html
> > says that Visual Studio 17 2022 is supported.
> >
> >
> >
> > It also says it doesn't support installing modules
>
> What generator supports installing modules?

I thought this meant that installing module interfaces (.cppm) was not
supported. It is indeed supported. But see my next comments.

>
> > and building EXPORTED
> > targets involving modules, including the std module,
>
> IMPORTED. I'm not actually sure what this means.

I completely meant IMPORTED. This means that the find_package workflow
doesn't work with C++20 modules and Visual Studio generators. For
example:

find_package(mylib REQUIRED) # contains a static library in the form
of a C++20 module
add_executable(main main.cpp)
target_link_libraries(main PUBLIC mylib)

Fails with:

[cmake] CMake Error in CMakeLists.txt:
[cmake] Target "mylib_at_synth_701dd1d1595e" contains C++ modules intended for
[cmake] BMI-only compilation. This is not yet supported by the Visual Studio
[cmake] generator.

If I read the CMake docs correctly, mylib here is an IMPORTED target
that contains a PUBLIC CXX_MODULES FILE_SET. When encountering these,
CMake attempts to build a suitable binary module interface, which is
required to consume the module. This step is the one that isn't
supported by Visual Studio generators.

Interestingly, import std seems to be built on this same concept, and
thus doesn't work with Visual Studio generators:

[cmake] CMake Error in libs/mp11/test/CMakeLists.txt:
[cmake] The "CXX_MODULE_STD" property on the target "boost_mp11-mp_bind_front"
[cmake] requires that the "__CMAKE::CXX23" target exist, but it was
not provided by
[cmake] the toolchain. Reason:
[cmake]
[cmake] Unsupported generator: Visual Studio 17 2022

Thanks,
Ruben.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk