Remove macro guards from Poco module#5268
Remove macro guards from Poco module#5268mikomikotaishi wants to merge 4 commits intopocoproject:mainfrom
Poco module#5268Conversation
|
Thanks for the PR! I like the goal of simplifying the module API, but I have a concern about how this interacts with Poco's optional component architecture. The problem: C++20 module partitions ( The previous design — separate modules ( Could you share more about the use case driving this? If the main goal is removing the Recommended: Generate Keep separate modules but have CMake generate the umbrella file, emitting only the set(POCO_MODULE_IMPORTS "")
if(ENABLE_FOUNDATION)
string(APPEND POCO_MODULE_IMPORTS "export import Poco.Foundation;\n")
endif()
if(ENABLE_CRYPTO)
string(APPEND POCO_MODULE_IMPORTS "export import Poco.Crypto;\n")
endif()
# ... etc
configure_file(Poco.cppm.in Poco.cppm @ONLY)This eliminates the preprocessor guards while preserving optional components. Other alternatives:
|
I think it only adds the empty partitions, but does not link anything (for example, if After all, the CI tests do succeed, which does suggest nothing is breaking between this change - it only makes all the module pieces into partitions which may or may not have exported contents. So, again, even though the partition |
But what is the point of having empty partitions?
C++ modules are built only in one CI job, not all. I am trying to understand the goal of these changes. I am probably missing something. |
I recalled at some point finding a paper that was adopted which prohibited |
|
Is this the article that you had in mind? https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1857r3.html |
Counter-Proposal: Per-Component Module Targets with
|
| Aspect | Current | This PR | Proposed |
|---|---|---|---|
#ifdef guards in .cppm |
Yes, everywhere | Removed (but empty partitions compiled) | Not needed — CMake controls what's built |
Minimal builds (ENABLE_CRYPTO=OFF) |
Works (conditional file list) | Compiles empty partition anyway | Works (.cppm never compiled) |
| Inter-component dependencies | Not expressed in modules | Lost (everything is one module) | Explicit import + target_link_libraries |
Separate Modules target |
Yes | Yes | Eliminated |
| Per-component CMake changes | None | None | One POCO_MODULE() call each |
| Module feature opt-in | Always built if sources present | Always built | ENABLE_POCO_MODULES=ON/OFF |
References
- CMake C++20 Modules Documentation —
FILE_SET CXX_MODULES, dependency scanning, installation - Kitware: import CMake; the Experiment is Over! — recommended patterns for multi-target module projects
- P1857R3: Modules Dependency Discovery — the actual restrictions on preprocessor + modules
- C++20 Modules, CMake, and Shared Libraries — practical guide for shared library projects
|
Ah, that was the paper, but indeed it does not restrict conditional That being said, we should continue with changing them to partitions. It would be a potential point of confusion for users to see both So, I'll return the CMake to the original form, but leave the files as partitions rather than full modules. |
This pull request makes the
Pocomodule only consist of partitions. This removes allPoco.*modules and turns them toPoco:*, so that only one module is created rather than several. This should simplify the API and make it far simpler to users (so there is no need to decide betweenimport Poco;orimport Poco.Foundation;, etc.)