Skip to content

Implement modules support#380

Merged
ednolan merged 1 commit intomainfrom
enolan_modules3
May 4, 2026
Merged

Implement modules support#380
ednolan merged 1 commit intomainfrom
enolan_modules3

Conversation

@ednolan
Copy link
Copy Markdown
Member

@ednolan ednolan commented May 4, 2026

This approach to modules implementation is based on the approach used to implement module support for Boost by Rubén Pérez (anarthal). See his documentation:
https://github.com/anarthal/boost-cmake/blob/e29bc2a5bd3493d353bf597610d4b32b5a11d0dc/modules.md

The basic idea is that every header is in one of three modes:

  • Normal mode (the user included the header, and we aren't building with modules)
    • In this case, the macros configure the header so its contents are the same as their pre-refactor state
  • included-from-interface-unit-mode
    • Here, we're inserting all the code from the header into an export block inside the implementation of the .cppm file, so this mode is the same as normal mode except that we ifdef out any standard library includes, or any other dependencies that the .cppm file is bringing in via module
  • Compatibility header mode
    • The project is built as a module, but the consumer still is bringing the dependency in by writing #include <{...}.hpp>. In this case the header #ifdefs out everything except a simple import beman.foo statement.

This approach to modules implementation is based on the approach used
to implement module support for Boost by Rubén Pérez (anarthal). See
his documentation:
https://github.com/anarthal/boost-cmake/blob/e29bc2a5bd3493d353bf597610d4b32b5a11d0dc/modules.md

The basic idea is that every header is in one of three modes:

- Normal mode (the user included the header, and we aren't building
  with modules)
  - In this case, the macros configure the header so its contents are
    the same as their pre-refactor state
- included-from-interface-unit-mode
  - Here, we're inserting all the code from the header into an export
    block inside the implementation of the .cppm file, so this mode
    is the same as normal mode except that we ifdef out any standard
    library includes, or any other dependencies that the .cppm file
    is bringing in via module
- Compatibility header mode
  - The project is built as a module, but the consumer still is
    bringing the dependency in by writing #include <{...}.hpp>.
    In this case the header #ifdefs out everything except a simple
    import beman.foo statement.
@ednolan ednolan force-pushed the enolan_modules3 branch from d93e2e2 to 818b4e8 Compare May 4, 2026 02:30
@coveralls
Copy link
Copy Markdown

coveralls commented May 4, 2026

Coverage Status

Coverage is 100.0%enolan_modules3 into main. No base build found for main.

@ednolan ednolan merged commit 7ab9de8 into main May 4, 2026
116 checks passed
@ednolan ednolan deleted the enolan_modules3 branch May 4, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants