Skip to content

feat(modules): create C++20 module files for common_system Phase 2#268

Merged
kcenon merged 3 commits into
mainfrom
feature/265-cpp20-modules
Jan 2, 2026
Merged

feat(modules): create C++20 module files for common_system Phase 2#268
kcenon merged 3 commits into
mainfrom
feature/265-cpp20-modules

Conversation

@kcenon

@kcenon kcenon commented Jan 2, 2026

Copy link
Copy Markdown
Owner

Summary

Changes

Module Structure

src/modules/
├── common.cppm              # Primary module (import kcenon.common;)
├── utils.cppm               # CircularBuffer, ObjectPool, source_location
├── error.cppm               # Error codes and categories
├── result.cppm              # Result aggregator
├── result/
│   ├── core.cppm            # Result<T>, Optional<T>, error_info
│   └── utilities.cppm       # Factory functions, exception conversion
├── concepts.cppm            # C++20 type constraints
├── interfaces.cppm          # Interfaces aggregator
├── interfaces/
│   └── core.cppm            # IExecutor, ILogger, IThreadPool
├── config.cppm              # Configuration utilities
├── di.cppm                  # Dependency injection
├── patterns.cppm            # EventBus implementation
└── logging.cppm             # Logging utilities

CMake Changes

  • Updated minimum CMake version to 3.28 for module support
  • Added COMMON_BUILD_MODULES option (default: OFF)
  • Added common_system_modules target with target-specific module scanning
  • Module scanning only applied to module target (avoids breaking CMake internal try_compile)

Test plan

  • Confirm backward compatibility with header includes (CI passed on all platforms)
  • Test on multiple compilers: ubuntu-22.04/clang, ubuntu-22.04/gcc, macos-latest/clang, windows-2022/msvc
  • All sanitizers passed (address, thread, undefined)
  • Static analysis passed (Clang-Tidy, Cppcheck)
  • Warning checks passed (GCC, Clang)
  • Build with modules enabled: cmake -DCOMMON_BUILD_MODULES=ON .. (optional feature, requires Phase 3)
  • Verify import kcenon.common; works correctly (Phase 3: Module Consumption Tests)
  • Verify individual partition imports work (Phase 3: Module Consumption Tests)

Note: Module build testing (COMMON_BUILD_MODULES=ON) is planned for Phase 3 (#266) which adds test examples. This PR focuses on creating the module interface files with backward-compatible default behavior.

Related

kcenon added 3 commits January 3, 2026 07:19
Add C++20 module files (.cppm) for common_system library as part of
the module migration Phase 2. This provides an alternative module-based
interface alongside the existing header-only approach.

Module structure:
- common.cppm: Primary module aggregator
- utils.cppm: CircularBuffer, ObjectPool, source_location
- error.cppm: Error codes and categories
- result/*.cppm: Result<T> pattern implementation
- concepts.cppm: C++20 type constraints
- interfaces/*.cppm: IExecutor, ILogger, IThreadPool
- config.cppm: Configuration utilities
- di.cppm: Dependency injection
- patterns.cppm: EventBus implementation
- logging.cppm: Logging utilities

CMake changes:
- Update minimum version to 3.28 for module support
- Add COMMON_BUILD_MODULES option (default: OFF)
- Add common_system_modules target for module builds
Document the addition of C++20 module interface files in the
unreleased section of the changelog.
Remove global CMAKE_CXX_SCAN_FOR_MODULES=ON which was causing CI
failures by affecting CMake's internal try_compile() calls in
FindThreads.cmake.

The module scanning is already properly enabled via target-specific
property (CXX_SCAN_FOR_MODULES ON) for the common_system_modules target
inside the COMMON_BUILD_MODULES conditional block.
@kcenon kcenon merged commit 496e3d9 into main Jan 2, 2026
22 checks passed
@kcenon kcenon deleted the feature/265-cpp20-modules branch January 2, 2026 22:39
kcenon added a commit that referenced this pull request Apr 13, 2026
)

* feat(modules): add C++20 module interface files (#265)

Add C++20 module files (.cppm) for common_system library as part of
the module migration Phase 2. This provides an alternative module-based
interface alongside the existing header-only approach.

Module structure:
- common.cppm: Primary module aggregator
- utils.cppm: CircularBuffer, ObjectPool, source_location
- error.cppm: Error codes and categories
- result/*.cppm: Result<T> pattern implementation
- concepts.cppm: C++20 type constraints
- interfaces/*.cppm: IExecutor, ILogger, IThreadPool
- config.cppm: Configuration utilities
- di.cppm: Dependency injection
- patterns.cppm: EventBus implementation
- logging.cppm: Logging utilities

CMake changes:
- Update minimum version to 3.28 for module support
- Add COMMON_BUILD_MODULES option (default: OFF)
- Add common_system_modules target for module builds

* docs(changelog): add C++20 module files entry (#265)

Document the addition of C++20 module interface files in the
unreleased section of the changelog.

* fix: remove global CMAKE_CXX_SCAN_FOR_MODULES setting

Remove global CMAKE_CXX_SCAN_FOR_MODULES=ON which was causing CI
failures by affecting CMake's internal try_compile() calls in
FindThreads.cmake.

The module scanning is already properly enabled via target-specific
property (CXX_SCAN_FOR_MODULES ON) for the common_system_modules target
inside the COMMON_BUILD_MODULES conditional block.
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.

[MODULE] Create C++20 module files for common_system - Phase 2

1 participant