Repository navigation
Conversation
…ure/cxx20-modules
Contributor
Author
|
See boostorg/cmake#105 for the full discussion, https://github.com/anarthal/boost-cmake/blob/feature/cxx20-modules/modules.md for the rationale I've been following. |
Collaborator
|
I'm not necessarily against this, but it will need documentation and testing support. |
soroshsabz
added a commit
to soroshsabz/program_options
that referenced
this pull request
Oct 23, 2026
…ncludes
Every standard-header include of the module units (the interface and
the BOOST_PROGRAM_OPTIONS_MODULE_UNIT preludes in src/*.cpp) now goes
through a local compatibility shim in src/cppm/std/, following the
pattern of the boost/config/std headers from boostorg/config PR #535
(Adds support for C++20 modules, not merged yet):
#ifdef BOOST_USE_MODULES
#ifndef BOOST_IN_MODULE_PURVIEW
import std;
#endif
#else
#include <string>
#endif
Today the shims compile to the plain includes (no behavior change);
once PR #535 is merged and the future modules mode (BOOST_USE_MODULES)
is used, they provide import std instead of textual includes inside
module units. Each shim carries a TODO comment to replace it with the
boost/config/std counterpart at that point; the README and the
documentation mention the PR as well.
Validated in fresh build directories: 15/15 tests, and the module test
with import std.
soroshsabz
added a commit
to soroshsabz/program_options
that referenced
this pull request
Oct 23, 2026
…ST_USE_MODULES
Every standard-header inclusion in the library's headers and sources is
now wrapped in one compatibility guard per include block, following the
pattern of the boost/config/std headers from boostorg/config PR #535
(Adds support for C++20 modules, not merged yet):
#ifdef BOOST_USE_MODULES
#ifndef BOOST_IN_MODULE_PURVIEW
import std;
#endif
#else
#include <...>
#endif
The guards are inactive today (BOOST_USE_MODULES is not defined), so
behavior is unchanged; each carries a TODO to switch to
<boost/config/std/...> when the PR is merged. In module units the
guarded std block sits after the textual dependency preloads, keeping
the MSVC-safe textual-before-import order, and the units define
BOOST_IN_MODULE_PURVIEW after their module declaration, per the
convention of that PR.
BOOST_USE_MODULES can now be enabled from CMake: the option activates
the module build, defines the macro for the module target, and requires
the toolchain std module (CMAKE_CXX_MODULE_STD plus a standard in
CMAKE_CXX_COMPILER_IMPORT_STD; fatal error otherwise). Full activation
of the ecosystem mode additionally requires modularized dependencies:
under this flag, already-converted dependencies such as Boost.TypeIndex
switch their headers to importing their own modules, superseding the
textual preloads used here until the PR #535 ecosystem lands. Noted in
CMakeLists.txt, README.md and doc/modules.xml.
Validated in fresh build directories: all 15 tests (classic build
unchanged) and the module test, both with textual preloads and with
import std.
soroshsabz
added a commit
to soroshsabz/program_options
that referenced
this pull request
Oct 23, 2026
convert.cpp originally included the standard headers before the Boost dependencies; the restructuring had moved them below. Restore the original order: the standard-library guard now sits at the headers' original position with the exact boostorg/config#535 pattern (BOOST_USE_MODULES branch). Because the textual Boost dependency includes follow it, the BOOST_PROGRAM_OPTIONS_USE_STD_MODULE 'import std;' for this file moves into the module closing block (after all textual includes, before the module declaration): MSVC reconciles textual includes followed by an explicit import, but rejects an import followed by textual includes. Validated in fresh build directories: all 15 tests (classic build unchanged), and the module test with textual preloads and with import std.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds "compatibility headers" <boost/config/std/xyz.hpp> to easily ifdef-out std dependencies in other libraries
Adds boost/config/disable_module_warnings.hpp, to disable warnings about angle-bracket includes in purviews
Changes some includes under some compilers to be more lightweight